[31748] | 1 | /** Javascript file for viewing documents */
|
---|
| 2 |
|
---|
[32072] | 3 | /** NOTE, this file uses inline templates which look for httpPath, assocfilepath, Source, Thumb, Title metadata. These need to be added into any xsl file that uses this javascript (using <gsf:metadata name="xx" hidden="true"/> if they are not already being collected. */
|
---|
| 4 |
|
---|
[25283] | 5 | var _imageZoomEnabled = false;
|
---|
[30772] | 6 | // Choose which types of filtering you want: sectionnum, or sectiontitle or both
|
---|
[30169] | 7 | var _filter_on_types = ["sectiontitle", "sectionnum"];
|
---|
[30772] | 8 |
|
---|
[30169] | 9 | // are titles numeric match?
|
---|
| 10 | var _filter_title_numeric = false;
|
---|
| 11 |
|
---|
[25283] | 12 | var _linkCellMap = new Array();
|
---|
| 13 | var _onCells = new Array();
|
---|
| 14 |
|
---|
[32158] | 15 | var curHLNum = null;
|
---|
[29173] | 16 |
|
---|
[29861] | 17 | /*Array to store init states of metadata fields and text*/
|
---|
| 18 | var editableInitStates = new Array();
|
---|
| 19 | /*Array to store last states of metadata fields and text*/
|
---|
| 20 | var editableLastStates = new Array();
|
---|
| 21 |
|
---|
[31050] | 22 |
|
---|
[24467] | 23 | /********************
|
---|
| 24 | * EXPANSION SCRIPTS *
|
---|
| 25 | ********************/
|
---|
| 26 |
|
---|
[32775] | 27 | /*
|
---|
| 28 | Given a string consisting of a single character, returns the %hex (%XX)
|
---|
| 29 | https://www.w3resource.com/javascript-exercises/javascript-string-exercise-27.php
|
---|
| 30 | https://stackoverflow.com/questions/40100096/what-is-equivalent-php-chr-and-ord-functions-in-javascript
|
---|
| 31 | https://www.w3resource.com/javascript-exercises/javascript-string-exercise-27.php
|
---|
| 32 | */
|
---|
| 33 | function urlEncodeChar(single_char_string) {
|
---|
| 34 | /*var hex = Number(single_char_string.charCodeAt(0)).toString(16);
|
---|
| 35 | var str = "" + hex;
|
---|
| 36 | str = "%" + str.toUpperCase();
|
---|
| 37 | return str;
|
---|
| 38 | */
|
---|
| 39 |
|
---|
| 40 | var hex = "%" + Number(single_char_string.charCodeAt(0)).toString(16).toUpperCase();
|
---|
| 41 | return hex;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
[32772] | 44 | /*
|
---|
| 45 | Tomcat 8 appears to be stricter in requiring unsafe and reserved chars
|
---|
| 46 | in URLs to be escaped with URL encoding
|
---|
| 47 | See section "Character Encoding Chart of
|
---|
| 48 | https://perishablepress.com/stop-using-unsafe-characters-in-urls/
|
---|
| 49 | Reserved chars:
|
---|
| 50 | ; / ? : @ = &
|
---|
| 51 | -----> %3B %2F %3F %3A %40 %3D %26
|
---|
| 52 | Unsafe chars:
|
---|
| 53 | " < > # % { } | \ ^ ~ [ ] ` and SPACE/BLANK
|
---|
| 54 | ----> %22 %3C %3E %23 %25 %7B %7D %7C %5C %5E ~ %5B %5D %60 and %20
|
---|
| 55 | But the above conflicts with the reserved vs unreserved listings at
|
---|
| 56 | https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI
|
---|
| 57 | Possibly more info: https://stackoverflow.com/questions/1547899/which-characters-make-a-url-invalid
|
---|
[32767] | 58 |
|
---|
[32775] | 59 | Javascript already provides functions encodeURI() and encodeURIComponent(), see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI
|
---|
| 60 | However, the set of chars they deal with only partially overlap with the set of chars that need encoding as per the RFC3986 for URIs and RFC1738 for URLs discussed at
|
---|
| 61 | https://perishablepress.com/stop-using-unsafe-characters-in-urls/
|
---|
| 62 | We want to handle all the characters listed as unsafe and reserved at https://perishablepress.com/stop-using-unsafe-characters-in-urls/
|
---|
| 63 | so we define and use our own conceptually equivalent methods for both existing JavaScript methods:
|
---|
| 64 | - makeSafeURL() for Javascript's encodeURI() to make sure all unsafe characters in URLs are escaped by being URL encoded
|
---|
| 65 | - and makeSafeURLComponent() for JavaScript's encodeURIComponent to additionally make sure all reserved characters in a URL portion are escaped by being URL encoded too
|
---|
| 66 |
|
---|
| 67 | Function makeSafeURL() is passed a string that represents a URL and therefore only deals with characters that are unsafe in a URL and which therefore require escaping.
|
---|
| 68 | Function makeSafeURLComponent() deals with portions of a URL that when decoded need not represent a URL at all, for example data like inline templates passed in as a
|
---|
| 69 | URL query string's parameter values. As such makeSafeURLComponent() should escape both unsafe URL characters and characters that are reserved in URLs since reserved
|
---|
| 70 | characters in the query string part (as query param values representing data) may take on a different meaning from their reserved meaning in a URL context.
|
---|
[32772] | 71 | */
|
---|
[32775] | 72 |
|
---|
| 73 | /* URL encodes both
|
---|
| 74 | - UNSAFE characters to make URL safe, by calling makeSafeURL()
|
---|
| 75 | - and RESERVED characters (characters that have reserved meanings within a URL) to make URL valid, since the url component parameter could use reserved characters
|
---|
| 76 | in a non-URL sense. For example, the inline template (ilt) parameter value of a URL could use '=' and '&' signs where these would have XSLT rather than URL meanings.
|
---|
| 77 |
|
---|
| 78 | See end of https://www.w3schools.com/jsref/jsref_replace.asp to use a callback passing each captured element of a regex in str.replace()
|
---|
| 79 | */
|
---|
| 80 | function makeURLComponentSafe(url_part, encode_percentages) {
|
---|
[32773] | 81 | // https://stackoverflow.com/questions/12797118/how-can-i-declare-optional-function-parameters-in-javascript
|
---|
| 82 | encode_percentages = encode_percentages || 1; // this method forces the URL-encoding of any % in url_part, e.g. do this for inline-templates that haven't ever been encoded
|
---|
[32772] | 83 |
|
---|
[32774] | 84 | var url_encoded = makeURLSafe(url_part, encode_percentages);
|
---|
[32775] | 85 | //return url_encoded.replace(/;/g, "%3B").replace(/\//g, "%2F").replace(/\?/g, "%3F").replace(/\:/g, "%3A").replace(/\@/g, "%40").replace(/=/g, "%3D").replace(/\&/g,"%26");
|
---|
| 86 | url_encoded = url_encoded.replace(/[\;\/\?\:\@\=\&]/g, function(s) {
|
---|
| 87 | return urlEncodeChar(s);
|
---|
| 88 | });
|
---|
[32772] | 89 | return url_encoded;
|
---|
[32767] | 90 | }
|
---|
| 91 |
|
---|
[32772] | 92 | /*
|
---|
[32775] | 93 | URL encode UNSAFE characters to make URL passed in safe.
|
---|
| 94 | Set encode_percentages to 1 (true) if you don't want % signs encoded: you'd do so if the url is already partly URL encoded.
|
---|
[32772] | 95 | */
|
---|
[32774] | 96 | function makeURLSafe(url, encode_percentages) {
|
---|
| 97 | encode_percentages = encode_percentages || 0; // https://stackoverflow.com/questions/12797118/how-can-i-declare-optional-function-parameters-in-javascript
|
---|
[32772] | 98 |
|
---|
| 99 | var url_encoded = url;
|
---|
[32774] | 100 | if(encode_percentages) { url_encoded = url_encoded.replace(/\%/g,"%25"); } // encode % first
|
---|
[32775] | 101 | //url_encoded = url_encoded.replace(/ /g, "%20").replace(/\"/g,"%22").replace(/\</g,"%3C").replace(/\>/g,"%3E").replace(/\#/g,"%23").replace(/\{/g,"%7B").replace(/\}/g,"%7D");
|
---|
| 102 | //url_encoded = url_encoded.replace(/\|/g,"%7C").replace(/\\/g,"%5C").replace(/\^/g,"%5E").replace(/\[/g,"%5B").replace(/\]/g,"%5D").replace(/\`/g,"%60");
|
---|
[32774] | 103 | // Should we handle ~, but then what is its URL encoded value? Because https://meyerweb.com/eric/tools/dencoder/ URLencodes ~ to ~.
|
---|
[32775] | 104 | //return url_encoded;
|
---|
| 105 | url_encoded = url_encoded.replace(/[\ \"\<\>\#\{\}\|\\^\~\[\]\`]/g, function(s) {
|
---|
| 106 | return urlEncodeChar(s);
|
---|
| 107 | });
|
---|
[32772] | 108 | return url_encoded;
|
---|
| 109 | }
|
---|
| 110 |
|
---|
[25366] | 111 | function getTextForSection(sectionID, callback)
|
---|
[24467] | 112 | {
|
---|
[25366] | 113 | if(!callback)
|
---|
| 114 | {
|
---|
| 115 | console.log("Cannot get text as the callback function is not defined");
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | var template = "";
|
---|
| 119 | template += '<xsl:template match="/">';
|
---|
| 120 | template += '<text>';
|
---|
[25441] | 121 | template += '<xsl:for-each select="/page/pageResponse/document//documentNode[@nodeID = \'' + sectionID + '\']">';
|
---|
[26020] | 122 | template += '<xsl:call-template name="sectionContent"/>';
|
---|
[25441] | 123 | template += '</xsl:for-each>';
|
---|
[25366] | 124 | template += '</text>';
|
---|
| 125 | template += '</xsl:template>';
|
---|
[32767] | 126 |
|
---|
[32775] | 127 | template = makeURLComponentSafe(template);
|
---|
[32767] | 128 |
|
---|
[25720] | 129 | var hlCheckBox = document.getElementById("highlightOption");
|
---|
| 130 |
|
---|
| 131 | var hl = "";
|
---|
| 132 | if(hlCheckBox)
|
---|
| 133 | {
|
---|
| 134 | if(hlCheckBox.checked)
|
---|
| 135 | {
|
---|
| 136 | hl = "on";
|
---|
| 137 | }
|
---|
| 138 | else
|
---|
| 139 | {
|
---|
| 140 | hl = "off";
|
---|
| 141 | }
|
---|
| 142 | }
|
---|
| 143 |
|
---|
[32767] | 144 | var url = gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/document/" + sectionID + "?ed=1&hl=" + hl + "&ilt=" + template;
|
---|
[32502] | 145 | if (gs.cgiParams.p_s && gs.cgiParams.p_s.length > 0) {
|
---|
| 146 | url += "&p.s=" + gs.cgiParams.p_s;
|
---|
| 147 | }
|
---|
[32718] | 148 | if (gs.cgiParams.ck && gs.cgiParams.ck.length > 0) {
|
---|
| 149 | url += "&ck=" + gs.cgiParams.ck;
|
---|
| 150 | }
|
---|
| 151 |
|
---|
[32502] | 152 |
|
---|
[26397] | 153 |
|
---|
| 154 | $.ajax(url)
|
---|
| 155 | .success(function(response)
|
---|
[25366] | 156 | {
|
---|
[26397] | 157 | if(response)
|
---|
[25366] | 158 | {
|
---|
[26397] | 159 | var textStart = response.indexOf(">", response.indexOf(">") + 1) + 1;
|
---|
| 160 | var textEnd = response.lastIndexOf("<");
|
---|
[25366] | 161 |
|
---|
[26397] | 162 | if(textStart == 0 || textEnd == -1 || textEnd <= textStart)
|
---|
[25366] | 163 | {
|
---|
[26397] | 164 | callback("");
|
---|
[25366] | 165 | }
|
---|
[26397] | 166 |
|
---|
| 167 | var text = response.substring(textStart, textEnd);
|
---|
| 168 | callback(text);
|
---|
[25366] | 169 | }
|
---|
[26397] | 170 | else
|
---|
[25366] | 171 | {
|
---|
| 172 | callback(null);
|
---|
| 173 | }
|
---|
[26397] | 174 | })
|
---|
| 175 | .error(function()
|
---|
| 176 | {
|
---|
| 177 | callback(null);
|
---|
| 178 | });
|
---|
[25366] | 179 | }
|
---|
| 180 |
|
---|
| 181 | function getSubSectionsForSection(sectionID, callback)
|
---|
| 182 | {
|
---|
| 183 | if(!callback)
|
---|
| 184 | {
|
---|
| 185 | console.log("Cannot get sub sections as the callback function is not defined");
|
---|
| 186 | }
|
---|
| 187 |
|
---|
| 188 | var template = "";
|
---|
| 189 | template += '<xsl:template match="/">';
|
---|
| 190 | template += '<sections>';
|
---|
[25441] | 191 | template += '<xsl:for-each select="/page/pageResponse/document//documentNode[@nodeID = \'' + sectionID + '\']/documentNode">';
|
---|
[25366] | 192 | template += '<xsl:call-template name="wrapDocumentNodes"/>';
|
---|
| 193 | template += '</xsl:for-each>';
|
---|
| 194 | template += '</sections>';
|
---|
| 195 | template += '</xsl:template>';
|
---|
| 196 |
|
---|
[32775] | 197 | template = makeURLComponentSafe(template);
|
---|
[32767] | 198 | var url = gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/document/" + sectionID + "?ilt=" + template;
|
---|
[25936] | 199 |
|
---|
[32502] | 200 | if(gs.documentMetadata.docType == "paged")
|
---|
[25936] | 201 | {
|
---|
| 202 | url += "&dt=hierarchy";
|
---|
| 203 | }
|
---|
[26397] | 204 |
|
---|
| 205 | $.ajax(url)
|
---|
| 206 | .success(function(response)
|
---|
[25366] | 207 | {
|
---|
[26397] | 208 | if(response)
|
---|
[25366] | 209 | {
|
---|
[26397] | 210 | var sectionsStart = response.indexOf(">", response.indexOf(">") + 1) + 1;
|
---|
| 211 | var sectionsEnd = response.lastIndexOf("<");
|
---|
[25366] | 212 |
|
---|
[26397] | 213 | if(sectionsStart == 0 || sectionsEnd == -1 || sectionsEnd <= sectionsStart)
|
---|
[25366] | 214 | {
|
---|
[26397] | 215 | callback(" ");
|
---|
| 216 | return;
|
---|
[25366] | 217 | }
|
---|
[26397] | 218 |
|
---|
| 219 | var sections = response.substring(sectionsStart, sectionsEnd);
|
---|
| 220 | callback(sections);
|
---|
[25366] | 221 | }
|
---|
[26397] | 222 | else
|
---|
[25366] | 223 | {
|
---|
| 224 | callback(null);
|
---|
| 225 | }
|
---|
[26397] | 226 | })
|
---|
| 227 | .error(function()
|
---|
| 228 | {
|
---|
| 229 | callback(null);
|
---|
| 230 | });
|
---|
[25366] | 231 | }
|
---|
| 232 |
|
---|
[25441] | 233 | function toggleSection(sectionID, callback, tocDisabled)
|
---|
[25366] | 234 | {
|
---|
[26397] | 235 | var docElem = gs.jqGet("doc" + sectionID);
|
---|
| 236 | var tocElem = gs.jqGet("toc" + sectionID);
|
---|
[24467] | 237 |
|
---|
[26397] | 238 | var tocToggleElem = gs.jqGet("ttoggle" + sectionID);
|
---|
| 239 | var docToggleElem = gs.jqGet("dtoggle" + sectionID);
|
---|
[24467] | 240 |
|
---|
[26397] | 241 | if(docElem.css("display") == "none")
|
---|
[24467] | 242 | {
|
---|
[26397] | 243 | if(tocToggleElem.length && !tocDisabled)
|
---|
[24467] | 244 | {
|
---|
[26397] | 245 | tocToggleElem.attr("src", gs.imageURLs.collapse);
|
---|
[24467] | 246 | }
|
---|
| 247 |
|
---|
[26397] | 248 | if(tocElem.length && !tocDisabled)
|
---|
[24467] | 249 | {
|
---|
[26397] | 250 | tocElem.css("display", "block");
|
---|
[24467] | 251 | }
|
---|
[25366] | 252 |
|
---|
[26397] | 253 | if(docElem.hasClass("noText"))
|
---|
[25366] | 254 | {
|
---|
| 255 | getTextForSection(sectionID, function(text)
|
---|
| 256 | {
|
---|
| 257 | if(text)
|
---|
| 258 | {
|
---|
[25462] | 259 | var nodeID = sectionID.replace(/\./g, "_");
|
---|
| 260 | if(text.search("wrap" + nodeID) != -1)
|
---|
| 261 | {
|
---|
[26408] | 262 | $("#zoomOptions").css("display", "");
|
---|
| 263 | $("#pagedImageOptions").css("display", "");
|
---|
[25462] | 264 | }
|
---|
[25366] | 265 | getSubSectionsForSection(sectionID, function(sections)
|
---|
[25462] | 266 | {
|
---|
[25366] | 267 | if(sections)
|
---|
| 268 | {
|
---|
[26397] | 269 | var textElem = gs.jqGet("doc" + sectionID);
|
---|
| 270 | textElem.html(text + sections);
|
---|
[25366] | 271 |
|
---|
[26397] | 272 | docElem.removeClass("noText");
|
---|
| 273 | docElem.css("display", "block");
|
---|
| 274 | docToggleElem.attr("src", gs.imageURLs.collapse);
|
---|
[25366] | 275 |
|
---|
| 276 | if(callback)
|
---|
| 277 | {
|
---|
| 278 | callback(true);
|
---|
| 279 | }
|
---|
[25441] | 280 |
|
---|
[26397] | 281 | if(gs.jqGet("viewSelection").length)
|
---|
[25441] | 282 | {
|
---|
| 283 | changeView();
|
---|
| 284 | }
|
---|
[25366] | 285 | }
|
---|
| 286 | else
|
---|
| 287 | {
|
---|
[26397] | 288 | docToggleElem.attr("src", gs.imageURLs.expand);
|
---|
[25366] | 289 | if(callback)
|
---|
| 290 | {
|
---|
| 291 | callback(false);
|
---|
| 292 | }
|
---|
| 293 | }
|
---|
| 294 | });
|
---|
| 295 | }
|
---|
| 296 | else
|
---|
| 297 | {
|
---|
[26397] | 298 | docToggleElem.attr("src", gs.imageURLs.expand);
|
---|
[25366] | 299 | if(callback)
|
---|
| 300 | {
|
---|
| 301 | callback(false);
|
---|
| 302 | }
|
---|
| 303 | }
|
---|
| 304 | });
|
---|
| 305 |
|
---|
[26397] | 306 | docToggleElem.attr("src", gs.imageURLs.loading);
|
---|
[25366] | 307 | }
|
---|
| 308 | else
|
---|
| 309 | {
|
---|
[26397] | 310 | docToggleElem.attr("src", gs.imageURLs.collapse);
|
---|
| 311 | docElem.css("display", "block");
|
---|
[25366] | 312 |
|
---|
| 313 | if(callback)
|
---|
| 314 | {
|
---|
| 315 | callback(true);
|
---|
| 316 | }
|
---|
| 317 | }
|
---|
[24467] | 318 | }
|
---|
| 319 | else
|
---|
| 320 | {
|
---|
[26397] | 321 | docElem.css("display", "none");
|
---|
[24467] | 322 |
|
---|
| 323 | //Use the page image if this is a leaf node and the chapter image if it not
|
---|
[26397] | 324 | docToggleElem.attr("src", gs.imageURLs.expand);
|
---|
[24467] | 325 |
|
---|
[26397] | 326 | if(tocToggleElem.length)
|
---|
[24467] | 327 | {
|
---|
[26397] | 328 | tocToggleElem.attr("src", gs.imageURLs.expand);
|
---|
[24467] | 329 | }
|
---|
| 330 |
|
---|
[26397] | 331 | if(tocElem.length)
|
---|
[24467] | 332 | {
|
---|
[26397] | 333 | tocElem.css("display", "none");
|
---|
[24467] | 334 | }
|
---|
[25366] | 335 |
|
---|
| 336 | if(callback)
|
---|
| 337 | {
|
---|
| 338 | callback(true);
|
---|
| 339 | }
|
---|
[24467] | 340 | }
|
---|
| 341 | }
|
---|
| 342 |
|
---|
[25366] | 343 | function scrollToTop()
|
---|
| 344 | {
|
---|
| 345 | $('html, body').stop().animate({scrollTop: 0}, 1000);
|
---|
| 346 | }
|
---|
| 347 |
|
---|
[32157] | 348 | function scrollNextHightlight()
|
---|
| 349 | {
|
---|
| 350 | if (curHLNum == null)
|
---|
| 351 | {
|
---|
| 352 | curHLNum = 0;
|
---|
| 353 | } else
|
---|
| 354 | {
|
---|
| 355 | curHLNum++;
|
---|
| 356 | }
|
---|
| 357 | var hlNode = $("span[class$='ermHighlight']:eq(" + curHLNum + ")");
|
---|
| 358 | if (hlNode.length == 0)
|
---|
| 359 | {
|
---|
| 360 | curHLNum = 0;
|
---|
| 361 | hlNode = $("span[class$='ermHighlight']:eq(" + curHLNum + ")");
|
---|
| 362 | }
|
---|
| 363 | if (hlNode.length != 0)
|
---|
| 364 | {
|
---|
| 365 | var topVal = $(hlNode).offset().top - 50;
|
---|
| 366 | $('html, body').stop().animate({scrollTop: topVal}, 1000);
|
---|
| 367 | }
|
---|
| 368 | }
|
---|
| 369 |
|
---|
| 370 | function scrollPrevHightlight()
|
---|
| 371 | {
|
---|
| 372 | if (curHLNum == null)
|
---|
| 373 | {
|
---|
| 374 | curHLNum = $("span[class$='ermHighlight']").length - 1;
|
---|
| 375 | } else
|
---|
| 376 | {
|
---|
| 377 | curHLNum--;
|
---|
| 378 | }
|
---|
| 379 | var hlNode = $("span[class$='ermHighlight']:eq(" + curHLNum + ")");
|
---|
| 380 | if (hlNode.length == 0)
|
---|
| 381 | {
|
---|
| 382 | curHLNum = $("span[class$='ermHighlight']").length - 1;
|
---|
| 383 | hlNode = $("span[class$='ermHighlight']:eq(" + curHLNum + ")");
|
---|
| 384 | }
|
---|
| 385 | if (hlNode.length != 0)
|
---|
| 386 | {
|
---|
| 387 | var topVal = $(hlNode).offset().top - 50;
|
---|
| 388 | $('html, body').stop().animate({scrollTop: topVal}, 1000);
|
---|
| 389 | }
|
---|
| 390 | }
|
---|
| 391 |
|
---|
[25441] | 392 | function focusSection(sectionID, level, tocDisabled)
|
---|
[25366] | 393 | {
|
---|
[31429] | 394 | expandAndExecute(sectionID, level, tocDisabled, function()
|
---|
[25366] | 395 | {
|
---|
[31429] | 396 | var topVal = $(document.getElementById("doc" + sectionID)).offset().top - 50;
|
---|
| 397 | $('html, body').stop().animate({scrollTop: topVal}, 1000);
|
---|
| 398 | });
|
---|
[25366] | 399 | }
|
---|
[31416] | 400 | function focusAnchor(sectionID, level, tocDisabled, anchor)
|
---|
| 401 | {
|
---|
[31429] | 402 | expandAndExecute(sectionID, level, tocDisabled, function()
|
---|
| 403 | {
|
---|
| 404 | var target = document.getElementById(anchor);
|
---|
| 405 | if (!target){
|
---|
| 406 | target = document.getElementsByName(anchor)[0];
|
---|
| 407 | }
|
---|
| 408 | var topVal = $(target).offset().top - 50;
|
---|
| 409 | $('html, body').stop().animate({scrollTop: topVal}, 1000);
|
---|
| 410 | window.location.hash = anchor;
|
---|
| 411 | });
|
---|
| 412 | }
|
---|
| 413 | function expandAndExecute(sectionID, level, tocDisabled, executeAfter)
|
---|
| 414 | {
|
---|
[31416] | 415 | if(!level)
|
---|
| 416 | {
|
---|
| 417 | level = 0;
|
---|
| 418 | }
|
---|
| 419 | var parts = sectionID.split(".");
|
---|
| 420 | if(level >= parts.length)
|
---|
[32602] | 421 | {
|
---|
| 422 | if (executeAfter) {
|
---|
| 423 | executeAfter();
|
---|
| 424 | }
|
---|
[31430] | 425 | document.getElementById("gs_content").style.cursor = "default";
|
---|
[31416] | 426 | return;
|
---|
| 427 | }
|
---|
| 428 |
|
---|
| 429 | var idToExpand = "";
|
---|
| 430 | for(var i = 0; i < level + 1; i++)
|
---|
| 431 | {
|
---|
| 432 | if(i > 0)
|
---|
| 433 | {
|
---|
| 434 | idToExpand += ".";
|
---|
| 435 | }
|
---|
| 436 |
|
---|
| 437 | idToExpand += parts[i];
|
---|
| 438 | }
|
---|
| 439 |
|
---|
| 440 | if(!isSectionExpanded(idToExpand))
|
---|
| 441 | {
|
---|
[31430] | 442 | document.getElementById("gs_content").style.cursor = "progress";
|
---|
[31416] | 443 | toggleSection(idToExpand, function(success)
|
---|
| 444 | {
|
---|
| 445 | if(success)
|
---|
| 446 | {
|
---|
[31429] | 447 | expandAndExecute(sectionID, level + 1, tocDisabled, executeAfter);
|
---|
[31416] | 448 | }
|
---|
| 449 | }, tocDisabled);
|
---|
| 450 | }
|
---|
| 451 | else
|
---|
| 452 | {
|
---|
[31429] | 453 | expandAndExecute(sectionID, level + 1, tocDisabled, executeAfter);
|
---|
[31416] | 454 | }
|
---|
| 455 | }
|
---|
[25366] | 456 | function expandOrCollapseAll(expand)
|
---|
| 457 | {
|
---|
[26397] | 458 | var divs = $("div");
|
---|
[25366] | 459 | var startCounter = 0;
|
---|
| 460 | var endCounter = 0;
|
---|
| 461 |
|
---|
| 462 | for(var i = 0; i < divs.length; i++)
|
---|
| 463 | {
|
---|
[26397] | 464 | if($(divs[i]).attr("id") && $(divs[i]).attr("id").search(/^doc/) != -1)
|
---|
[25366] | 465 | {
|
---|
[26397] | 466 | var id = $(divs[i]).attr("id").replace(/^doc(.*)/, "$1");
|
---|
[30703] | 467 | if(isSectionExpanded(id) != expand)
|
---|
[25366] | 468 | {
|
---|
| 469 | //Don't collapse the top level
|
---|
| 470 | if(!expand && id.indexOf(".") == -1)
|
---|
| 471 | {
|
---|
| 472 | continue;
|
---|
| 473 | }
|
---|
| 474 | startCounter++;
|
---|
[25462] | 475 |
|
---|
[25366] | 476 | var toggleFunction = function(tid)
|
---|
| 477 | {
|
---|
| 478 | toggleSection(tid, function(success)
|
---|
| 479 | {
|
---|
| 480 | if(success)
|
---|
| 481 | {
|
---|
| 482 | endCounter++;
|
---|
| 483 | }
|
---|
| 484 | else
|
---|
| 485 | {
|
---|
| 486 | setTimeout(function(){toggleFunction(tid)}, 500);
|
---|
| 487 | }
|
---|
| 488 | });
|
---|
| 489 | }
|
---|
| 490 | toggleFunction(id);
|
---|
| 491 | }
|
---|
| 492 | }
|
---|
| 493 | }
|
---|
| 494 |
|
---|
| 495 | if(startCounter != 0)
|
---|
| 496 | {
|
---|
| 497 | var checkFunction = function()
|
---|
| 498 | {
|
---|
| 499 | if(startCounter == endCounter)
|
---|
| 500 | {
|
---|
| 501 | expandOrCollapseAll(expand);
|
---|
| 502 | }
|
---|
| 503 | else
|
---|
| 504 | {
|
---|
| 505 | setTimeout(checkFunction, 500);
|
---|
| 506 | }
|
---|
| 507 | }
|
---|
[25441] | 508 | checkFunction();
|
---|
[25366] | 509 | }
|
---|
| 510 | }
|
---|
| 511 |
|
---|
[25936] | 512 | function loadTopLevelPage(callbackFunction, customURL)
|
---|
[25366] | 513 | {
|
---|
[26397] | 514 | var url;
|
---|
| 515 | if(customURL)
|
---|
[25641] | 516 | {
|
---|
[26397] | 517 | url = customURL;
|
---|
[25641] | 518 | }
|
---|
[25936] | 519 | else
|
---|
| 520 | {
|
---|
[26397] | 521 | url = gs.xsltParams.library_name + "?a=d&c=" + gs.cgiParams.c + "&excerptid=gs-document";
|
---|
| 522 | if(gs.cgiParams.d && gs.cgiParams.d.length > 0)
|
---|
| 523 | {
|
---|
| 524 | url += "&d=" + gs.cgiParams.d.replace(/([^.]*)\..*/, "$1");
|
---|
| 525 | }
|
---|
| 526 | else if(gs.cgiParams.href && gs.cgiParams.href.length > 0)
|
---|
| 527 | {
|
---|
| 528 | url += "&d=&alb=1&rl=1&href=" + gs.cgiParams.href;
|
---|
| 529 | }
|
---|
[25936] | 530 | }
|
---|
[26205] | 531 |
|
---|
[26397] | 532 | $.ajax(url)
|
---|
| 533 | .success(function(response)
|
---|
[25366] | 534 | {
|
---|
[26397] | 535 | if(response)
|
---|
[25366] | 536 | {
|
---|
[26401] | 537 | var targetElem = $("#gs-document");
|
---|
[26397] | 538 | var docStart = response.indexOf(">") + 1;
|
---|
| 539 | var docEnd = response.lastIndexOf("<");
|
---|
| 540 | var doc = response.substring(docStart, docEnd);
|
---|
| 541 |
|
---|
| 542 | targetElem.html(doc);
|
---|
[25366] | 543 |
|
---|
[26397] | 544 | if(callbackFunction)
|
---|
[25366] | 545 | {
|
---|
[26397] | 546 | callbackFunction();
|
---|
[25366] | 547 | }
|
---|
| 548 | }
|
---|
[26397] | 549 | })
|
---|
| 550 | .error(function()
|
---|
| 551 | {
|
---|
| 552 | setTimeout(function(){loadTopLevelPage(callbackFunction, customURL);}, 1000);
|
---|
| 553 | });
|
---|
[25366] | 554 | }
|
---|
| 555 |
|
---|
[30478] | 556 | function retrieveFullTableOfContentsSuccess(newTOCElem)
|
---|
| 557 | {
|
---|
| 558 | var tocStart = newTOCElem.indexOf(">") + 1;
|
---|
| 559 | var tocEnd = newTOCElem.lastIndexOf("<");
|
---|
| 560 |
|
---|
| 561 | var newTOC = newTOCElem.substring(tocStart, tocEnd);
|
---|
| 562 |
|
---|
| 563 | //Add the "Expand document"/"Collapse document" links
|
---|
[31520] | 564 | //newTOC = "<table style=\"width:100%; text-align:center;\"><tr><td><a href=\"javascript:expandOrCollapseAll(true);\">"+gs.text.doc.expand_doc+"</a></td><td><a href=\"javascript:expandOrCollapseAll(false);\">"+gs.text.doc.collapse_doc+"</a></td></tr></table>" + newTOC;
|
---|
| 565 | //newTOC = "<table style=\"width:100%; text-align:center;\"><tr><td><a href=\""+window.location.href+"?ed=1\">"+gs.text.doc.expand_doc+"</a></td><td><a href=\""+window.location.href+"?ed=0\">"+gs.text.doc.collapse_doc+"</a></td></tr></table>" + newTOC;
|
---|
[30478] | 566 |
|
---|
| 567 | //Collapse the TOC
|
---|
| 568 | newTOC = newTOC.replace(/display:block/g, "display:none");
|
---|
| 569 | newTOC = newTOC.replace(/display:none/, "display:block");
|
---|
| 570 | newTOC = newTOC.replace(/images\/collapse/g, "images/expand");
|
---|
| 571 |
|
---|
| 572 | var tocElem = $("#tableOfContents");
|
---|
| 573 | tocElem.html(newTOC);
|
---|
| 574 |
|
---|
| 575 | gs.variables.tocLoaded = true;
|
---|
| 576 | }
|
---|
| 577 |
|
---|
| 578 | function retrieveFullTableOfContentsSuccessClientSideXSLT(newTOCElem)
|
---|
| 579 | {
|
---|
| 580 | $('#client-side-xslt-ajax').remove();
|
---|
| 581 | retrieveFullTableOfContentsSuccess(newTOCElem)
|
---|
| 582 | }
|
---|
| 583 |
|
---|
[25366] | 584 | function retrieveFullTableOfContents()
|
---|
| 585 | {
|
---|
[31520] | 586 | var url = gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "?excerptid=tableOfContents&ec=1";
|
---|
[25641] | 587 | if(gs.cgiParams.d && gs.cgiParams.d.length > 0)
|
---|
| 588 | {
|
---|
| 589 | url += "&a=d&d=" + gs.cgiParams.d;
|
---|
| 590 | }
|
---|
| 591 | else if(gs.cgiParams.href && gs.cgiParams.href.length > 0)
|
---|
| 592 | {
|
---|
[25660] | 593 | url += "&a=d&d=&alb=1&rl=1&href=" + gs.cgiParams.href;
|
---|
[25641] | 594 | }
|
---|
[31523] | 595 | // later on we want this arg p.s so we can keep search term highlighting for expand document link
|
---|
| 596 | if (gs.cgiParams.p_s && gs.cgiParams.p_s.length > 0) {
|
---|
| 597 | url += "&p.s=" + gs.cgiParams.p_s;
|
---|
| 598 | }
|
---|
[32718] | 599 | if (gs.cgiParams.ck && gs.cgiParams.ck.length > 0) {
|
---|
| 600 | url += "&ck=" + gs.cgiParams.ck;
|
---|
| 601 | }
|
---|
[30478] | 602 |
|
---|
| 603 | if (gs.xsltParams.use_client_side_xslt == "true") { // note xsltParams are of type string, so test needs to be in quotes
|
---|
| 604 | url += "&callback=retrieveFullTableOfContentsSuccessClientSideXSLT"; // used in client-side-xslt.js, in combination with 'excerptid'
|
---|
| 605 | $('<iframe src="'+url+'" id="client-side-xslt-ajax" tabindex="-1" style="position: absolute; width: 0px; height: 0px; border: none;"></iframe>').appendTo('body');
|
---|
| 606 | }
|
---|
| 607 | else {
|
---|
[26397] | 608 | $.ajax(url)
|
---|
[30478] | 609 | .success(retrieveFullTableOfContentsSuccess)
|
---|
| 610 | .error(function() {
|
---|
[26397] | 611 | setTimeout(retrieveFullTableOfContents, 1000);
|
---|
[30478] | 612 | });
|
---|
| 613 | }
|
---|
[25366] | 614 | }
|
---|
| 615 |
|
---|
[30703] | 616 | function isSectionExpanded(sectionID)
|
---|
[24467] | 617 | {
|
---|
[26397] | 618 | var docElem = gs.jqGet("doc" + sectionID);
|
---|
| 619 | if(docElem.css("display") == "block")
|
---|
[24467] | 620 | {
|
---|
| 621 | return true;
|
---|
| 622 | }
|
---|
| 623 | return false;
|
---|
| 624 | }
|
---|
| 625 |
|
---|
[24655] | 626 | function minimizeSidebar()
|
---|
| 627 | {
|
---|
[26401] | 628 | var toc = $("#contentsArea");
|
---|
| 629 | var maxLink = $("#sidebarMaximizeButton");
|
---|
| 630 | var minLink = $("#sidebarMinimizeButton");
|
---|
[24655] | 631 |
|
---|
[26397] | 632 | if(toc.length)
|
---|
[24655] | 633 | {
|
---|
[26397] | 634 | toc.css("display", "none");
|
---|
[24655] | 635 | }
|
---|
| 636 |
|
---|
[26397] | 637 | maxLink.css("display", "block");
|
---|
| 638 | minLink.css("display", "none");
|
---|
[24655] | 639 | }
|
---|
| 640 |
|
---|
| 641 | function maximizeSidebar()
|
---|
| 642 | {
|
---|
[26401] | 643 | var coverImage = $("#coverImage");
|
---|
| 644 | var toc = $("#contentsArea");
|
---|
| 645 | var maxLink = $("#sidebarMaximizeButton");
|
---|
| 646 | var minLink = $("#sidebarMinimizeButton");
|
---|
[24655] | 647 |
|
---|
[26397] | 648 | if(coverImage.length)
|
---|
[24655] | 649 | {
|
---|
[26397] | 650 | coverImage.css("display", "block");
|
---|
[24655] | 651 | }
|
---|
| 652 |
|
---|
[26397] | 653 | if(toc.length)
|
---|
[24655] | 654 | {
|
---|
[26397] | 655 | toc.css("display", "block");
|
---|
[24655] | 656 | }
|
---|
| 657 |
|
---|
[26397] | 658 | maxLink.css("display", "none");
|
---|
| 659 | minLink.css("display", "block");
|
---|
[24655] | 660 | }
|
---|
| 661 |
|
---|
[28253] | 662 | function extractFilteredPagesToOwnDocument()
|
---|
| 663 | {
|
---|
| 664 | var oids = new Array();
|
---|
| 665 | var filtered = $(".pageSliderCol:visible a").each(function()
|
---|
| 666 | {
|
---|
| 667 | var hrefString = $(this).attr("href");
|
---|
| 668 | var oidStart = hrefString.indexOf(".") + 1;
|
---|
| 669 | var oidFinish = hrefString.indexOf("'", oidStart + 1);
|
---|
| 670 |
|
---|
| 671 | oids.push(hrefString.substring(oidStart, oidFinish));
|
---|
| 672 | });
|
---|
| 673 |
|
---|
| 674 | var sectionString = "[";
|
---|
| 675 | for(var i = 0; i < oids.length; i++)
|
---|
| 676 | {
|
---|
| 677 | sectionString += "\"" + oids[i] + "\"";
|
---|
| 678 | if(i < oids.length - 1)
|
---|
| 679 | {
|
---|
| 680 | sectionString += ",";
|
---|
| 681 | }
|
---|
| 682 | }
|
---|
| 683 | sectionString += "]";
|
---|
| 684 |
|
---|
[28279] | 685 | var url = "cgi-bin/document-extract.pl?a=extract-archives-doc&c=" + gs.cgiParams.c + "&d=" + gs.cgiParams.d + "&json-sections=" + sectionString + "&site=" + gs.xsltParams.site_name;// + "&json-metadata=[{"metaname":"dc.Title","metavalue":"All Black Rugy Success","metamode":"accumulate"]"
|
---|
[31531] | 686 | $("#extractDocButton").attr("disabled", "disabled").html("Extracting document...");
|
---|
[28253] | 687 | $.ajax(url)
|
---|
| 688 | .success(function(response)
|
---|
| 689 | {
|
---|
[28279] | 690 | $("#extractDocButton").html("Building collection...");
|
---|
[28255] | 691 | gs.functions.buildCollections([gs.cgiParams.c], function()
|
---|
| 692 | {
|
---|
[28279] | 693 | $("#extractDocButton").removeAttr("disabled").html("Extract these pages to document");
|
---|
[28255] | 694 | });
|
---|
[28279] | 695 | })
|
---|
| 696 | .error(function()
|
---|
| 697 | {
|
---|
| 698 | $("#extractDocButton").removeAttr("disabled").html("Extract these pages to document");
|
---|
[28253] | 699 | });
|
---|
| 700 | }
|
---|
| 701 |
|
---|
[25009] | 702 | /**********************
|
---|
| 703 | * PAGED-IMAGE SCRIPTS *
|
---|
| 704 | **********************/
|
---|
| 705 |
|
---|
| 706 | function changeView()
|
---|
| 707 | {
|
---|
[26401] | 708 | var viewList = $("#viewSelection");
|
---|
[26397] | 709 | var currentVal = viewList.val();
|
---|
[25009] | 710 |
|
---|
| 711 | var view;
|
---|
| 712 | if(currentVal == "Image view")
|
---|
| 713 | {
|
---|
| 714 | setImageVisible(true);
|
---|
| 715 | setTextVisible(false);
|
---|
| 716 | view = "image";
|
---|
| 717 | }
|
---|
| 718 | else if(currentVal == "Text view")
|
---|
| 719 | {
|
---|
| 720 | setImageVisible(false);
|
---|
| 721 | setTextVisible(true);
|
---|
| 722 | view = "text";
|
---|
| 723 | }
|
---|
| 724 | else
|
---|
| 725 | {
|
---|
| 726 | setImageVisible(true);
|
---|
| 727 | setTextVisible(true);
|
---|
| 728 | view = "";
|
---|
| 729 | }
|
---|
| 730 |
|
---|
[26397] | 731 | var url = gs.xsltParams.library_name + "?a=d&view=" + view + "&c=" + gs.cgiParams.c;
|
---|
| 732 | $.ajax(url);
|
---|
[25009] | 733 | }
|
---|
| 734 |
|
---|
| 735 | function setImageVisible(visible)
|
---|
| 736 | {
|
---|
[26401] | 737 | $("div").each(function()
|
---|
[25009] | 738 | {
|
---|
[26401] | 739 | if($(this).attr("id") && $(this).attr("id").search(/^image/) != -1)
|
---|
[25177] | 740 | {
|
---|
[26401] | 741 | $(this).css("display", (visible ? "block" : "none"));
|
---|
[25177] | 742 | }
|
---|
[26401] | 743 | });
|
---|
[25009] | 744 | }
|
---|
| 745 |
|
---|
| 746 | function setTextVisible(visible)
|
---|
| 747 | {
|
---|
[26401] | 748 | $("div").each(function()
|
---|
[25009] | 749 | {
|
---|
[26401] | 750 | if($(this).attr("id") && $(this).attr("id").search(/^text/) != -1)
|
---|
[25177] | 751 | {
|
---|
[26401] | 752 | $(this).css("display", (visible ? "block" : "none"));
|
---|
[25177] | 753 | }
|
---|
[26401] | 754 | });
|
---|
[25009] | 755 | }
|
---|
| 756 |
|
---|
[25283] | 757 | function retrieveTableOfContentsAndTitles()
|
---|
[25009] | 758 | {
|
---|
[25441] | 759 | var ilt = "";
|
---|
| 760 | ilt += '<xsl:template match="/">';
|
---|
[25660] | 761 | ilt += '<xsl:for-each select="/page/pageResponse/document/documentNode">';
|
---|
| 762 | ilt += '<xsl:call-template name="documentNodeTOC"/>';
|
---|
| 763 | ilt += '</xsl:for-each>';
|
---|
[25441] | 764 | ilt += '</xsl:template>';
|
---|
[26397] | 765 |
|
---|
[32775] | 766 | ilt = makeURLComponentSafe(ilt);
|
---|
[25441] | 767 |
|
---|
[32767] | 768 |
|
---|
| 769 | var url = gs.xsltParams.library_name + "?a=d&ec=1&c=" + gs.cgiParams.c + "&d=" + gs.cgiParams.d + "&ilt=" + ilt;
|
---|
| 770 |
|
---|
[26397] | 771 | $.ajax(url)
|
---|
| 772 | .success(function(response)
|
---|
[25009] | 773 | {
|
---|
[31531] | 774 | var tableOfContents = $("#tableOfContents");
|
---|
| 775 | tableOfContents.append(response);
|
---|
| 776 | replaceLinksWithSlider();
|
---|
| 777 |
|
---|
| 778 | var loading = $("#tocLoadingImage");
|
---|
| 779 | loading.remove();
|
---|
[26397] | 780 | })
|
---|
| 781 | .error(function()
|
---|
| 782 | {
|
---|
| 783 | setTimeout(function(){retrieveTableOfContentsAndTitles();}, 1000);
|
---|
| 784 | });
|
---|
[25009] | 785 | }
|
---|
| 786 |
|
---|
[30748] | 787 |
|
---|
[25009] | 788 | function replaceLinksWithSlider()
|
---|
| 789 | {
|
---|
[26401] | 790 | var tableOfContents = $("#tableOfContents");
|
---|
[25009] | 791 | var leafSections = new Array();
|
---|
[26401] | 792 | var liElems = tableOfContents.find("li").each(function()
|
---|
[25009] | 793 | {
|
---|
[26401] | 794 | var section = $(this);
|
---|
[25009] | 795 | var add = true;
|
---|
| 796 | for(var j = 0; j < leafSections.length; j++)
|
---|
| 797 | {
|
---|
| 798 | if(leafSections[j] == undefined){continue;}
|
---|
| 799 |
|
---|
[26397] | 800 | var leaf = $(leafSections[j]);
|
---|
| 801 | if(leaf.attr("id").search(section.attr("id")) != -1)
|
---|
[25009] | 802 | {
|
---|
| 803 | add = false;
|
---|
| 804 | }
|
---|
| 805 |
|
---|
[26397] | 806 | if(section.attr("id").search(leaf.attr("id")) != -1)
|
---|
[25009] | 807 | {
|
---|
| 808 | delete leafSections[j];
|
---|
| 809 | }
|
---|
| 810 | }
|
---|
[26397] | 811 |
|
---|
[25009] | 812 | if(add)
|
---|
| 813 | {
|
---|
| 814 | leafSections.push(section);
|
---|
| 815 | }
|
---|
[26401] | 816 | });
|
---|
[25009] | 817 |
|
---|
| 818 | for(var i = 0 ; i < leafSections.length; i++)
|
---|
| 819 | {
|
---|
| 820 | if(leafSections[i] == undefined){continue;}
|
---|
[26397] | 821 |
|
---|
| 822 | leafSections[i].css("display", "none");
|
---|
| 823 | var links = leafSections[i].find("a");
|
---|
| 824 |
|
---|
[25009] | 825 | var widget = new SliderWidget(links);
|
---|
[26397] | 826 | leafSections[i].before(widget.getElem());
|
---|
[25009] | 827 | }
|
---|
[26397] | 828 |
|
---|
[25441] | 829 | //Disable all TOC toggles
|
---|
[26401] | 830 | var imgs = $("img").each(function()
|
---|
[25283] | 831 | {
|
---|
[26401] | 832 | var currentImage = $(this);
|
---|
[26397] | 833 | if(currentImage.attr("id") && currentImage.attr("id").search(/^ttoggle/) != -1)
|
---|
[25283] | 834 | {
|
---|
[26397] | 835 | currentImage.attr("onclick", "");
|
---|
[28253] | 836 | currentImage.click(function()
|
---|
| 837 | {
|
---|
| 838 | var sliderDiv = currentImage.parents("table").first().next();
|
---|
| 839 | if(sliderDiv.is(":visible"))
|
---|
| 840 | {
|
---|
| 841 | sliderDiv.hide();
|
---|
| 842 | }
|
---|
| 843 | else
|
---|
| 844 | {
|
---|
| 845 | sliderDiv.show();
|
---|
| 846 | }
|
---|
| 847 | });
|
---|
[25283] | 848 | }
|
---|
[26397] | 849 | else if(currentImage.attr("id") && currentImage.attr("id").search(/^dtoggle/) != -1)
|
---|
[25441] | 850 | {
|
---|
[26397] | 851 | currentImage.attr("onclick", currentImage.attr("onclick").replace(/\)/, ", null, true)"));
|
---|
[25441] | 852 | }
|
---|
[26401] | 853 | });
|
---|
[25283] | 854 | }
|
---|
| 855 |
|
---|
[30169] | 856 |
|
---|
[25009] | 857 | function SliderWidget(_links)
|
---|
| 858 | {
|
---|
| 859 | //****************
|
---|
| 860 | //MEMBER VARIABLES
|
---|
| 861 | //****************
|
---|
| 862 |
|
---|
| 863 | //The container for the widget
|
---|
[26397] | 864 | var _mainDiv = $("<div>");
|
---|
| 865 | _mainDiv.attr("class", "ui-widget-content pageSlider");
|
---|
[25009] | 866 |
|
---|
| 867 | //The table of images
|
---|
[26397] | 868 | var _linkTable = $("<table>");
|
---|
| 869 | _mainDiv.append(_linkTable);
|
---|
[25009] | 870 |
|
---|
| 871 | //The image row of the table
|
---|
[26397] | 872 | var _linkRow = $("<tr>");
|
---|
| 873 | _linkTable.append(_linkRow);
|
---|
[25009] | 874 |
|
---|
[25283] | 875 | //The list of titles we can search through
|
---|
| 876 | var _titles = new Array();
|
---|
[26397] | 877 |
|
---|
| 878 | //Keep track of the slider position
|
---|
| 879 | var _prevScroll = 0;
|
---|
[25009] | 880 |
|
---|
| 881 | //****************
|
---|
| 882 | //PUBLIC FUNCTIONS
|
---|
| 883 | //****************
|
---|
| 884 |
|
---|
| 885 | //Function that returns the widget element
|
---|
| 886 | this.getElem = function()
|
---|
| 887 | {
|
---|
| 888 | return _mainDiv;
|
---|
| 889 | }
|
---|
| 890 |
|
---|
| 891 | //*****************
|
---|
| 892 | //PRIVATE FUNCTIONS
|
---|
| 893 | //*****************
|
---|
[30169] | 894 |
|
---|
| 895 | // _filter_on_types can be "sectionnum", "sectiontitle"
|
---|
| 896 | var setUpFilterButtons = function() {
|
---|
| 897 |
|
---|
| 898 | var button_div = $("#filterOnButtons");
|
---|
| 899 | button_div.onclick = doFiltering;
|
---|
| 900 | button_div.html("radio");
|
---|
| 901 | if (_filter_on_types.length == 0) {
|
---|
| 902 | _filter_on_types = ["sectionnum", "sectiontitle"];
|
---|
| 903 | }
|
---|
| 904 | else if (_filter_on_types.length == 1) {
|
---|
| 905 | if (_filter_on_types[0] == "sectionnum") {
|
---|
[30772] | 906 | button_div.html("(<input type='radio' name='filterOn' value='num' checked>"+gs.text.doc.filter.pagenum+"</input>)");
|
---|
[30169] | 907 | } else {
|
---|
[30772] | 908 | button_div.html("(<input type='radio' name='filterOn' value='title' checked>"+gs.text.doc.filter.title+"</input>)");
|
---|
[30169] | 909 | }
|
---|
| 910 | } else {
|
---|
| 911 | // should be both options
|
---|
[30772] | 912 | button_div.html("<input type='radio' name='filterOn' value='num' checked>"+gs.text.doc.filter.pagenum+"</input><input type='radio' name='filterOn' value='title'>"+gs.text.doc.filter.title+"</input>");
|
---|
[30169] | 913 | }
|
---|
| 914 | }
|
---|
| 915 |
|
---|
| 916 | var doFiltering = function () {
|
---|
| 917 | if (typeof _titles == "undefined") {
|
---|
| 918 | return;
|
---|
| 919 | }
|
---|
| 920 |
|
---|
| 921 | var filter_string = $("#filterText").val();
|
---|
| 922 | var filter_type = $('input[name="filterOn"]:checked').val();
|
---|
| 923 |
|
---|
| 924 | var index = 2; // section num
|
---|
| 925 | var numeric_match = true;
|
---|
| 926 | if (filter_type == "title") {
|
---|
| 927 | index = 3;
|
---|
| 928 | if (_filter_title_numeric != true) {
|
---|
| 929 | numeric_match = false;
|
---|
| 930 | }
|
---|
| 931 |
|
---|
| 932 | }
|
---|
| 933 | var values = filter_string.split(",");
|
---|
| 934 |
|
---|
| 935 | var matchingTitles = new Array();
|
---|
| 936 |
|
---|
| 937 | for (var l = 0; l < values.length; l++)
|
---|
| 938 | {
|
---|
| 939 | var currentValue = values[l].replace(/^ +/g, "").replace(/ +$/g, "");
|
---|
| 940 | if (numeric_match) {
|
---|
[31740] | 941 | var isRange = (currentValue.search(/^\d+-\d+$/) != -1);
|
---|
[30169] | 942 | if (isRange) {
|
---|
[31740] | 943 | var firstNumber = Number(currentValue.replace(/(\d+)-\d+/, "$1"));
|
---|
| 944 | var secondNumber = Number(currentValue.replace(/\d+-(\d+)/, "$1"));
|
---|
[30169] | 945 | if(firstNumber <= secondNumber)
|
---|
| 946 | {
|
---|
| 947 | for(var i = firstNumber; i <= secondNumber; i++)
|
---|
| 948 | {
|
---|
| 949 | var numString = i + "";
|
---|
| 950 | for(var j = 0; j < _titles.length; j++) {
|
---|
| 951 | var currentTitle = _titles[j];
|
---|
| 952 | if(currentTitle[index] == numString) {
|
---|
[31740] | 953 | matchingTitles.push(currentTitle);
|
---|
| 954 | break; // assume no titles are the same
|
---|
[30169] | 955 | }
|
---|
| 956 | }
|
---|
| 957 | }
|
---|
| 958 | }
|
---|
| 959 | } // if isRange
|
---|
| 960 | else {
|
---|
| 961 | for(var j = 0; j < _titles.length; j++) {
|
---|
| 962 | if (_titles[j][index]==currentValue) {
|
---|
| 963 | matchingTitles.push(_titles[j]);
|
---|
[31740] | 964 | break; // assume no titles are the same
|
---|
[30169] | 965 | }
|
---|
| 966 | }
|
---|
| 967 |
|
---|
| 968 | }
|
---|
[25009] | 969 |
|
---|
[30169] | 970 | } else { // not numeric match.
|
---|
| 971 | // need to do a search
|
---|
| 972 | for(var i = 0; i < _titles.length; i++)
|
---|
| 973 | {
|
---|
| 974 | var currentTitle = _titles[i];
|
---|
| 975 | if(currentTitle[index].toLowerCase().search(currentValue.toLowerCase().replace(/\./g, "\\.")) != -1)
|
---|
| 976 | {
|
---|
| 977 | matchingTitles.push(currentTitle);
|
---|
| 978 | }
|
---|
| 979 | }
|
---|
| 980 | }
|
---|
| 981 | } // for each value from filter string
|
---|
| 982 |
|
---|
| 983 | // set all to hide...
|
---|
| 984 | for(var i = 0; i < _titles.length; i++)
|
---|
| 985 | {
|
---|
| 986 | $(_titles[i][1].cell).css("display", "none");
|
---|
| 987 | }
|
---|
| 988 |
|
---|
| 989 | // .. then display the matching ones
|
---|
| 990 | for(var i = 0; i < matchingTitles.length; i++)
|
---|
| 991 | {
|
---|
| 992 | $(matchingTitles[i][1].cell).css("display", "table-cell");
|
---|
| 993 | }
|
---|
[31740] | 994 | } // end doFiltering() function
|
---|
[30169] | 995 |
|
---|
| 996 | var setUpFilterBox = function()
|
---|
[25283] | 997 | {
|
---|
[30169] | 998 | var filter = $("#filterText");
|
---|
| 999 |
|
---|
| 1000 | filter.keyup(function()
|
---|
| 1001 | {
|
---|
| 1002 | doFiltering();
|
---|
| 1003 | });
|
---|
[25283] | 1004 | }
|
---|
| 1005 |
|
---|
[26212] | 1006 | var getImage = function(page, attemptNumber)
|
---|
[32072] | 1007 | {
|
---|
[25009] | 1008 | var href = page.getAttribute("href");
|
---|
[25441] | 1009 | var startHREF = href.indexOf("'") + 1;
|
---|
| 1010 | var endHREF = href.indexOf("'", startHREF);
|
---|
| 1011 | var nodeID = href.substring(startHREF, endHREF);
|
---|
| 1012 | href = gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/document/" + nodeID;
|
---|
| 1013 |
|
---|
[25177] | 1014 | var template = '';
|
---|
| 1015 | template += '<xsl:template match="/">';
|
---|
| 1016 | template += '<html>';
|
---|
| 1017 | template += '<img>';
|
---|
| 1018 | template += '<xsl:attribute name="src">';
|
---|
| 1019 | template += "<xsl:value-of disable-output-escaping=\"yes\" select=\"/page/pageResponse/collection/metadataList/metadata[@name = 'httpPath']\"/>";
|
---|
| 1020 | template += '<xsl:text>/index/assoc/</xsl:text>';
|
---|
| 1021 | template += "<xsl:value-of disable-output-escaping=\"yes\" select=\"/page/pageResponse/document/metadataList/metadata[@name = 'assocfilepath']\"/>";
|
---|
| 1022 | template += '<xsl:text>/</xsl:text>';
|
---|
[25441] | 1023 | template += "<xsl:value-of disable-output-escaping=\"yes\" select=\"/page/pageResponse/document//documentNode[@nodeID = '" + nodeID + "']/metadataList/metadata[@name = 'Thumb']\"/>";
|
---|
[25177] | 1024 | template += '</xsl:attribute>';
|
---|
| 1025 | template += '</img>';
|
---|
[25283] | 1026 | template += '<p>';
|
---|
| 1027 | template += "<xsl:value-of disable-output-escaping=\"yes\" select=\"/page/pageResponse/document/documentNode/metadataList/metadata[@name = 'Title']\"/>";
|
---|
| 1028 | template += '</p>';
|
---|
[25177] | 1029 | template += '</html>';
|
---|
| 1030 | template += '</xsl:template>';
|
---|
[32775] | 1031 | template = makeURLComponentSafe(template);
|
---|
[32767] | 1032 | var url = href + "?noText=1&ilt=" + template;
|
---|
[25441] | 1033 |
|
---|
[26397] | 1034 | $.ajax(url)
|
---|
| 1035 | .success(function(text)
|
---|
[32072] | 1036 | {
|
---|
[26397] | 1037 | var hrefStart = text.indexOf("src=\"") + 5;
|
---|
| 1038 | if(hrefStart == -1)
|
---|
[25009] | 1039 | {
|
---|
[26397] | 1040 | page.isLoading = false;
|
---|
| 1041 | page.noImage = true;
|
---|
| 1042 | $(page.image).attr("src", gs.imageURLs.blank);
|
---|
| 1043 | return;
|
---|
| 1044 | }
|
---|
| 1045 | var hrefEnd = text.indexOf("\"", hrefStart);
|
---|
| 1046 | var href = text.substring(hrefStart, hrefEnd);
|
---|
[25283] | 1047 |
|
---|
[26397] | 1048 | var image = $("<img>");
|
---|
| 1049 | image.load(function()
|
---|
[25009] | 1050 | {
|
---|
[26397] | 1051 | $(page.link).html("");
|
---|
| 1052 | $(page.link).append(image);
|
---|
| 1053 | page.isLoading = false;
|
---|
| 1054 | page.imageLoaded = true;
|
---|
| 1055 | });
|
---|
| 1056 | image.error(function()
|
---|
| 1057 | {
|
---|
[26212] | 1058 | if(!attemptNumber || attemptNumber < 3)
|
---|
| 1059 | {
|
---|
| 1060 | setTimeout(function(){getImage(page, ((!attemptNumber) ? 1 : attemptNumber + 1));}, 500);
|
---|
| 1061 | }
|
---|
| 1062 | else
|
---|
| 1063 | {
|
---|
| 1064 | page.isLoading = false;
|
---|
| 1065 | page.noImage = true;
|
---|
[26397] | 1066 | image.attr("src", gs.imageURLs.blank);
|
---|
[26212] | 1067 | }
|
---|
[26397] | 1068 | });
|
---|
| 1069 | image.attr("src", href);
|
---|
| 1070 |
|
---|
| 1071 | var titleStart = text.indexOf("<p>") + 3;
|
---|
| 1072 | var titleEnd = text.indexOf("</p>");
|
---|
| 1073 | var title = text.substring(titleStart, titleEnd);
|
---|
| 1074 | })
|
---|
| 1075 | .error(function()
|
---|
| 1076 | {
|
---|
| 1077 | page.failed = true;
|
---|
| 1078 | if(!attemptNumber || attemptNumber < 3)
|
---|
| 1079 | {
|
---|
| 1080 | setTimeout(function(){getImage(page, ((!attemptNumber) ? 1 : attemptNumber + 1));}, 500);
|
---|
[25009] | 1081 | }
|
---|
[26397] | 1082 | else
|
---|
| 1083 | {
|
---|
[26401] | 1084 | var image = $("<img>", {"src": gs.imageURLs.blank});
|
---|
| 1085 | $(page.link).html("");
|
---|
| 1086 | $(page.link).append(image);
|
---|
[26397] | 1087 | page.isLoading = false;
|
---|
| 1088 | page.noImage = true;
|
---|
| 1089 | }
|
---|
| 1090 | });
|
---|
[25009] | 1091 | }
|
---|
| 1092 |
|
---|
| 1093 | var startCheckFunction = function()
|
---|
| 1094 | {
|
---|
[26397] | 1095 | var checkFunction = function(forced)
|
---|
[25009] | 1096 | {
|
---|
[26397] | 1097 | //Don't bother checking if we haven't scrolled very far
|
---|
| 1098 | if(Math.abs(_mainDiv.scrollLeft() - _prevScroll) > 100 || forced)
|
---|
[25009] | 1099 | {
|
---|
[26397] | 1100 | _prevScroll = _mainDiv.scrollLeft();
|
---|
| 1101 | _checking = true;
|
---|
| 1102 | var widgetLeft = _mainDiv.offset().left;
|
---|
| 1103 | var widgetRight = widgetLeft + _mainDiv.width();
|
---|
| 1104 |
|
---|
| 1105 | var visiblePages = new Array();
|
---|
| 1106 | for(var i = 0; i < _links.length; i++)
|
---|
[25009] | 1107 | {
|
---|
[26397] | 1108 | var current = _links[i].cell;
|
---|
| 1109 | var currentLeft = current.offset().left;
|
---|
| 1110 | var currentRight = currentLeft + current.width();
|
---|
| 1111 |
|
---|
| 1112 | if(currentRight > widgetLeft && currentLeft < widgetRight)
|
---|
| 1113 | {
|
---|
| 1114 | visiblePages.push(_links[i]);
|
---|
| 1115 | }
|
---|
[25009] | 1116 | }
|
---|
[26397] | 1117 |
|
---|
| 1118 | for(var i = 0; i < visiblePages.length; i++)
|
---|
[25009] | 1119 | {
|
---|
[26397] | 1120 | var page = visiblePages[i];
|
---|
| 1121 | if(!page || page.imageLoaded || page.noImage || page.isLoading)
|
---|
| 1122 | {
|
---|
| 1123 | continue;
|
---|
| 1124 | }
|
---|
| 1125 |
|
---|
| 1126 | page.isLoading = true;
|
---|
| 1127 | getImage(page);
|
---|
[25009] | 1128 | }
|
---|
[26397] | 1129 | _checking = false;
|
---|
[25009] | 1130 | }
|
---|
| 1131 | }
|
---|
[26397] | 1132 |
|
---|
| 1133 | setTimeout(checkFunction, 250);
|
---|
| 1134 | setInterval(function(){checkFunction(true)}, 2000);
|
---|
| 1135 | _mainDiv.scroll(checkFunction);
|
---|
[25009] | 1136 | }
|
---|
| 1137 |
|
---|
| 1138 | //***********
|
---|
| 1139 | //CONSTRUCTOR
|
---|
| 1140 | //***********
|
---|
| 1141 |
|
---|
| 1142 | for(var i = 0; i < _links.length; i++)
|
---|
| 1143 | {
|
---|
[26397] | 1144 | var col = $("<td>");
|
---|
| 1145 | _linkRow.append(col);
|
---|
| 1146 | col.addClass("pageSliderCol");
|
---|
[25009] | 1147 | _links[i].cell = col;
|
---|
[26401] | 1148 |
|
---|
[26397] | 1149 | var link = $("<a>");
|
---|
| 1150 | col.append(link);
|
---|
[25009] | 1151 | _links[i].link = link;
|
---|
[26397] | 1152 | var href = $(_links[i]).attr("href");
|
---|
| 1153 | link.attr("href", href.replace(/\)/, ", 0, true)"));
|
---|
[26401] | 1154 |
|
---|
[25283] | 1155 | if(!_linkCellMap[href])
|
---|
| 1156 | {
|
---|
| 1157 | _linkCellMap[href] = new Array();
|
---|
| 1158 | }
|
---|
| 1159 | _linkCellMap[href].push(_links[i]);
|
---|
[26401] | 1160 |
|
---|
[26397] | 1161 | var loadingText = $("<p>Loading image</p>");
|
---|
| 1162 | link.append(loadingText);
|
---|
[26401] | 1163 |
|
---|
[26397] | 1164 | var image = $("<img>");
|
---|
| 1165 | link.append(image);
|
---|
| 1166 | image.attr("src", gs.imageURLs.loading);
|
---|
[25009] | 1167 | _links[i].image = image;
|
---|
[26401] | 1168 |
|
---|
[26397] | 1169 | var title = $(_links[i]).html();
|
---|
[30169] | 1170 | var t_section = "";
|
---|
| 1171 | var t_title = "";
|
---|
| 1172 | if (title.search(/tocSectionNumber/) != -1)
|
---|
| 1173 | {
|
---|
[30700] | 1174 | var matching_regex = /<span class=\"tocSectionNumber\">([0-9]+)<\/span>[\s\S]*<span class=\"tocSectionTitle\">(.+)<\/span>$/mg;
|
---|
[30169] | 1175 | var matches_array = matching_regex.exec(title);
|
---|
[30700] | 1176 | if (matches_array != null && matches_array.length == 3) {
|
---|
[30169] | 1177 | t_section = matches_array[1];
|
---|
| 1178 | t_title = matches_array[2];
|
---|
| 1179 | }
|
---|
| 1180 | }
|
---|
| 1181 |
|
---|
| 1182 | _titles.push([title, _links[i], t_section, t_title]);
|
---|
[26401] | 1183 |
|
---|
[26397] | 1184 | col.append($("<br>"));
|
---|
| 1185 | col.append(title);
|
---|
[25009] | 1186 | }
|
---|
[26401] | 1187 |
|
---|
[25283] | 1188 | setUpFilterBox();
|
---|
[30169] | 1189 | setUpFilterButtons();
|
---|
[25009] | 1190 | startCheckFunction();
|
---|
[30169] | 1191 | }
|
---|
[25009] | 1192 |
|
---|
[24467] | 1193 | /***********************
|
---|
| 1194 | * HIGHLIGHTING SCRIPTS *
|
---|
| 1195 | ***********************/
|
---|
[26307] | 1196 | function swapHighlight(imageClicked)
|
---|
[24467] | 1197 | {
|
---|
[26397] | 1198 | var hlCheckbox = $("#highlightOption");
|
---|
[26307] | 1199 | if(imageClicked)
|
---|
| 1200 | {
|
---|
[29320] | 1201 | // toggle the state of the checkbox
|
---|
| 1202 | $(hlCheckbox).prop("checked", !$(hlCheckbox).prop("checked"));
|
---|
[26307] | 1203 | }
|
---|
[25720] | 1204 | var from;
|
---|
| 1205 | var to;
|
---|
[29320] | 1206 | if(hlCheckbox.prop("checked"))
|
---|
[24467] | 1207 | {
|
---|
[25720] | 1208 | from = "noTermHighlight";
|
---|
| 1209 | to = "termHighlight";
|
---|
[24467] | 1210 | }
|
---|
[25720] | 1211 | else
|
---|
| 1212 | {
|
---|
| 1213 | from = "termHighlight";
|
---|
| 1214 | to = "noTermHighlight";
|
---|
| 1215 | }
|
---|
[26397] | 1216 |
|
---|
| 1217 | var spans = $("span").each(function()
|
---|
[24467] | 1218 | {
|
---|
[26397] | 1219 | if($(this).hasClass(from))
|
---|
[24467] | 1220 | {
|
---|
[26397] | 1221 | $(this).removeClass(from);
|
---|
| 1222 | $(this).addClass(to);
|
---|
[24467] | 1223 | }
|
---|
[26397] | 1224 | });
|
---|
[24467] | 1225 | }
|
---|
| 1226 |
|
---|
| 1227 | /**************************
|
---|
| 1228 | * REALISTIC BOOKS SCRIPTS *
|
---|
| 1229 | **************************/
|
---|
| 1230 |
|
---|
| 1231 | function bookInit()
|
---|
| 1232 | {
|
---|
| 1233 | loadBook();
|
---|
| 1234 | hideText();
|
---|
| 1235 | showBook();
|
---|
| 1236 | swapLinkJavascript(false);
|
---|
| 1237 | }
|
---|
| 1238 |
|
---|
| 1239 | function hideText()
|
---|
| 1240 | {
|
---|
[26397] | 1241 | $("#gs-document-text").css("visibility", "hidden");
|
---|
[24467] | 1242 | }
|
---|
| 1243 |
|
---|
| 1244 | function showText()
|
---|
| 1245 | {
|
---|
[26397] | 1246 | $("#gs-document-text").css("visibility", "visible");
|
---|
[24467] | 1247 | }
|
---|
| 1248 |
|
---|
| 1249 | function hideBook()
|
---|
| 1250 | {
|
---|
[26397] | 1251 | $("#bookDiv, #bookObject, #bookEmbed").css({"visibility": "hidden", "height": "0px"});
|
---|
[24467] | 1252 | }
|
---|
| 1253 |
|
---|
| 1254 | function showBook()
|
---|
| 1255 | {
|
---|
[26397] | 1256 | $("#bookDiv, #bookObject, #bookEmbed").css({"visibility": "visible", "height": "600px"});
|
---|
[24467] | 1257 | }
|
---|
| 1258 |
|
---|
| 1259 | function swapLinkJavascript(rbOn)
|
---|
| 1260 | {
|
---|
[26397] | 1261 | var option = $("#rbOption");
|
---|
| 1262 | var optionImage = $("#rbOptionImage");
|
---|
[26307] | 1263 |
|
---|
[24467] | 1264 | if(rbOn)
|
---|
| 1265 | {
|
---|
[26397] | 1266 | option.attr("onclick", "hideText(); showBook(); swapLinkJavascript(false);");
|
---|
| 1267 | optionImage.attr("onclick", "hideText(); showBook(); swapLinkJavascript(false);");
|
---|
[29320] | 1268 | $(option).prop("checked", false);
|
---|
[24467] | 1269 | }
|
---|
| 1270 | else
|
---|
| 1271 | {
|
---|
[26397] | 1272 | option.attr("onclick", "hideBook(); showText(); swapLinkJavascript(true);");
|
---|
| 1273 | optionImage.attr("onclick", "hideBook(); showText(); swapLinkJavascript(true);");
|
---|
[29320] | 1274 | $(option).prop("checked", true);
|
---|
[24467] | 1275 | }
|
---|
| 1276 | }
|
---|
| 1277 |
|
---|
| 1278 | function loadBook()
|
---|
| 1279 | {
|
---|
| 1280 | var doc_url = document.URL;
|
---|
| 1281 | doc_url = doc_url.replace(/(&|\?)book=[a-z]+/gi,'');
|
---|
| 1282 | doc_url += '&book=flashxml';
|
---|
| 1283 |
|
---|
| 1284 | var img_cover = gs.collectionMetadata.httpPath + '/index/assoc/' + gs.documentMetadata.assocfilepath + '/cover.jpg';
|
---|
| 1285 |
|
---|
| 1286 | var flash_plug_html = ""
|
---|
| 1287 | flash_plug_html += '<OBJECT align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" \n';
|
---|
| 1288 | flash_plug_html += ' height="600px" id="bookObject" swLiveConnect="true" \n';
|
---|
| 1289 | flash_plug_html += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" \n';
|
---|
| 1290 | flash_plug_html += ' width="70%">\n';
|
---|
| 1291 | flash_plug_html += ' <PARAM name="allowScriptAccess" value="always" />\n';
|
---|
| 1292 | flash_plug_html += ' <PARAM name="movie" value="Book.swf';
|
---|
| 1293 | flash_plug_html += '?src_image=' + escape(img_cover);
|
---|
[25142] | 1294 | flash_plug_html += '&doc_url=' + escape(doc_url);
|
---|
[24467] | 1295 | flash_plug_html += '" />\n';
|
---|
| 1296 | flash_plug_html += ' <PARAM name="quality" value="high" />\n';
|
---|
| 1297 | flash_plug_html += ' <PARAM name="bgcolor" value="#FFFFFF" />\n';
|
---|
| 1298 | flash_plug_html += ' <EMBED align="middle" \n';
|
---|
| 1299 | flash_plug_html += ' allowScriptAccess="always" swLiveConnect="true" \n';
|
---|
| 1300 | flash_plug_html += ' bgcolor="#FFFFFF" height="600px" name="Book" \n';
|
---|
| 1301 | flash_plug_html += ' pluginspage="http://www.macromedia.com/go/getflashplayer" \n';
|
---|
| 1302 | flash_plug_html += ' quality="high" id="bookEmbed"\n';
|
---|
| 1303 | flash_plug_html += ' src="Book.swf';
|
---|
| 1304 | flash_plug_html += '?src_image=' + escape(img_cover);
|
---|
| 1305 | flash_plug_html += '&doc_url=' + escape(doc_url);
|
---|
| 1306 | flash_plug_html += '"\n';
|
---|
| 1307 | flash_plug_html += ' type="application/x-shockwave-flash" width="70%" />\n';
|
---|
| 1308 | flash_plug_html += '</OBJECT>\n';
|
---|
[26397] | 1309 | $("#bookdiv").html(flash_plug_html);
|
---|
[25142] | 1310 | }
|
---|
| 1311 |
|
---|
[30733] | 1312 |
|
---|
| 1313 |
|
---|
[26397] | 1314 | /***************
|
---|
| 1315 | * MENU SCRIPTS *
|
---|
| 1316 | ***************/
|
---|
[29173] | 1317 | function moveScroller() {
|
---|
| 1318 | var move = function() {
|
---|
| 1319 | var editbar = $("#editBar");
|
---|
| 1320 | var st = $(window).scrollTop();
|
---|
| 1321 | var fa = $("#float-anchor").offset().top;
|
---|
| 1322 | if(st > fa) {
|
---|
| 1323 |
|
---|
| 1324 | editbar.css({
|
---|
| 1325 | position: "fixed",
|
---|
| 1326 | top: "0px",
|
---|
| 1327 | width: editbar.data("width"),
|
---|
| 1328 | //width: "30%"
|
---|
| 1329 | });
|
---|
| 1330 | } else {
|
---|
| 1331 | editbar.data("width", editbar.css("width"));
|
---|
| 1332 | editbar.css({
|
---|
| 1333 | position: "relative",
|
---|
| 1334 | top: "",
|
---|
| 1335 | width: ""
|
---|
| 1336 | });
|
---|
| 1337 | }
|
---|
| 1338 | };
|
---|
| 1339 | $(window).scroll(move);
|
---|
| 1340 | move();
|
---|
| 1341 | }
|
---|
[26397] | 1342 |
|
---|
[29173] | 1343 |
|
---|
[26226] | 1344 | function floatMenu(enabled)
|
---|
| 1345 | {
|
---|
| 1346 | var menu = $(".tableOfContentsContainer");
|
---|
| 1347 | if(enabled)
|
---|
| 1348 | {
|
---|
| 1349 | menu.data("position", menu.css("position"));
|
---|
| 1350 | menu.data("width", menu.css("width"));
|
---|
| 1351 | menu.data("right", menu.css("right"));
|
---|
| 1352 | menu.data("top", menu.css("top"));
|
---|
| 1353 | menu.data("max-height", menu.css("max-height"));
|
---|
| 1354 | menu.data("overflow", menu.css("overflow"));
|
---|
| 1355 | menu.data("z-index", menu.css("z-index"));
|
---|
| 1356 |
|
---|
| 1357 | menu.css("position", "fixed");
|
---|
| 1358 | menu.css("width", "300px");
|
---|
| 1359 | menu.css("right", "0px");
|
---|
| 1360 | menu.css("top", "100px");
|
---|
| 1361 | menu.css("max-height", "600px");
|
---|
| 1362 | menu.css("overflow", "auto");
|
---|
| 1363 | menu.css("z-index", "200");
|
---|
| 1364 |
|
---|
| 1365 | $("#unfloatTOCButton").show();
|
---|
| 1366 | }
|
---|
| 1367 | else
|
---|
| 1368 | {
|
---|
| 1369 | menu.css("position", menu.data("position"));
|
---|
| 1370 | menu.css("width", menu.data("width"));
|
---|
| 1371 | menu.css("right", menu.data("right"));
|
---|
| 1372 | menu.css("top", menu.data("top"));
|
---|
| 1373 | menu.css("max-height", menu.data("max-height"));
|
---|
| 1374 | menu.css("overflow", menu.data("overflow"));
|
---|
| 1375 | menu.css("z-index", menu.data("z-index"));
|
---|
| 1376 |
|
---|
| 1377 | $("#unfloatTOCButton").hide();
|
---|
[29320] | 1378 | $("#floatTOCToggle").prop("checked", false);
|
---|
[26226] | 1379 | }
|
---|
[26308] | 1380 |
|
---|
[26397] | 1381 | var url = gs.xsltParams.library_name + "?a=d&ftoc=" + (enabled ? "1" : "0") + "&c=" + gs.cgiParams.c;
|
---|
| 1382 |
|
---|
| 1383 | $.ajax(url);
|
---|
[26226] | 1384 | }
|
---|
| 1385 |
|
---|
[26397] | 1386 | /********************
|
---|
| 1387 | * SLIDESHOW SCRIPTS *
|
---|
| 1388 | ********************/
|
---|
| 1389 |
|
---|
[26203] | 1390 | function showSlideShow()
|
---|
| 1391 | {
|
---|
[26305] | 1392 | if(!($("#gs-slideshow").length))
|
---|
[26203] | 1393 | {
|
---|
[26390] | 1394 | var slideshowDiv = $("<div>", {id:"gs-slideshow", style:"height:100%;"});
|
---|
[26305] | 1395 | var loadingImage = $("<img>", {src:gs.imageURLs.loading});
|
---|
| 1396 | slideshowDiv.append(loadingImage);
|
---|
| 1397 |
|
---|
| 1398 | $.blockUI({message: $(slideshowDiv), css:{top: "5%", left: "5%", width: "90%", height: "90%", overflow: "auto", cursor: "auto"}});
|
---|
| 1399 |
|
---|
| 1400 | retrieveImagesForSlideShow(function(imageIDArray)
|
---|
[26203] | 1401 | {
|
---|
[26305] | 1402 | loadingImage.hide();
|
---|
| 1403 | if(imageIDArray && imageIDArray.length > 0)
|
---|
[26203] | 1404 | {
|
---|
[26305] | 1405 | var imageURLs = new Array();
|
---|
| 1406 | for(var i = 0; i < imageIDArray.length; i++)
|
---|
[26203] | 1407 | {
|
---|
[26305] | 1408 | if(imageIDArray[i].source && imageIDArray[i].source.search(/.*\.(gif|jpg|jpeg|png)$/) != -1)
|
---|
[26203] | 1409 | {
|
---|
[26305] | 1410 | imageURLs.push(gs.collectionMetadata.httpPath + "/index/assoc/" + gs.documentMetadata.assocfilepath + "/" + imageIDArray[i].source);
|
---|
[26203] | 1411 | }
|
---|
| 1412 | }
|
---|
[26305] | 1413 | new SlideShowWidget(slideshowDiv, imageURLs, imageIDArray);
|
---|
| 1414 | }
|
---|
| 1415 | });
|
---|
[26203] | 1416 | }
|
---|
| 1417 | else
|
---|
| 1418 | {
|
---|
[26305] | 1419 | $("#gs-slideshow").show();
|
---|
[26203] | 1420 | }
|
---|
| 1421 | }
|
---|
| 1422 |
|
---|
| 1423 | function retrieveImagesForSlideShow(callback)
|
---|
| 1424 | {
|
---|
| 1425 | var template = "";
|
---|
| 1426 | template += '<xsl:template match="/">';
|
---|
| 1427 | template += '<images>[';
|
---|
| 1428 | template += '<xsl:for-each select="//documentNode">';
|
---|
| 1429 | template += '<xsl:text disable-output-escaping="yes">{"source":"</xsl:text><gsf:metadata name="Source"/><xsl:text disable-output-escaping="yes">",</xsl:text>';
|
---|
| 1430 | template += '<xsl:text disable-output-escaping="yes">"id":"</xsl:text><xsl:value-of select="@nodeID"/><xsl:text disable-output-escaping="yes">"}</xsl:text>';
|
---|
| 1431 | template += '<xsl:if test="position() != count(//documentNode)">,</xsl:if>';
|
---|
| 1432 | template += '</xsl:for-each>';
|
---|
| 1433 | template += ']</images>';
|
---|
| 1434 | template += '</xsl:template>';
|
---|
[32775] | 1435 | template = makeURLComponentSafe(template);
|
---|
[32767] | 1436 | var url = gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/document/" + gs.cgiParams.d + "?ed=1&ilt=" + template;
|
---|
[26203] | 1437 |
|
---|
| 1438 | $.ajax(
|
---|
| 1439 | {
|
---|
| 1440 | url:url,
|
---|
| 1441 | success: function(data)
|
---|
| 1442 | {
|
---|
| 1443 | var startIndex = data.indexOf(">", data.indexOf(">") + 1) + 1;
|
---|
| 1444 | var endIndex = data.lastIndexOf("<");
|
---|
| 1445 | var arrayString = data.substring(startIndex, endIndex);
|
---|
| 1446 | var imageIDArray = eval(arrayString);
|
---|
| 1447 |
|
---|
| 1448 | callback(imageIDArray);
|
---|
| 1449 | }
|
---|
| 1450 | });
|
---|
| 1451 | }
|
---|
| 1452 |
|
---|
| 1453 | function SlideShowWidget(mainDiv, images, idArray)
|
---|
| 1454 | {
|
---|
| 1455 | var _inTransition = false;
|
---|
| 1456 | var _images = new Array();
|
---|
| 1457 | var _mainDiv = mainDiv;
|
---|
[26390] | 1458 | var _imageDiv = $("<div>", {id:"ssImageDiv", style:"height:95%; overflow:auto;"});
|
---|
| 1459 | var _navDiv = $("<div>", {style:"height:5%;"});
|
---|
[26203] | 1460 | var _nextButton = $("<img>", {src:gs.imageURLs.next, style:"float:right; cursor:pointer;"});
|
---|
[26282] | 1461 | var _prevButton = $("<img>", {src:gs.imageURLs.prev, style:"float:left; cursor:pointer; display:none;"});
|
---|
[26305] | 1462 | var _closeLink = $("<a href=\"javascript:$.unblockUI()\">Close Slideshow</a>");
|
---|
[26203] | 1463 | var _clearDiv = $("<div>", {style:"clear:both;"});
|
---|
| 1464 | var _currentIndex = 0;
|
---|
| 1465 |
|
---|
| 1466 | _navDiv.append(_nextButton);
|
---|
[26305] | 1467 | _navDiv.append(_closeLink);
|
---|
[26203] | 1468 | _navDiv.append(_prevButton);
|
---|
| 1469 | _navDiv.append(_clearDiv);
|
---|
| 1470 | _mainDiv.append(_navDiv);
|
---|
| 1471 | _mainDiv.append(_imageDiv);
|
---|
| 1472 |
|
---|
| 1473 | for(var i = 0; i < images.length; i++)
|
---|
| 1474 | {
|
---|
| 1475 | _images.push($("<img>", {src:images[i], "class":"slideshowImage"}));
|
---|
| 1476 | }
|
---|
| 1477 |
|
---|
[26282] | 1478 | if(_images.length < 2)
|
---|
| 1479 | {
|
---|
| 1480 | _nextButton.css("display", "none");
|
---|
| 1481 | }
|
---|
| 1482 |
|
---|
[26203] | 1483 | _imageDiv.append(_images[0]);
|
---|
| 1484 |
|
---|
| 1485 | this.nextImage = function()
|
---|
| 1486 | {
|
---|
| 1487 | if(!_inTransition)
|
---|
| 1488 | {
|
---|
| 1489 | _inTransition = true;
|
---|
| 1490 | if((_currentIndex + 1) < _images.length)
|
---|
| 1491 | {
|
---|
[26282] | 1492 | _prevButton.css("display", "");
|
---|
| 1493 | if(_currentIndex + 1 == _images.length - 1)
|
---|
| 1494 | {
|
---|
| 1495 | _nextButton.css("display", "none");
|
---|
| 1496 | }
|
---|
| 1497 |
|
---|
[26305] | 1498 | _imageDiv.fadeOut(500, function()
|
---|
[26203] | 1499 | {
|
---|
| 1500 | _imageDiv.empty();
|
---|
| 1501 | _imageDiv.append(_images[_currentIndex + 1]);
|
---|
| 1502 | _currentIndex++;
|
---|
[26305] | 1503 | _imageDiv.fadeIn(500, function()
|
---|
[26203] | 1504 | {
|
---|
| 1505 | _inTransition = false;
|
---|
| 1506 | });
|
---|
| 1507 | });
|
---|
| 1508 | }
|
---|
| 1509 | else
|
---|
| 1510 | {
|
---|
| 1511 | _inTransition = false;
|
---|
| 1512 | }
|
---|
| 1513 | }
|
---|
| 1514 | }
|
---|
| 1515 |
|
---|
| 1516 | this.prevImage = function()
|
---|
| 1517 | {
|
---|
| 1518 | if(!_inTransition)
|
---|
| 1519 | {
|
---|
| 1520 | _inTransition = true;
|
---|
| 1521 | if((_currentIndex - 1) >= 0)
|
---|
| 1522 | {
|
---|
[26282] | 1523 | _nextButton.css("display", "");
|
---|
| 1524 | if(_currentIndex - 1 == 0)
|
---|
| 1525 | {
|
---|
| 1526 | _prevButton.css("display", "none");
|
---|
| 1527 | }
|
---|
| 1528 |
|
---|
[26305] | 1529 | _imageDiv.fadeOut(500, function()
|
---|
[26203] | 1530 | {
|
---|
| 1531 | _imageDiv.empty();
|
---|
| 1532 | _imageDiv.append(_images[_currentIndex - 1]);
|
---|
| 1533 | _currentIndex--;
|
---|
[26305] | 1534 | _imageDiv.fadeIn(500, function()
|
---|
[26203] | 1535 | {
|
---|
| 1536 | _inTransition = false;
|
---|
| 1537 | });
|
---|
| 1538 | });
|
---|
| 1539 | }
|
---|
| 1540 | else
|
---|
| 1541 | {
|
---|
| 1542 | _inTransition = false;
|
---|
| 1543 | }
|
---|
| 1544 | }
|
---|
| 1545 | }
|
---|
| 1546 |
|
---|
| 1547 | var getRootFilenameFromURL = function(url)
|
---|
| 1548 | {
|
---|
| 1549 | var urlSegments = url.split("/");
|
---|
| 1550 | var filename = urlSegments[urlSegments.length - 1];
|
---|
| 1551 | return filename.replace(/_thumb\..*$/, "");
|
---|
| 1552 | }
|
---|
| 1553 |
|
---|
| 1554 | var setLink = function(currentLink, index)
|
---|
| 1555 | {
|
---|
| 1556 | $(currentLink).click(function()
|
---|
| 1557 | {
|
---|
| 1558 | _inTransition = true;
|
---|
| 1559 | _currentIndex = index;
|
---|
[26305] | 1560 | _imageDiv.fadeOut(500, function()
|
---|
[26203] | 1561 | {
|
---|
| 1562 | _imageDiv.empty();
|
---|
| 1563 | _imageDiv.append(_images[_currentIndex]);
|
---|
[26305] | 1564 | _imageDiv.fadeIn(500, function()
|
---|
[26203] | 1565 | {
|
---|
| 1566 | _inTransition = false;
|
---|
| 1567 | });
|
---|
| 1568 | });
|
---|
| 1569 | });
|
---|
| 1570 | }
|
---|
| 1571 |
|
---|
| 1572 | var sliderLinks = $(".pageSliderCol a");
|
---|
| 1573 | for(var i = 0; i < sliderLinks.length; i++)
|
---|
| 1574 | {
|
---|
| 1575 | var currentLink = sliderLinks[i];
|
---|
| 1576 | var id = $(currentLink).attr("href").split("'")[1];
|
---|
| 1577 |
|
---|
| 1578 | for(var j = 0; j < idArray.length; j++)
|
---|
| 1579 | {
|
---|
| 1580 | if(idArray[j].id == id)
|
---|
| 1581 | {
|
---|
| 1582 | var image = idArray[j].source;
|
---|
| 1583 |
|
---|
| 1584 | for(var l = 0; l < images.length; l++)
|
---|
| 1585 | {
|
---|
| 1586 | var filename = getRootFilenameFromURL(images[l]);
|
---|
| 1587 | if (filename == image)
|
---|
| 1588 | {
|
---|
| 1589 | setLink(currentLink, l);
|
---|
| 1590 | break;
|
---|
| 1591 | }
|
---|
| 1592 | }
|
---|
| 1593 |
|
---|
| 1594 | break;
|
---|
| 1595 | }
|
---|
| 1596 | }
|
---|
| 1597 | }
|
---|
| 1598 |
|
---|
| 1599 | _nextButton.click(this.nextImage);
|
---|
| 1600 | _prevButton.click(this.prevImage);
|
---|
[29861] | 1601 | }
|
---|