source: main/trunk/greenstone2/macros/document.dm@ 27297

Last change on this file since 27297 was 27297, checked in by ak19, 11 years ago

Username field should not be cleared as it's no longer hidden and stores the logged in user. Also added a logout for the add comments feature, but there's probably a better way to do this, though the admin pages don't provide a logout and require you to log in repeatedly.

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