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

Revision 27281, 25.5 KB (checked in by ak19, 6 years ago)

Preliminary working version of display of existing user comments. Tested and works. Need to optimise it so that we don't repeatedly ask for each username, comment and timestamp from the archives (by calling the new getArchivesMeta function in gsajaxapi), but instead need to be able to ask for all such meta to be returned in an array of triples format.

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