-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.js
More file actions
79 lines (68 loc) · 2.01 KB
/
common.js
File metadata and controls
79 lines (68 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//file xml close
function fileXmlClose(fxml,snomore,n){
if (snomore !== "") fxml.WriteLine(snomore + '</n>');
while (n>0) {
fxml.Write( '</n>');
n--;
}
fxml.WriteLine('</tree>');
fxml.Close();
}
//file xml start
function fileXmlStart(fxml){
fxml.WriteLine('<?xml version="1.0" encoding="'+sCharset+'"?>');
fxml.WriteLine('<?xml-stylesheet href="view.xsl" type="text/xsl"?>');
fxml.WriteLine('<tree b="root">');
}
//Wrap string to line
function WrapLine(s,flagWrap,flagWrapMin){
var i,flag;
var line = "";
while ((s.length) > flagWrap) {
i = flagWrap;
flag = true;
while (flag&&(i>flagWrapMin)) {
if (" -(\\/<,|[{".indexOf(s.charAt(i),0)>=0) flag = false;
else i--;
}
if (i == flagWrapMin) i = flagWrap;
line = line + s.substr(0,i) + '\x0D\x0A';
s = s.substr(i);}
line = line + s;
return(line);
}
//text2xmltext
function XmlFormat(s) {
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\x22/g, """).replace(/\x27/g, "'").replace(/\x5C/g, "\\\\");
}
//text2xmlattrtextNoSlash
function XmlAttrFormatNoSlash(s) {
return s.replace(/\x5C/g, "\\\\");
}
//text2xmlattrtext
function XmlAttrFormat(s) {
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\x22/g, """).replace(/\x27/g, "'");
}
function skipWhite(str) {
iStr = 0;
while ((iStr<str.length) && ((str.charAt(iStr)==" ")||(str.charAt(iStr)==" "))) iStr++;
return iStr
}
function isCapLetter(ch) {
return (((ch >= "A") && (ch <= "Z")) || ((ch >= "À") && (ch <= "ß")))
}
function isDigit(ch) {
return (((ch >= "0") && (ch <= "9")))
}
function IsEmpty(str) {
iStr=0;
while ((iStr<str.length)&&((str.charAt(iStr) == " ")||(str.charAt(iStr) == " "))) iStr++;
return (iStr == str.length);
}
function Words(str) {
i1=0;
while ((i1<str.length)&&((str.charAt(i1) == " ")||(str.charAt(i1) == " "))) i1++;
i2=str.length;
while ((i2>0)&&((str.charAt(i2) == " ")||(str.charAt(i2) == " "))) i2--;
return str.substr(i1,i2-i1);
}