Changeset 30479
- Timestamp:
- 2016-04-20T22:57:50+12:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/xslt-util.js
r30468 r30479 66 66 } 67 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 68 115 function getNumberedItem(list, number) 69 116 { … … 78 125 } 79 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")); 80 210 81 211 //alert(getInterfaceTextSubstituteArgs("test {0} test {1} test" ,"1;2"));
Note:
See TracChangeset
for help on using the changeset viewer.