Skip to content

Commit 724ed9f

Browse files
committed
Fix loading jQuery in the offline reference
Currently, jQuery is being loaded from Google's CDN via a schemaless URI reference "//ajax.googleapis.com/...". When the reference is viewed offline, that URI reference resolves to "file://ajax.googleapis.com/...", which causes two problems: 1) jQuery is obviously not loaded (can be checked by seeing whether the navbar remains pinned to the top of the page when scrolling). This is mitigated by the fallbacks on some pages that attempt to load the local copy of jQuery if the Google copy didn't load, although some pages lack the fallbacks. 2) More importantly, when viewed on Windows, this causes long browser freezes, as Windows tries to look up the script in a shared folder on ajax.googleapis.com, which only fails after a long timeout. This commit fixes both problems by making the offline reference only refer to the local copy of jQuery.
1 parent 0406a31 commit 724ed9f

File tree

8 files changed

+11
-13
lines changed

8 files changed

+11
-13
lines changed

java_generate/ReferenceGenerator/src/writers/TemplateWriter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@ private Boolean write( String templateName, HashMap<String, String> vars, String
6565
ArrayList<String> output = new ArrayList<String>();
6666
vars.put("timestamp", getTimestamp());
6767
if(isLocal)
68-
{ //add local nav
68+
{
6969
vars.put( "webcontentpath", getRelativePathToRoot( outputName ) );
70+
vars.put("jquery", writePartial("jquery.local.partial.html", vars));
7071
vars.put("navigation", writePartial("nav.local.template.html", vars));
7172
} else
7273
{
7374
vars.put( "webcontentpath", "/" );
75+
vars.put("jquery", writePartial("jquery.web.partial.html", vars));
7476
vars.put("navigation", writePartial("nav.web.template.html", vars));
7577
}
7678

java_generate/templates/class.template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
</div>
123123

124124
</div>
125-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
125+
<!-- jquery -->
126126
<script src="<!-- webcontentpath -->javascript/site.js" type="text/javascript"></script>
127127
</body>
128128

java_generate/templates/generic.template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
</div>
124124

125125
</div>
126-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
126+
<!-- jquery -->
127127
<script src="<!-- webcontentpath -->javascript/site.js" type="text/javascript"></script>
128128
</body>
129129
</html>

java_generate/templates/index.alphabetical.template.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717

1818
<script src="<!-- webcontentpath -->javascript/modernizr-2.6.2.touch.js" type="text/javascript"></script>
1919
<link href="<!-- webcontentpath -->css/style.css" rel="stylesheet" type="text/css" />
20-
21-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
22-
<script>window.jQuery || document.write('<script src="<!-- webcontentpath -->javascript/jquery-1.9.1.min.js"><\/script>')</script>
23-
<script src="<!-- webcontentpath -->javascript/site.js" type="text/javascript"></script>
2420
</head>
2521
<body id="A-Z" onload="" >
2622

@@ -88,8 +84,7 @@ <h1 class="large-header"><span class="black">Reference.</span> The Processing La
8884
</div>
8985

9086
</div>
91-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
92-
<script>window.jQuery || document.write('<script src="<!-- webcontentpath -->javascript/jquery-1.9.1.min.js"><\/script>')</script>
87+
<!-- jquery -->
9388
<script src="<!-- webcontentpath -->javascript/site.js" type="text/javascript"></script>
9489
</body>
9590
</html>

java_generate/templates/index.template.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ <h5>Random</h5>
266266
</div>
267267

268268
</div>
269-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
270-
<script>window.jQuery || document.write('<script src="<!-- webcontentpath -->javascript/jquery-1.9.1.min.js"><\/script>')</script>
269+
<!-- jquery -->
271270
<script src="<!-- webcontentpath -->javascript/site.js" type="text/javascript"></script>
272271

273272
<script type="text/javascript">
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<script src="<!-- webcontentpath -->javascript/jquery-1.9.1.min.js"></script>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
2+
<script>window.jQuery || document.write('<script src="<!-- webcontentpath -->javascript/jquery-1.9.1.min.js"><\\/script>');</script>

java_generate/templates/library.index.template.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ <h5><!-- libraryname --> Events</h5>
7979
</div>
8080

8181
</div>
82-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
83-
<script>window.jQuery || document.write('<script src="<!-- webcontentpath -->javascript/jquery-1.9.1.min.js"><\/script>')</script>
82+
<!-- jquery -->
8483
<script src="<!-- webcontentpath -->javascript/site.js" type="text/javascript"></script>
8584
</body>
8685

0 commit comments

Comments
 (0)