author | Eugene Ostroukhov <eugeneo@symbian.org> |
Fri, 09 Apr 2010 11:42:56 -0700 | |
changeset 301 | a908b05787d1 |
parent 273 | b1f63c2c240c |
permissions | -rw-r--r-- |
37
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
1 |
/* |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
2 |
xml2json v 1.1 |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
3 |
copyright 2005-2007 Thomas Frank |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
4 |
|
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
5 |
This program is free software under the terms of the |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
6 |
GNU General Public License version 2 as published by the Free |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
7 |
Software Foundation. It is distributed without any warranty. |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
8 |
*/ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
9 |
|
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
10 |
var xml2json={ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
11 |
parser:function(xmlcode,ignoretags,debug){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
12 |
if(!ignoretags){ignoretags=""}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
13 |
xmlcode=xmlcode.replace(/\s*\/>/g,'/>'); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
14 |
xmlcode=xmlcode.replace(/<\?[^>]*>/g,"").replace(/<\![^>]*>/g,""); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
15 |
if (!ignoretags.sort){ignoretags=ignoretags.split(",")}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
16 |
var x=this.no_fast_endings(xmlcode); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
17 |
x=this.attris_to_tags(x); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
18 |
x=escape(x); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
19 |
x=x.split("%3C").join("<").split("%3E").join(">").split("%3D").join("=").split("%22").join("\""); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
20 |
for (var i=0;i<ignoretags.length;i++){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
21 |
x=x.replace(new RegExp("<"+ignoretags[i]+">","g"),"*$**"+ignoretags[i]+"**$*"); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
22 |
x=x.replace(new RegExp("</"+ignoretags[i]+">","g"),"*$***"+ignoretags[i]+"**$*") |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
23 |
}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
24 |
x='<JSONTAGWRAPPER>'+x+'</JSONTAGWRAPPER>'; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
25 |
this.xmlobject={}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
26 |
var y=this.xml_to_object(x).jsontagwrapper; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
27 |
if(debug){y=this.show_json_structure(y,debug)}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
28 |
return y |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
29 |
}, |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
30 |
xml_to_object:function(xmlcode){ |
210
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
37
diff
changeset
|
31 |
var x=xmlcode.replace(/<\//g,"�"); |
37
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
32 |
x=x.split("<"); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
33 |
var y=[]; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
34 |
var level=0; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
35 |
var opentags=[]; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
36 |
for (var i=1;i<x.length;i++){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
37 |
var tagname=x[i].split(">")[0]; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
38 |
opentags.push(tagname); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
39 |
level++ |
210
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
37
diff
changeset
|
40 |
y.push(level+"<"+x[i].split("�")[0]); |
0f7abfd6ae62
Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents:
37
diff
changeset
|
41 |
while(x[i].indexOf("�"+opentags[opentags.length-1]+">")>=0){level--;opentags.pop()} |
37
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
42 |
}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
43 |
var oldniva=-1; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
44 |
var objname="this.xmlobject"; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
45 |
for (var i=0;i<y.length;i++){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
46 |
var preeval=""; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
47 |
var niva=y[i].split("<")[0]; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
48 |
var tagnamn=y[i].split("<")[1].split(">")[0]; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
49 |
tagnamn=tagnamn.toLowerCase(); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
50 |
var rest=y[i].split(">")[1]; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
51 |
if(niva<=oldniva){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
52 |
var tabort=oldniva-niva+1; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
53 |
for (var j=0;j<tabort;j++){objname=objname.substring(0,objname.lastIndexOf("."))} |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
54 |
}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
55 |
objname+="."+tagnamn; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
56 |
var pobject=objname.substring(0,objname.lastIndexOf(".")); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
57 |
if (eval("typeof "+pobject) != "object"){preeval+=pobject+"={value:"+pobject+"};\n"}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
58 |
var objlast=objname.substring(objname.lastIndexOf(".")+1); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
59 |
var already=false; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
60 |
for (k in eval(pobject)){if(k==objlast){already=true}}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
61 |
var onlywhites=true; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
62 |
for(var s=0;s<rest.length;s+=3){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
63 |
if(rest.charAt(s)!="%"){onlywhites=false} |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
64 |
}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
65 |
if (rest!="" && !onlywhites){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
66 |
if(rest/1!=rest){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
67 |
rest="'"+rest.replace(/\'/g,"\\'")+"'"; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
68 |
rest=rest.replace(/\*\$\*\*\*/g,"</"); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
69 |
rest=rest.replace(/\*\$\*\*/g,"<"); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
70 |
rest=rest.replace(/\*\*\$\*/g,">") |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
71 |
} |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
72 |
} |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
73 |
else {rest="{}"}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
74 |
if(rest.charAt(0)=="'"){rest='unescape('+rest+')'}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
75 |
if (already && !eval(objname+".sort")){preeval+=objname+"=["+objname+"];\n"}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
76 |
var before="=";after=""; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
77 |
if (already){before=".push(";after=")"}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
78 |
var toeval=preeval+objname+before+rest+after; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
79 |
eval(toeval); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
80 |
if(eval(objname+".sort")){objname+="["+eval(objname+".length-1")+"]"}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
81 |
oldniva=niva |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
82 |
}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
83 |
return this.xmlobject |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
84 |
}, |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
85 |
show_json_structure:function(obj,debug,l){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
86 |
var x=''; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
87 |
if (obj.sort){x+="[\n"} else {x+="{\n"}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
88 |
for (var i in obj){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
89 |
if (!obj.sort){x+=i+":"}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
90 |
if (typeof obj[i] == "object"){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
91 |
x+=this.show_json_structure(obj[i],false,1) |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
92 |
} |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
93 |
else { |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
94 |
if(typeof obj[i]=="function"){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
95 |
var v=obj[i]+""; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
96 |
//v=v.replace(/\t/g,""); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
97 |
x+=v |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
98 |
} |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
99 |
else if(typeof obj[i]!="string"){x+=obj[i]+",\n"} |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
100 |
else {x+="'"+obj[i].replace(/\'/g,"\\'").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r")+"',\n"} |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
101 |
} |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
102 |
}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
103 |
if (obj.sort){x+="],\n"} else {x+="},\n"}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
104 |
if (!l){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
105 |
x=x.substring(0,x.lastIndexOf(",")); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
106 |
x=x.replace(new RegExp(",\n}","g"),"\n}"); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
107 |
x=x.replace(new RegExp(",\n]","g"),"\n]"); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
108 |
var y=x.split("\n");x=""; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
109 |
var lvl=0; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
110 |
for (var i=0;i<y.length;i++){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
111 |
if(y[i].indexOf("}")>=0 || y[i].indexOf("]")>=0){lvl--}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
112 |
tabs="";for(var j=0;j<lvl;j++){tabs+="\t"}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
113 |
x+=tabs+y[i]+"\n"; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
114 |
if(y[i].indexOf("{")>=0 || y[i].indexOf("[")>=0){lvl++} |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
115 |
}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
116 |
if(debug=="html"){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
117 |
x=x.replace(/</g,"<").replace(/>/g,">"); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
118 |
x=x.replace(/\n/g,"<BR>").replace(/\t/g," ") |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
119 |
}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
120 |
if (debug=="compact"){x=x.replace(/\n/g,"").replace(/\t/g,"")} |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
121 |
}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
122 |
return x |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
123 |
}, |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
124 |
no_fast_endings:function(x){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
125 |
x=x.split("/>"); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
126 |
for (var i=1;i<x.length;i++){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
127 |
var t=x[i-1].substring(x[i-1].lastIndexOf("<")+1).split(" ")[0]; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
128 |
x[i]="></"+t+">"+x[i] |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
129 |
} ; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
130 |
x=x.join(""); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
131 |
return x |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
132 |
}, |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
133 |
attris_to_tags: function(x){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
134 |
var d=' ="\''.split(""); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
135 |
x=x.split(">"); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
136 |
for (var i=0;i<x.length;i++){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
137 |
var temp=x[i].split("<"); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
138 |
for (var r=0;r<4;r++){temp[0]=temp[0].replace(new RegExp(d[r],"g"),"_jsonconvtemp"+r+"_")}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
139 |
if(temp[1]){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
140 |
temp[1]=temp[1].replace(/'/g,'"'); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
141 |
temp[1]=temp[1].split('"'); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
142 |
for (var j=1;j<temp[1].length;j+=2){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
143 |
for (var r=0;r<4;r++){temp[1][j]=temp[1][j].replace(new RegExp(d[r],"g"),"_jsonconvtemp"+r+"_")} |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
144 |
}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
145 |
temp[1]=temp[1].join('"') |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
146 |
}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
147 |
x[i]=temp.join("<") |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
148 |
}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
149 |
x=x.join(">"); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
150 |
x=x.replace(/ ([^=]*)=([^ |>]*)/g,"><$1>$2</$1"); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
151 |
x=x.replace(/>"/g,">").replace(/"</g,"<"); |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
152 |
for (var r=0;r<4;r++){x=x.replace(new RegExp("_jsonconvtemp"+r+"_","g"),d[r])} ; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
153 |
return x |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
154 |
} |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
155 |
}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
156 |
|
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
157 |
|
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
158 |
if(!Array.prototype.push){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
159 |
Array.prototype.push=function(x){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
160 |
this[this.length]=x; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
161 |
return true |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
162 |
} |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
163 |
}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
164 |
|
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
165 |
if (!Array.prototype.pop){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
166 |
Array.prototype.pop=function(){ |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
167 |
var response = this[this.length-1]; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
168 |
this.length--; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
169 |
return response |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
170 |
} |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
171 |
}; |
641b65b14318
Added WRT previewer, Mozilla Xulrunner, and Mozilla XP Com. Integrated Xulrunner browser into WRT Previewer.
tasneems@symbian.org
parents:
diff
changeset
|
172 |