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 | function getNumberedItem(list, number)
|
---|
69 | {
|
---|
70 | var items = list.split(",");
|
---|
71 |
|
---|
72 | if (items.length > number)
|
---|
73 | {
|
---|
74 | return items[number];
|
---|
75 | }
|
---|
76 |
|
---|
77 | return ""; // index out of bounds
|
---|
78 | }
|
---|
79 |
|
---|
80 |
|
---|
81 | //alert(getInterfaceTextSubstituteArgs("test {0} test {1} test" ,"1;2"));
|
---|
82 | //alert(getNumberedItem("item0,item1,item2" ,1));
|
---|