source: main/trunk/greenstone3/web/interfaces/oran/transform/javascript-global-setup.xsl@ 24468

Last change on this file since 24468 was 24468, checked in by sjm84, 9 years ago

Removing debug statements

  • Property svn:executable set to *
File size: 8.5 KB
Line 
1<xsl:stylesheet version="1.0"
2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:java="http://xml.apache.org/xslt/java"
4 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
5 xmlns:gslib="http://www.greenstone.org/skinning"
6 extension-element-prefixes="java util"
7 exclude-result-prefixes="java util">
8
9 <xsl:template name="setup-gs-variable">
10 <script type="text/javascript">
11 gs = new Array();
12 gs.cgiParams = new Array();
13 gs.siteMetadata = new Array();
14 gs.collectionMetadata = new Array();
15 gs.documentMetadata = new Array();
16 gs.imageURLs = new Array();
17 gs.variables = new Array();
18 </script>
19 <xsl:call-template name="populate-cgi-param-values"/>
20 <xsl:call-template name="populate-image-url-values"/>
21 <xsl:call-template name="populate-metadata-values"/>
22 </xsl:template>
23
24 <xsl:template name="populate-cgi-param-values">
25 <xsl:for-each select="/page/pageRequest/paramList/param">
26 <script type="text/javascript">
27 <xsl:text disable-output-escaping="yes">var name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
28 <xsl:text disable-output-escaping="yes">var value = "</xsl:text><xsl:value-of select="@value"/><xsl:text disable-output-escaping="yes">";</xsl:text>
29 <xsl:text disable-output-escaping="yes">name = name.replace(".", "_");</xsl:text>
30 gs.cgiParams[name] = value;
31 </script>
32 </xsl:for-each>
33 </xsl:template>
34
35 <xsl:template name="populate-metadata-values">
36 <script type="text/javascript">
37 <xsl:text disable-output-escaping="yes">
38 function addMetadataToList(name, value, list, lang)
39 {
40 name = name.replace(".", "_");
41 if(lang == "" || lang == "en")
42 {
43 list[name] = value;
44 }
45 else
46 {
47 if (list[lang] == undefined)
48 {
49 list[lang] = new Array();
50 }
51 var langList = list[lang];
52 langList[name] = value;
53 }
54 }
55 </xsl:text>
56 </script>
57 <xsl:for-each select="/page/pageResponse/metadataList/metadata">
58 <script type="text/javascript">
59 <xsl:text disable-output-escaping="yes">var name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
60 <xsl:text disable-output-escaping="yes">var value = "</xsl:text><xsl:value-of disable-output-escaping="yes" select="."/><xsl:text disable-output-escaping="yes">";</xsl:text>
61 <xsl:text disable-output-escaping="yes">var lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
62 addMetadataToList(name, value, gs.siteMetadata, lang);
63 </script>
64 </xsl:for-each>
65
66 <xsl:for-each select="/page/pageResponse/collection/metadataList/metadata">
67 <script type="text/javascript">
68 <xsl:text disable-output-escaping="yes">var name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
69 <xsl:text disable-output-escaping="yes">var value = "</xsl:text><xsl:value-of disable-output-escaping="yes" select="."/><xsl:text disable-output-escaping="yes">";</xsl:text>
70 <xsl:text disable-output-escaping="yes">var lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
71 addMetadataToList(name, value, gs.collectionMetadata, lang);
72 </script>
73 </xsl:for-each>
74
75 <xsl:for-each select="/page/pageResponse/document/metadataList/metadata">
76 <script type="text/javascript">
77 <xsl:text disable-output-escaping="yes">var name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
78 <xsl:text disable-output-escaping="yes">var value = "</xsl:text><xsl:value-of disable-output-escaping="yes" select="."/><xsl:text disable-output-escaping="yes">";</xsl:text>
79 <xsl:text disable-output-escaping="yes">var lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
80 addMetadataToList(name, value, gs.documentMetadata, lang);
81 </script>
82 </xsl:for-each>
83 </xsl:template>
84
85 <xsl:template name="populate-image-url-values">
86 <script type="text/javascript">
87 <xsl:text disable-output-escaping="yes">gs.imageURLs.expand = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
88 <xsl:text disable-output-escaping="yes">gs.imageURLs.collapse = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
89 <xsl:text disable-output-escaping="yes">gs.imageURLs.page = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
90 <xsl:text disable-output-escaping="yes">gs.imageURLs.chapter = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'chapter_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
91 <xsl:text disable-output-escaping="yes">gs.imageURLs.realisticBook = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'realistic_books_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
92 <xsl:text disable-output-escaping="yes">gs.imageURLs.highlight = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'highlight_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
93 <xsl:text disable-output-escaping="yes">gs.imageURLs.bookshelf = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
94 <xsl:text disable-output-escaping="yes">gs.imageURLs.book = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'book_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
95 <xsl:text disable-output-escaping="yes">gs.imageURLs.loading = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'loading_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
96 <xsl:text disable-output-escaping="yes">gs.imageURLs.pageIcon = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_icon_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
97 </script>
98 </xsl:template>
99</xsl:stylesheet>
100
101 <!--
102 USEFUL FOR TESTING ASSOCIATIVE ARRAYS
103 function getKeys(obj)
104 {
105 var keys = [];
106 for(var key in obj)
107 {
108 keys.push(key);
109 }
110 return keys;
111 }
112 -->
113
114 <!-- CAN WE FIND SOME WAY TO MAKE THIS WORK?
115 <xsl:call-template name="populate-metadata-values">
116 <xsl:with-param name="path">/page/pageResponse/metadataList/metadata</xsl:with-param>
117 <xsl:with-param name="metadataListName">siteMetadata</xsl:with-param>
118 </xsl:call-template>
119
120 <xsl:call-template name="populate-metadata-values">
121 <xsl:with-param name="path">/page/pageResponse/collection/metadataList/metadata</xsl:with-param>
122 <xsl:with-param name="metadataListName">collectionMetadata</xsl:with-param>
123 </xsl:call-template>
124
125 <xsl:call-template name="populate-metadata-values">
126 <xsl:with-param name="path">/page/pageResponse/document/metadataList/metadata</xsl:with-param>
127 <xsl:with-param name="metadataListName">documentMetadata</xsl:with-param>
128 </xsl:call-template>
129 -->
130
131 <!-- NOT WORKING BUT IT WOULD BE TIDIER IF IT DID
132 <xsl:template name="populate-metadata-values">
133 <xsl:param name="path"/>
134 <xsl:param name="metadataListName"/>
135
136 <xsl:for-each select="$path">
137 <script type="text/javascript">
138 <xsl:text disable-output-escaping="yes">var name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
139 <xsl:text disable-output-escaping="yes">var value = "</xsl:text><xsl:value-of select="."/><xsl:text disable-output-escaping="yes">";</xsl:text>
140 <xsl:text disable-output-escaping="yes">var lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
141 <xsl:text disable-output-escaping="yes">var metadataListName = "</xsl:text><xsl:value-of select="$metadataListName"/><xsl:text disable-output-escaping="yes">";</xsl:text>
142 var list = gs[metadataListName];
143 if(lang == "")
144 {
145 list[name] = value;
146 }
147 else
148 {
149 if (list[lang] == undefined)
150 {
151 list[lang] = new Array();
152 }
153 var langList = list[lang];
154 langList[name] = value;
155 }
156 </script>
157 </xsl:for-each>
158 </xsl:template>
159 -->
Note: See TracBrowser for help on using the repository browser.