source: main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js@ 33128

Last change on this file since 33128 was 33128, checked in by wy59, 5 years ago

Improvements to Coordinate support AND bugfixes. BUT not all the fixes may be ideal, many marked with TODO. 1. Now we support an Array of coordinates. At present these are only displayed as Markers, but in future shapes should appear as shapes. 2. Bugfixes include: (a) expanding sections wasn't working when we had hierarchical docs with Coordinate data, because map-scripts 'overrode' the toggleSection function but no longer did any of the doc expanding behaviour that document_scripts.js used to do. This was not a problem with the ImagesGPS collection, simply because that did not have hierarchical/sectionalised documents. (b) Perl: A previous commit output duplicate Coordinates into the index. Now this doesn't happen. Fix works but may not be ideal. 3. Perl: (a) Reserved index names CD, CS for Coordinate and CoordShort. Note however that LAT and LNG were never added to reserve list for index names. (b) Now doc.pm::processCoord() takes a section parameter and works out the section-ptr from that.

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