1 | "use strict";
|
---|
2 |
|
---|
3 |
|
---|
4 |
|
---|
5 | var foo_count = 0;
|
---|
6 |
|
---|
7 | function gitDebug(key,val,args) {
|
---|
8 | console.log(key+"="+val+" ("+args+")");
|
---|
9 | foo_count++;
|
---|
10 | return val;
|
---|
11 | }
|
---|
12 |
|
---|
13 |
|
---|
14 | // Port of methods from GSXLUtil.java and Dictionary.java to support client side XSLT
|
---|
15 |
|
---|
16 | // Function for inserting args into retrieved interface string
|
---|
17 | function getInterfaceTextSubstituteArgs(initial,argsStr)
|
---|
18 | {
|
---|
19 | var args = argsStr.split(";");
|
---|
20 |
|
---|
21 | var complete = ""; //new StringBuffer();
|
---|
22 |
|
---|
23 | // While we still have initial string left.
|
---|
24 | while ((initial.length > 0) && (initial.indexOf('{') != -1) && (initial.indexOf('}') != -1))
|
---|
25 | {
|
---|
26 | // Remove preamble
|
---|
27 | var opening = initial.indexOf('{');
|
---|
28 | var closing = initial.indexOf('}');
|
---|
29 | var comment_mark = initial.indexOf('-', opening); // May not exist
|
---|
30 | if (comment_mark > closing)
|
---|
31 | { // May also be detecting a later comment
|
---|
32 | comment_mark = -1;
|
---|
33 | }
|
---|
34 | complete += initial.substring(0, opening);
|
---|
35 |
|
---|
36 | // Parse arg_num
|
---|
37 | var arg_str = null;
|
---|
38 | if (comment_mark != -1)
|
---|
39 | {
|
---|
40 | arg_str = initial.substring(opening + 1, comment_mark);
|
---|
41 | }
|
---|
42 | else
|
---|
43 | {
|
---|
44 | arg_str = initial.substring(opening + 1, closing);
|
---|
45 | }
|
---|
46 | if (closing + 1 < initial.length)
|
---|
47 | {
|
---|
48 | initial = initial.substring(closing + 1);
|
---|
49 | }
|
---|
50 | else
|
---|
51 | {
|
---|
52 | initial = "";
|
---|
53 | }
|
---|
54 |
|
---|
55 | var arg_num = Number(arg_str);
|
---|
56 | // Insert argument
|
---|
57 | if ((args != null) && (0 <= arg_num) && (arg_num < args.length))
|
---|
58 | {
|
---|
59 | complete += args[arg_num];
|
---|
60 | }
|
---|
61 | }
|
---|
62 |
|
---|
63 | complete += initial;
|
---|
64 |
|
---|
65 | return complete;
|
---|
66 | }
|
---|
67 |
|
---|
68 | var xsltUtil_stringVariables = {};
|
---|
69 |
|
---|
70 | //public static void storeString(String name, String value)
|
---|
71 | function storeString(name,value)
|
---|
72 | {
|
---|
73 | xsltUtil_stringVariables[name] = value;
|
---|
74 | }
|
---|
75 |
|
---|
76 | //public static String getString(String name)
|
---|
77 | function getString(name)
|
---|
78 | {
|
---|
79 | return xsltUtil_stringVariables[name];
|
---|
80 | }
|
---|
81 |
|
---|
82 |
|
---|
83 | //public static String escapeNewLines(String str)
|
---|
84 | function escapeNewLines(str)
|
---|
85 | {
|
---|
86 | if (str == null || str.length < 1)
|
---|
87 | {
|
---|
88 | return null;
|
---|
89 | }
|
---|
90 | return str.replace("\n", "\\\n");
|
---|
91 | }
|
---|
92 |
|
---|
93 | //public static String escapeQuotes(String str)
|
---|
94 | function escapeQuotes(str)
|
---|
95 | {
|
---|
96 | if (str == null || str.length < 1)
|
---|
97 | {
|
---|
98 | return null;
|
---|
99 | }
|
---|
100 | return str.replace("\"", "\\\"");
|
---|
101 | }
|
---|
102 |
|
---|
103 | //public static String escapeNewLinesAndQuotes(String str)
|
---|
104 | function escapeNewLinesAndQuotes(str)
|
---|
105 | {
|
---|
106 | if (str == null || str.length < 1)
|
---|
107 | {
|
---|
108 | return null;
|
---|
109 | }
|
---|
110 | return escapeNewLines(escapeQuotes(str));
|
---|
111 | }
|
---|
112 |
|
---|
113 |
|
---|
114 |
|
---|
115 | function getNumberedItem(list, number)
|
---|
116 | {
|
---|
117 | var items = list.split(",");
|
---|
118 |
|
---|
119 | if (items.length > number)
|
---|
120 | {
|
---|
121 | return items[number];
|
---|
122 | }
|
---|
123 |
|
---|
124 | return ""; // index out of bounds
|
---|
125 | }
|
---|
126 |
|
---|
127 |
|
---|
128 |
|
---|
129 |
|
---|
130 | //public static boolean oidIsMatchOrParent(String first, String second)
|
---|
131 | function oidIsMatchOrParent(first, second)
|
---|
132 | {
|
---|
133 | if (first == second)
|
---|
134 | {
|
---|
135 | return true;
|
---|
136 | }
|
---|
137 |
|
---|
138 | var firstParts = first.split(".");
|
---|
139 | var secondParts = second.split(".");
|
---|
140 |
|
---|
141 | if (firstParts.length >= secondParts.length)
|
---|
142 | {
|
---|
143 | return false;
|
---|
144 | }
|
---|
145 |
|
---|
146 | for (var i = 0; i < firstParts.length; i++)
|
---|
147 | {
|
---|
148 | if (!firstParts[i].equals(secondParts[i]))
|
---|
149 | {
|
---|
150 | return false;
|
---|
151 | }
|
---|
152 | }
|
---|
153 |
|
---|
154 | return true;
|
---|
155 | }
|
---|
156 |
|
---|
157 | //public static String oidDocumentRoot(String oid)
|
---|
158 | function oidDocumentRoot(oid)
|
---|
159 | {
|
---|
160 | var oidParts = oid.split("\\.");
|
---|
161 |
|
---|
162 | return oidParts[0];
|
---|
163 | }
|
---|
164 |
|
---|
165 |
|
---|
166 |
|
---|
167 | //public static String hashToSectionId(String hashString)
|
---|
168 | function hashToSectionId(hashString)
|
---|
169 | {
|
---|
170 | if (hashString == null || hashString.length == 0)
|
---|
171 | {
|
---|
172 | return "";
|
---|
173 | }
|
---|
174 |
|
---|
175 | var firstDotIndex = hashString.indexOf(".");
|
---|
176 | if (firstDotIndex == -1)
|
---|
177 | {
|
---|
178 | return "";
|
---|
179 | }
|
---|
180 |
|
---|
181 | var sectionString = hashString.substring(firstDotIndex + 1);
|
---|
182 |
|
---|
183 | return sectionString;
|
---|
184 | }
|
---|
185 |
|
---|
186 | //public static String hashToDepthClass(hashString)
|
---|
187 | function hashToDepthClass(hashString)
|
---|
188 | {
|
---|
189 | if (hashString == null || hashString.length == 0)
|
---|
190 | {
|
---|
191 | return "";
|
---|
192 | }
|
---|
193 |
|
---|
194 | var sectionString = hashToSectionId(hashString);
|
---|
195 |
|
---|
196 | var count = sectionString.split("\\.").length;
|
---|
197 |
|
---|
198 | if (sectionString == "")
|
---|
199 | {
|
---|
200 | return "sectionHeaderDepthTitle";
|
---|
201 | }
|
---|
202 | else
|
---|
203 | {
|
---|
204 | return "sectionHeaderDepth" + count;
|
---|
205 | }
|
---|
206 | }
|
---|
207 |
|
---|
208 | //alert("hashToDepthClass(\"HASH134B.1\")=" + hashToDepthClass("HASH134B.1"));
|
---|
209 | //alert("hashToSectionId(\"HASH134B.1\")=" + hashToSectionId("HASH134B.1"));
|
---|
210 |
|
---|
211 | //alert(getInterfaceTextSubstituteArgs("test {0} test {1} test" ,"1;2"));
|
---|
212 | //alert(getNumberedItem("item0,item1,item2" ,1));
|
---|