root/main/trunk/greenstone2/macros/document.dm @ 27277

Revision 27277, 25.0 KB (checked in by ak19, 6 years ago)

Adding an Ajax Synchronous Post method to gsajaxapi.js which is then used by the setMetadataArray() that is called from document.dm. Also corrected a variable misspelling in baseaction (authenication changed to authentication) so that locating perl code that deals with authentication may become easier.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1# this file must be UTF-8 encoded
2
3package document
4
5#######################################################################
6# macros set from within the server
7#######################################################################
8
9_imagethispage_ {}
10_httpprevarrow_ {}
11_httpnextarrow_ {}
12_pagetitle_ {}
13_phindclassifier_ {}
14_collageclassifier_ {}
15
16# custom header for individual document
17_documentheader_ {}
18
19#custom css links for individual document
20_csslink_{
21   <link rel="stylesheet" href="_cssfilelink_" type="text/css"
22    charset="UTF-8"   _linktagend_
23  <link rel="alternate stylesheet" href="_httpstyle_/preview-document.css"
24    type="text/css"
25    title="Preview Document" charset="UTF-8" media="screen"  _linktagend_
26   <link rel="stylesheet" href="_httpstyle_/print-document.css" type="text/css"
27    charset="UTF-8" media="print"  _linktagend_
28}
29
30#######################################################################
31# page content
32#######################################################################
33
34_tocopen_ {<div class="top" _tocopenextra_>}
35_tocclose_ {</div>}
36
37_nextsearchresult_ {_If_("_cgiargsrn_" ne "0",<li id="nextresult"><a href="_httpquery_&amp;ifl=1&amp;ifln=_cgiargsrn_">_textnextsearchresult_</a></li>)}
38
39_prevsearchresult_ {_If_("_cgiargsrp_" ne "0",<li id="prevresult"><a href="_httpquery_&amp;ifl=1&amp;ifln=_cgiargsrp_">_textprevsearchresult_</a></li>)}
40
41_content_ {
42_optnavigationbar_
43
44_If_(_phindclassifier__collageclassifier_,
45<p style="text-align: center;">
46_phindclassifier_
47_collageclassifier_
48</p>
49)
50
51_If_("_cgiargcl_" eq "search",
52<ul id="searchresults">
53_prevsearchresult_
54_nextsearchresult_
55</ul>)
56
57<div class="document">
58
59
60}
61
62# Dublin Core Metadata Element Set, Version 1.1
63_textTitlepage_ {_texticonhtitle_}
64_textCreatorpage_ {_texticonhcreat_}
65_textSubjectpage_ {_texticonhsubj_}
66_textDescriptionpage_ {_texticonhdesc_}
67_textPublisherpage_ {_texticonhpubl_}
68_textContributorpage_ {_texticonhcontr_}
69_textDatepage_ {_texticonhdate_}
70_textTypepage_ {_texticonhtype_}
71_textFormatpage_ {_texticonhform_}
72_textIdentifierpage_ {_texticonhident_}
73_textSourcepage_ {_texticonhsrc_}
74_textLanguagepage_ {_texticonhlang_}
75_textRelationpage_ {_texticonhrel_}
76_textCoveragepage_ {_texticonhcover_}
77_textRightspage_ {_texticonhright_}
78
79_textTopage_ {_texticonhto_}
80_textFrompage_ {_texticonhfrom_}
81_textSeriespage_ {_texticonhser_}
82_textHowtopage_ {_texticonhhow_}
83_textOrganizationpage_ {_texticonhorg_}
84_textBrowsepage_ {_texticonhbrwse_}
85_textCollagepage_ {_texticonhcoll_}
86_textPeoplepage_ {_texticonhpeople_}
87_textAcronympage_ {_texticonhacronym_}
88_textPhrasepage_ {_texticonhphrases_}
89_textArtistpage_ {_texticonhartist_}
90_textKeywordpage_ {_texticonhkw_}
91_textVolumepage_ {_texticonhvol_}
92_textCaptionspage_ {_texticonhcapt_}
93_textCountriespage_ {_texticonhcount_}
94
95#######################################################################
96# navigation arrows
97#
98#######################################################################
99
100# these two may be reset to "" by the server
101_navarrowsbottom_ {_navarrows_}
102_navarrowstop_ {_navarrows_}
103
104_navarrows_ {<center>
105<table width=_pagewidth_ cellpadding=0 cellspacing=0 border=0>
106<tr><td align=left valign=top>
107_usercomment_
108_prevarrow_
109</td><td align=right valign=top>
110_nextarrow_
111</td></tr></table>
112</center>
113}
114
115_prevarrow_ {_If_(_httpprevarrow_,<a href="_httpprevarrow_">_iconprev_</a>)}
116_nextarrow_ {_If_(_httpnextarrow_,<a href="_httpnextarrow_">_iconnext_</a>)}
117
118_navarrows_ [v=1] {<p>
119_prevarrow_<br>
120_nextarrow_
121}
122
123#######################################################################
124# section for adding user comments: consists of form and its javascript
125#######################################################################
126
127# Display the add-user-comment form on actual document pages and not when browsing/searching
128# This means the form should only be displayed on pages where the _cgiargd_ (the docid) is set
129
130# For getting the submitbutton to make Ajax calls, see
131# http://stackoverflow.com/questions/4264091/input-type-submit-instead-of-input-type-button-with-ajax
132# http://stackoverflow.com/questions/8869341/ajax-form-submit-with-submit-button
133
134_usercomment_ {
135
136_If_(_cgiargd_,
137
138<form name="AddUserCommentForm">
139<p>_textcommentusername_ <input type="text" name="username"></p>
140<p>
141_textaddusercomment_
142<textarea name="comment" rows="10" cols="70"></textarea>
143<input type=hidden name="d" value="_cgiargd_">
144</p>
145
146<input type="submit" value="_textaddcomment_" onclick="addUserComment(document.AddUserCommentForm.username.value, document.AddUserCommentForm.comment.value, document.AddUserCommentForm.d.value, document); return false;">
147<label id="usercommentfeedback"></label>
148</form>
149)
150
151<script type="text/javascript"> 
152
153    // Unused. Replaced in favour of call to escape() in setMetaArray function that calls urlPostSync
154    // http://stackoverflow.com/questions/6020714/escape-html-using-jquery
155    function safeHTML(str) \{
156         return str.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;").replace('"',"&quot;").replace("'","&#x27;").replace("/", "&#x2F;"); //"\\""
157    \}
158
159
160    function addUserComment(_username, _comment, _docid, doc) \{
161        // Need to the add user comment meta of username, timestamp and comment to the
162        // topmost section of the document. So only get the docId up to any period mark:
163        var period = _docid.indexOf(".");
164        if(period != -1) \{
165            _docid = _docid.substring(0, period);
166        \}
167
168
169        // Want to store username, timestamp and comment in import/metadata.xml, archives/doc.xml
170        // and index/col.gdb.
171
172        // For getting the current time, see
173        // http://stackoverflow.com/questions/3830244/get-current-date-time-in-seconds
174        var _timestamp = new Date().getTime(); // div by 1000 to get seconds. valueOf() may return string
175
176        //alert("username:" + _username
177        //+ "\\ncomment: " + _comment
178        //+ "\\ncollection: " + collection
179        //+ "\\ndocid: " + _docid
180        //+ "\\ntimestamp: " + _timestamp);
181
182
183        // Entity encode the values before storing (at least <, >, /. And single and double quote, ampersand)
184        // http://stackoverflow.com/questions/6020714/escape-html-using-jquery
185        // setMetadataArray escapes the entire JSON, is that better than escaping individually here?
186        //_docid = escape(_docid);
187        //_timestamp = escape(_timestamp);
188        //_username = escape(_username); //safeHTML(_username);
189        //_comment = escape(_comment); //safeHTML(_comment);
190
191        // Use this if making individual api calls to set username meta, then timestamp then comment meta
192        // GSAPI already knows the collection
193        //gsapi.setMetadata(_docid, "username", null, _username, "accumulate", "import|archives|index");
194        //gsapi.setMetadata(_docid, "usertimestamp", null, _timestamp, "accumulate", "import|archives|index");
195        //gsapi.setMetadata(_docid, "usercomment", null, _comment, "accumulate", "import|archives|index");
196
197
198        // Use the new JSON metatable format to set username, timestamp and comment meta for docid in one go
199
200        // For creating the JSON object that gets turned into a string, see
201        // http://msdn.microsoft.com/en-us/library/ie/cc836459%28v=vs.94%29.aspx
202        // http://jsfiddle.net/qmacro/W54hy/
203       
204        var username_rec = \{
205            metaname: "username",
206            metavals: [_username]
207        \};
208
209        var timestamp_rec = \{
210            metaname: "usertimestamp",
211            metavals: [_timestamp]
212        \};
213
214        var comment_rec = \{
215            metaname: "usercomment",
216            metavals: [_comment]
217        \};
218
219        var doc_rec = \{
220            docid: _docid,
221            metatable: [username_rec, timestamp_rec, comment_rec],
222            metamode: "accumulate"
223        \};
224
225        var docArray = [doc_rec];
226
227        //alert(JSON.stringify(docArray));
228
229        // GSAPI already knows the collection
230        gsapi.setMetadataArray(docArray, "accumulate", "import|archives|index");       
231        doc.AddUserCommentForm.comment.value = "";
232        doc.AddUserCommentForm.username.value = "";
233        doc.getElementById("usercommentfeedback").innerHTML = "_textcommentsubmitted_";
234    \}
235</script>
236}
237
238
239#######################################################################
240# the goto form
241#######################################################################
242
243_gotoform_ {
244<form name="GotoForm" method="get" action="_gwcgi_">
245<input type=hidden name="e" value="_decodedcompressedoptions_">
246<input type=hidden name="d" value="_cgiargd_">
247<input type=hidden name="cl" value="_cgiargcl_">
248<input type="text" name="gp" size="3" maxlength="4">
249<input type="submit" value="_textgoto_">
250</form>
251}
252
253_textnumpages_ {&nbsp;<i>(_1_ _pages_)</i>}
254_parentarrow_ {}
255_prevtitle_ {}
256_nexttitle_ {}
257
258#######################################################################
259# the phind applet
260#
261# The phind applet is only required on phind classifier pages.
262# Consequently, the _phindclassifier_ macro is not usually set.  On screens
263# where it is required, _phindclassifier_ resolves to _phindapplet_, and
264# the following macro is loaded into the web page.
265#######################################################################
266
267_phindapplet_ {
268<APPLET CODEBASE="_httpjava_" CODE="org.nzdl.gsdl.Phind.Phind.class" ARCHIVE="Phind.jar" WIDTH=500 HEIGHT=400>
269  <PARAM NAME=library      VALUE="_gwcgi_?e=_compressedoptions_">
270  <PARAM NAME=phindcgi     VALUE="_gwcgi_?a=phind">
271  <PARAM NAME=collection   VALUE="_cgiargc_">
272  <PARAM NAME=classifier   VALUE="_phindnumber_">
273
274  <PARAM NAME=orientation  VALUE="vertical">
275  <PARAM NAME=depth        VALUE="2">
276  <PARAM NAME=resultorder VALUE="L,l,E,e,D,d">
277  <PARAM NAME=textorientation VALUE="_textorientation_">
278  <PARAM NAME=backdrop     VALUE="_httpimg_/phindbg1.jpg">
279  <PARAM NAME=fontsize     VALUE="10">
280  <PARAM NAME=blocksize    VALUE="10">
281
282  The Phind java applet.
283</APPLET>
284}
285
286_collageapplet_ {
287 <applet CODEBASE="_httpjava_"
288     code="org.nzdl.gsdl.GsdlCollageApplet.GsdlCollageApplet.class"
289     archive="GsdlCollageApplet.jar"
290     width="_collagexdim_" height="_collageydim_">
291
292        <param name="gwcgi" value="_gwcgi_">
293        <param name="collection" value="_cgiargc_">
294        <param name="classifier" value="_cgiargcl_.1">
295
296        <param name="hrefMustHave" value="cl=_cgiargcl_.1">
297        <param name="imageMustNotHave" value="hl=\%x=\%gt=\%gc=\%.pr">
298
299        <param name="imageType" value="_collageimageType_">
300        <param name="verbosity" value="_collageverbosity_">
301        <param name="maxDepth" value="_collagemaxDepth_">
302        <param name="maxDisplay" value="_collagemaxDisplay_">
303        <param name="refreshDelay" value="_collagerefreshDelay_">
304        <param name="isJava2" value="_collageisJava2_">
305        <param name="bgcolor" value="_collagebgcolor_">
306        <param name="documentroot" value="_httpimg_">   
307 </applet>
308
309<center>
310_collagecaption_
311</center>
312}
313
314
315_flashbook_ {
316 <div id="bookdiv">
317 </div>
318
319 <script type="text/javascript">
320 var myWidth = "100%";
321 myHeight = 800;
322 
323 var img_cover = '_httpassocdir_/_thisOID_/cover.jpg';
324 var doc_url = document.URL;
325 doc_url = doc_url.replace(/(&|\\?)book=[a-z]+/gi,'');
326 doc_url += '&book=flashxml';
327 
328 var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;//get windows or not
329 //Only for Windows computers because Greenstone webserver doesn't allow us to pass parameters to Flash.
330 //These methods is called by the Flash program to get all the necessary parameters for the book
331 //However, it will only work for IE 5.0 and later, Firefox 1.0 and later, Mozilla 1.7.5 and later
332 //Netscape 8.0 and later, Safari 1.3 and later
333 function getDocURL() \{ return doc_url; \}
334 function getImgCover() \{ return img_cover; \}
335 function getStageW() \{ return -1; \}
336 function getStageH() \{ return -1; \}
337
338
339 var flash_plug_html = "";
340 flash_plug_html += '<OBJECT align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" \\n';
341 flash_plug_html += '  codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" \\n';
342 flash_plug_html += '  height="';
343 flash_plug_html += myHeight + '" id="Book" swLiveConnect="true" align="middle"\\n';
344 flash_plug_html += '  width="';
345 flash_plug_html += myWidth + '">\\n';
346 
347 flash_plug_html += '    <PARAM name="allowScriptAccess" value="always" />\\n';
348 flash_plug_html += '    <PARAM name="movie" value="_httpflash_/Book.swf';
349 if (isWin == false)
350 \{
351    flash_plug_html += '?src_image=' + escape(img_cover);
352    flash_plug_html += '&amp;doc_url=' + escape(doc_url);
353 \}
354 flash_plug_html += '" />\\n';
355 flash_plug_html += '    <PARAM name="quality" value="high" />\\n';
356 flash_plug_html += '    <PARAM name="bgcolor" value="#FFFFFF" />\\n';
357 flash_plug_html += '    <EMBED align="middle" \\n';
358 flash_plug_html += '      allowScriptAccess="always" swLiveConnect="true" \\n';
359 flash_plug_html += '      bgcolor="#FFFFFF" height="';
360 flash_plug_html += myHeight + '" name="Book" \\n';
361 flash_plug_html += '      pluginspage="http://www.macromedia.com/go/getflashplayer" \\n';
362 flash_plug_html += '      quality="high" \\n';
363 flash_plug_html += '      src=\\'_httpflash_/Book.swf';
364 if (isWin == false)
365 \{
366    flash_plug_html += '?src_image=' + escape(img_cover);
367    flash_plug_html += '&amp;doc_url=' + escape(doc_url);
368 \}
369 flash_plug_html += '\\'\\n';
370 flash_plug_html += '      type="application/x-shockwave-flash" width="';
371 flash_plug_html += myWidth + '" />\\n';
372 flash_plug_html += '</OBJECT>\\n';
373
374 var flash_div = document.getElementById("bookdiv");
375 flash_div.innerHTML = flash_plug_html;
376 </script>
377}
378
379#######################################################################
380# icons
381#######################################################################
382
383_iconsmalltext_ {<img src="_httpiconsmtext_" class="icon" width=_widthsmtext_ height=_heightsmtext_ alt="_texticonsmalltext_" title="_texticonsmalltext_">}
384_iconsmalltext_ [v=1] {<small><b>_texticonsmalltext2_</b></small>}
385
386_iconarrowsmalltext_ {<img src="_httpiconasmtext_" class="icon" width=_widthasmtext_ height=_heightasmtext_ alt="_texticonsmalltext_" title="_texticonsmalltext_">}
387_iconarrowsmalltext_ [v=1] {<small><b>->_texticonsmalltext2_</b></small>}
388
389_iconclosedfolder_ {<img src="_httpiconclsdfldr_" class="icon" width=_widthclsdfldr_ height=_heightclsdfldr_ alt="_texticonclosedfolder_" title="_texticonclosedfolder_">}
390_iconclosedfolder_ [v=1] {<small><b>_texticonclosedfolder2_</b></small>}
391
392_iconarrowclosedfolder_ {<img src=_httpiconaclsdfdr_" class="icon" width=_widthaclsdfdr_ height=_heightaclsdfdr_ alt="_texticonclosedfolder_" title="_texticonclosedfolder_">}
393_iconarrowclosedfolder_ [v=1] {<small><b>->_texticonclosedfolder2_</b></small>}
394
395_iconopenfolder_ {<img src="_httpiconopenfldr_" class="icon" width=_widthopenfldr_ height=_heightopenfldr_ alt="_texticonopenfolder_" title="_texticonopenfolder_">}
396_iconopenfolder_ [v=1] {<small><b>_texticonopenfolder2_</b></small>}
397
398_iconarrowopenfolder_ {<img src="_httpiconaopenfdr_" class="icon" width=_widthaopenfdr_ height=_heightaopenfdr_ alt="_texticonopenfolder_" title="_texticonopenfolder_">}
399_iconarrowopenfolder_ [v=1] {<small><b>->_texticonopenfolder2_</b></small>}
400
401_iconarrowclosedbook_ {<img src="_httpiconabook_" width=_widthabook_ height=_heightabook_ class="icon" alt="_texticonclosedbook_" title="_texticonclosedbook_">}
402_iconarrowclosedbook_ [v=1] {<small><b>->_texticonclosedbook_: </b></small>}
403
404_iconopenbook_ {<img src="_httpiconopenbook_" width=_widthopenbook_ height=_heightopenbook_ class="icon" alt="_texticonopenbook_" title="_texticonopenbook_">}
405_iconopenbook_ [v=1] {<small><b>_texticonopenbook_: </b></small>}
406
407_iconarrowopenbook_ {<img src="_httpiconaopenbk_" width=_widthaopenbk_ height=_heightaopenbk_ class="icon" alt="_texticonopenbook_" title="_texticonopenbook_">}
408_iconarrowopenbook_ [v=1] {<small><b>->_texticonopenbook_: </b></small>}
409
410_iconopenbookshelf_ {<img src="_httpiconbshelf_" class="icon" width=_widthbshelf_ height=_heightbshelf_ alt="_texticonopenbookshelf_" title="_texticonopenbookshelf_">}
411_iconopenbookshelf_ [v=1] {<small><b>_texticonopenbookshelf_: </b></small>}
412
413_iconarrowopenbookshelf_ {<img src="_httpiconabshelf_" class="icon" width=_widthabshelf_ height=_heightabshelf_ alt="_texticonopenbookshelf_" title="_texticonopenbookshelf_">}
414_iconarrowopenbookshelf_ [v=1] {<small><b>->_texticonopenbookshelf_: </b></small>}
415
416_iconclosedbookshelf_ {<img src="_httpiconbshelf_" class="icon" width=_widthbshelf_ height=_heightbshelf_ alt="_texticonclosedbookshelf_" title="_texticonclosedbookshelf_">}
417_iconclosedbookshelf_ [v=1] {<small><b>_texticonclosedbookshelf_: </b></small>}
418
419_iconarrowclosedbookshelf_ {<img src="_httpiconabshelf_" class="icon" width=_widthabshelf_ height=_heightabshelf_ alt="_texticonclosedbookshelf_" title="_texticonclosedbookshelf_">}
420_iconarrowclosedbookshelf_ [v=1] {<small><b>->_texticonclosedbookshelf_: </b></small>}
421
422_iconpointer_ {<img src="_httpiconarrrght_" class="icon" width=_widtharrrght_ height=_heightarrrght_>}
423_iconpointer_ [v=1] {<small><b>_texticonpointer_-> </b></small>}
424
425_iconwarning_ {<img src="_httpiconwarning_" width="_widthwarning_" height="_heightwarning_" class="icon" align="left">}
426_iconwarning_ [v=1] {_texticonwarning_}
427
428
429#######################################################################
430# images
431#######################################################################
432
433_coverimage_ {<img alt="Cover Image" onError="src='_httpimg_/blank.gif'" src="_httpassocdir_/_thisOID_/cover.jpg">}
434
435_docbutton_ {<div class="button"><span class="button" title="_3_"><a href="_1_">_2_</a></span></div>
436}
437
438# can't use _docbutton_ macro for detach button as we need to include target
439_imagedetach_ {<div class="button"><span class="button"><a href="_httpcurrentdocument_&amp;x=1" target="\_blank" title="_texticondetach_">_textDETACH_</a></span></div>}
440
441_imageprint_{<div class="button"><span class="button"><a href="javascript:print_preview()">_textPRINT_</a></span></div>}
442
443
444_imagehighlight_ {_docbutton_(_httpcurrentdocument_&amp;hl=1&amp;gc=_cgiarggc_&amp;gt=_cgiarggt_,_textHIGHLIGHT_,_texticonhighlight_)}
445
446_imagenohighlight_ {_docbutton_(_httpcurrentdocument_&amp;hl=0&amp;gc=_cgiarggc_&amp;gt=_cgiarggt_,_document:textNOHIGHLIGHT_,_document:texticonnohighlight_)}
447
448_imagecontracttoc_ {_docbutton_(_httpcurrentdocument_&amp;gc=0,_textCONTRACTCONTENTS_,_texticoncontracttoc_)}
449
450_imageexpandtoc_ {_docbutton_(_httpcurrentdocument_&amp;gc=1,_textEXPANDCONTENTS_,_texticonexpandtoc_)}
451
452_imagecontracttext_ {_docbutton_(_httpcurrentdocument_&amp;gt=0,_textCONTRACT_,_texticoncontracttext_)}
453
454_imageexpandtext_ {_docbutton_(_httpcurrentdocument_&amp;gt=1,_textEXPANDTEXT_,_texticonexpandtext_)}
455
456_imagecont_ {_docbutton_(_httpcurrentdocument_&amp;gt=2,_textCONTINUE_,_texticoncont_)}
457
458
459#######################################################################
460# print preview script
461#######################################################################
462
463
464_pagescriptextra_{
465
466 var style_display_old;
467 var show = true;
468 var toc_top;
469
470 function has_toc(){
471     var div_nodes = document.getElementsByTagName("div");   
472     for (var i=0;i < div_nodes.length ; i++ )\{
473          var div_node = div_nodes[i];
474          if (div_node.className =="toc" && div_node.childNodes.length > 1)
475             \{
476                 return true;
477             \}
478      \}
479   
480    return false;
481 \}
482
483 function hide_toc()\{
484     var div_nodes = document.getElementsByTagName("div");   
485     for (var i=0;i < div_nodes.length ; i++ )\{
486          var div_node = div_nodes[i];
487          if (div_node.className =="toc")
488             \{
489               style_display_old = div_node.style.display;
490               toc_top = document.getElementById("toc_top");
491               if (toc_top)
492                div_node.parentNode.insertBefore(toc_top,div_node);
493                div_node.style.display = "none";
494             \};
495      \} 
496
497 \} 
498
499
500 function show_toc()\{
501 
502     var div_nodes = document.getElementsByTagName("div");   
503     for (var i=0;i < div_nodes.length ; i++ )\{
504          var div_node = div_nodes[i];
505          if (div_node.className =="toc")
506             \{
507               div_node.style.display = style_display_old;
508               if (toc_top)
509                  div_node.insertBefore(toc_top,div_node.firstChild);   
510              \};
511      \}
512
513 \} 
514
515 
516  function switch_toc()\{
517     var toc_link =  document.getElementById("toc_link");
518       while (toc_link.hasChildNodes()) \{
519          toc_link.removeChild(toc_link.firstChild);
520    \} 
521    if (show)\{
522        toc_link.appendChild(document.createTextNode('_textshowcontents_'));
523        show = false;
524        hide_toc();
525    \}
526  else\{
527       toc_link.appendChild(document.createTextNode('_texthidecontents_'));
528      show = true;
529      show_toc();
530    \}
531
532  \}
533   
534  function print_preview() \{
535   // Switch the stylesheet
536    setActiveStyleSheet("Preview Document");
537    add_print_message();
538  \}
539
540  function add_print_message()\{
541     if (document.getElementById)\{
542        var print_message = document.createElement('ul');
543        print_message.id = 'print-message';
544            print_message.className = "printmessage"; 
545       
546         var cancel_print_link = document.createElement('li');
547         cancel_print_link.className = "cancelprint"
548         cancel_print_link.onclick = function()\{ cancel_print(); return false;\};
549         cancel_print_link.appendChild(document.createTextNode('_textreturnoriginal_'));
550          print_message.appendChild(cancel_print_link); 
551
552         
553           var print_link = document.createElement('li');
554           print_link.onclick = function()\{ window.print(); return false;\};
555           print_link.appendChild(document.createTextNode('_textprintpage_'));
556           print_message.appendChild(print_link);
557
558    if (has_toc())\{ 
559      var toc_link = document.createElement('li');
560          toc_link.id = "toc_link";
561          toc_link.onclick = function()\{ switch_toc(); return false;\};
562          toc_link.appendChild(document.createTextNode('_texthidecontents_'));                 
563          print_message.appendChild(toc_link);   
564         \}
565
566         //insert the print message node
567         var div_nodes = document.getElementsByTagName("div");   
568         for (var i=0;i < div_nodes.length ; i++ )\{
569            var div_node = div_nodes[i];
570             if (div_node.className =="document")\{         
571                 var parent = div_node.parentNode;
572                 parent.insertBefore(print_message,div_node);
573           \}
574        \}
575     \}
576
577  \}
578 
579 
580 function cancel_print() \{
581    // Destroy the preview message
582   var print_message = document.getElementById('print-message');
583   var parent = print_message.parentNode;
584   parent.removeChild(print_message);
585   
586    show_toc();
587    // Switch back stylesheet
588    setActiveStyleSheet("default");
589  \}
590
591 function setActiveStyleSheet(title) \{
592    var i, a, main;
593    for(i=0; (a = document.getElementsByTagName("link")[i]); i++) \{
594      if(a.getAttribute("rel").indexOf("style") != -1
595         && a.getAttribute("title")) \{
596        a.disabled = true;
597        if(a.getAttribute("title") == title) a.disabled = false;
598    \}
599   \}
600  \}
601
602}
603
604
605#######################################################################
606# headers/footers
607#######################################################################
608
609
610# header overridden for text pages
611_textheader_ {_cgihead_
612_htmlhead_
613_startspacer_
614
615<!-- document:textheader -->
616<div id="banner">
617<div class="pageinfo"><p class="bannerlinks">_globallinks_</p></div>
618<div class="collectimage">_imagecollection_</div>
619</div>
620<div class="bannerextra">_pagebannerextra_</div>
621}
622
623_textheader_ [v=1] {_cgihead_
624_htmlhead_
625_globallinks_
626}
627
628_footer_ {
629</div> <!-- document:footer -->
630
631<div class="navarrowsbottom">
632_navarrowsbottom_
633</div>
634_endspacer__htmlfooter_
635}
636
637
638
639
640package Global
641   
642# Social network support
643# Defined here in document, as the most likely place this will be used in
644# within a document view, however its package is 'Global' because you
645# might equally want this in a search or browse list
646
647# _1_ = e.g. title
648# _2_ = [srclink] or left empty.  If left empty, then it will share the internal GS document
649
650_sharemescript_ {
651  <script type="text/javascript">
652    var a2a_config = a2a_config || \{ \};
653    a2a_config.linkname = "_1_";
654
655    _If_(_2_,
656    var srclink = \'_2_\';
657   
658    //If metadata value is a valid URL that starts with xxx://
659    // (e.g. any protocol\, http, https\, ftp ...) then that will be the link to share
660    if (srclink.match(/^[^:]+:\\\/\\\//i)) \{
661          a2a_config.linkurl = srclink;
662     \}
663    else \{
664    //if metadata value is [srclink] then we have to cut off the 'href' tag label
665        var href = srclink.match(/href=\"([^\"]*)\"/);
666        a2a_config.linkurl = gsapi.fullDomainURL(href[1]);
667    \}
668    ,
669    //if no metadata was passed as link\, then the GS version of the document will be used.
670    a2a_config.linkurl = gsapi.fullDomainURL("_gwcgi_")+ "?c=_cgiargc_&a=d&d=_cgiargd_";
671)
672
673  </script>
674}
675
676_shareme_ {
677
678<div style=\'padding-left:50px;\' class=\'a2a_kit a2a_default_style\'>
679  _sharemescript_(_1_,_2_)
680  <center>
681    <a class=\'a2a_dd\' href=\'http://www.addtoany.com/share_save\'>Share</a>
682      <span class=\"a2a_divider\"></span>
683      <a class=\'a2a_button_facebook\'></a>
684      <a class=\'a2a_button_twitter\'></a>
685      <a class=\'a2a_button_email\'></a>
686      <a class=\'a2a_button_linkedin\'></a>
687    </center>
688  <script type=\"text/javascript\" src=\"http://static.addtoany.com/menu/page.js\"></script>
689</div>
690
691}
692
693_sharemesmall_ {
694
695<span style=\'padding-left:8px;\' class=\'a2a_kit a2a_default_style\'>
696  _sharemescript_(_1_,_2_)
697    <a class=\'a2a_dd\' href=\'http://www.addtoany.com/share_save\'>Share</a>
698  <script type=\"text/javascript\" src=\"http://static.addtoany.com/menu/page.js\"></script>
699</span>
700
701}
Note: See TracBrowser for help on using the browser.