1. David Chambers
  2. jQuery.localize

Commits

David Chambers  committed 4389820

tests: improve the mechanism by which the various jQuery versions are loaded

  • Participants
  • Parent commits a355d69
  • Branches default

Comments (0)

Files changed (1)

File tests.html

View file
  • Ignore whitespace
     <time id="t4" datetime="2010-11-12T13:14:15.161718Z"></time>
     <time id="t5" datetime="2010-09-08T07:06:05.43Z"></time>
     <time id="t6" datetime="2010-11-20">Initial release</time>
-
-    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-1.4.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-1.4.1.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-1.4.2.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-1.4.3.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-1.4.4.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-1.5.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-1.5.1.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-1.5.2.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-1.6.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-1.6.1.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-1.6.2.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-1.6.3.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-1.6.4.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-1.7.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-1.7.1.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-1.7.2.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
-
-    <script src="http://code.jquery.com/jquery-latest.js"></script>
-    <script src="jquery.localize.js"></script>
-    <script src="tests.js"></script>
+    <script>
+      !function() {
+        var head, next, queue, version, versions
+        versions = [
+          '1.2', '1.2.1', '1.2.2', '1.2.3', '1.2.6',
+          '1.3', '1.3.1', '1.3.2',
+          '1.4', '1.4.1', '1.4.2', '1.4.3', '1.4.4',
+          '1.5', '1.5.1', '1.5.2',
+          '1.6', '1.6.1', '1.6.2', '1.6.3', '1.6.4',
+          '1.7', '1.7.1', '1.7.2',
+          'latest'
+        ]
+        queue = []
+        while (version = versions.pop()) {
+          queue.push(
+            'http://code.jquery.com/jquery-' + version + '.js',
+            './jquery.localize.js',
+            './tests.js'
+          )
+        }
+        // http://stackoverflow.com/a/4845802/312785
+        head = document.documentElement
+        next = function() {
+          var done, script, src
+          if (!(src = queue.shift())) return
+          done = false
+          script = document.createElement('script')
+          script.src = src.substr(0, 2) == './' ? src + '?' + (+new Date) : src
+          script.onload = script.onreadystatechange = function() {
+            var state = this.readyState
+            if (done || state && !/^(complete|loaded)$/.test(state)) return
+            done = true
+            next()
+            script.onload = script.onreadystatechange = null
+            if (head && script.parentNode) head.removeChild(script)
+          }
+          head.insertBefore(script, head.firstChild)
+        }
+        next()
+      }()
+    </script>
   </body>
 </html>