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

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