1 | |
---|
2 | var tagstyles=new TextField.StyleSheet(); |
---|
3 | tagstyles.load("/potlatch/tags.css?d=3"); |
---|
4 | |
---|
5 | // Open the tagfinder dialogue |
---|
6 | |
---|
7 | function openTagFinder() { |
---|
8 | _root.panel.properties.enableTabs(false); |
---|
9 | _root.windows.attachMovie("modal","tf",++windowdepth); |
---|
10 | _root.windows.tf.init(300, 110, [iText('cancel'), iText('ok')], createTagWindow); |
---|
11 | |
---|
12 | _root.windows.tf.addHeadline("z1",iText('tags_findatag')); |
---|
13 | _root.windows.tf.addText("z2",iText('tags_typesearchterm')); |
---|
14 | _root.windows.tf.addTextEntry("comment","",20); |
---|
15 | |
---|
16 | _root.tfswallowed=false; |
---|
17 | _root.windows.tf.box.comment.onChanged=function() { |
---|
18 | fixUTF8(); |
---|
19 | if (_root.windows.tf.box.comment.text.toUpperCase()=='F' && !_root.tfswallowed ) { _root.windows.tf.box.comment.text=''; } |
---|
20 | _root.tfswallowed=true; |
---|
21 | }; |
---|
22 | } |
---|
23 | |
---|
24 | // Create the tag window |
---|
25 | |
---|
26 | function createTagWindow(button) { |
---|
27 | if (button!=iText('ok') || !_root.windows.tf.box.comment.text) { return false; } |
---|
28 | _root.tagsearch=_root.windows.tf.box.comment.text; |
---|
29 | |
---|
30 | _root.tagtable=[]; |
---|
31 | createHelpWindow(500,350); |
---|
32 | _root.help.createTextField("headline",5,10,10,480,30); |
---|
33 | with (_root.help.headline) { setNewTextFormat(yellowHead); wordWrap=true; selectable=false; type='dynamic'; } |
---|
34 | |
---|
35 | if (tagsearch.indexOf('=')>0) { |
---|
36 | var c=tagsearch.split('='); |
---|
37 | beginMoreDetails(c[0],c[1]); |
---|
38 | } else { |
---|
39 | beginTagTable(); |
---|
40 | var tagdoc=new XML(); |
---|
41 | tagdoc.load("http://tagstat.hypercube.telascience.org/xmlsearch.php?action=fulltext_fast&key="+tagsearch); |
---|
42 | tagdoc.onLoad=function() { createTagTable(this); writeTagTable(); }; |
---|
43 | } |
---|
44 | } |
---|
45 | |
---|
46 | // Parse XML and create the table of tags |
---|
47 | |
---|
48 | function createTagTable(doc) { |
---|
49 | var level1=doc.childNodes; |
---|
50 | for (i=0; i<level1.length; i+=1) { |
---|
51 | if (level1[i].nodeName=='search') { |
---|
52 | var level2=level1[i].childNodes; |
---|
53 | for (j=0; j<level2.length; j+=1) { |
---|
54 | if (level2[j].nodeName=='results') { |
---|
55 | |
---|
56 | var level3=level2[j].childNodes; |
---|
57 | for (k=0; k<level3.length; k+=1) { |
---|
58 | if (level3[k].nodeName=='result') { |
---|
59 | |
---|
60 | // Read values into hash |
---|
61 | var o=[]; |
---|
62 | var level4=level3[k].childNodes; |
---|
63 | for (l=0; l<level4.length; l+=1) { |
---|
64 | if (level4[l].nodeName) { o[level4[l].nodeName]=level4[l].firstChild.nodeValue; } |
---|
65 | } |
---|
66 | |
---|
67 | // Add to tag table |
---|
68 | tagtable.push([o['tag'],o['value'],Number(o['total']),o['onway'],o['onnode'],o['onrelation']]); |
---|
69 | } |
---|
70 | } |
---|
71 | } |
---|
72 | } |
---|
73 | } |
---|
74 | } |
---|
75 | tagtable.sortOn(2,18); |
---|
76 | } |
---|
77 | |
---|
78 | // Write the table of tags |
---|
79 | |
---|
80 | function beginTagTable() { |
---|
81 | _root.help.createTextField("tag",10,10,60,180,280); _root.help.tag.setNewTextFormat(plainWhite); _root.help.tag.selectable=false; _root.help.tag.text=iText('loading'); |
---|
82 | _root.help.headline.text=iText('tags_matching',_root.tagsearch); |
---|
83 | } |
---|
84 | |
---|
85 | function writeTagTable() { |
---|
86 | removeMovieClip(_root.help.returnlink); |
---|
87 | _root.help.createTextField("legend1",20,200,36,180,280); _root.help.legend1.setNewTextFormat(plainLight); _root.help.legend1.selectable=false; _root.help.legend1.text="Total"; |
---|
88 | _root.help.createTextField("legend2",21,260,36,180,280); _root.help.legend2.setNewTextFormat(plainLight); _root.help.legend2.selectable=false; _root.help.legend2.text="Ways"; |
---|
89 | _root.help.createTextField("legend3",22,320,36,180,280); _root.help.legend3.setNewTextFormat(plainLight); _root.help.legend3.selectable=false; _root.help.legend3.text="Nodes"; |
---|
90 | _root.help.createTextField("legend4",23,380,36,180,280); _root.help.legend4.setNewTextFormat(plainLight); _root.help.legend4.selectable=false; _root.help.legend4.text="Relations"; |
---|
91 | |
---|
92 | var y=60; |
---|
93 | _root.help.createTextField("tag" ,10,10 ,y,180,280); _root.help.tag.setNewTextFormat(plainWhite); _root.help.tag.selectable=false; |
---|
94 | _root.help.createTextField("total1",11,200,y,59 ,280) ; _root.help.total1.setNewTextFormat(plainWhite); _root.help.total1.selectable=false; |
---|
95 | _root.help.createTextField("total2",12,260,y,59 ,280) ; _root.help.total2.setNewTextFormat(plainWhite); _root.help.total2.selectable=false; |
---|
96 | _root.help.createTextField("total3",13,320,y,59 ,280) ; _root.help.total3.setNewTextFormat(plainWhite); _root.help.total3.selectable=false; |
---|
97 | _root.help.createTextField("total4",14,380,y,59 ,280) ; _root.help.total4.setNewTextFormat(plainWhite); _root.help.total4.selectable=false; |
---|
98 | _root.help.createTextField("more" ,15,440,y,40 ,280) ; _root.help.more.setNewTextFormat(moreText); _root.help.more.selectable=false; |
---|
99 | |
---|
100 | for (i=0; i<tagtable.length; i++) { |
---|
101 | _root.help.tag.text +=tagtable[i][0]+" = "+tagtable[i][1]+"\n"; |
---|
102 | _root.help.total1.text+=tagtable[i][2]+"\n"; |
---|
103 | _root.help.total2.text+=tagtable[i][3]+"\n"; |
---|
104 | _root.help.total3.text+=tagtable[i][4]+"\n"; |
---|
105 | _root.help.total4.text+=tagtable[i][5]+"\n"; |
---|
106 | _root.help.more.text +=iText('more')+"\n"; |
---|
107 | if (i==0) { _root.rowheight=_root.help.tag.textHeight; } // how tall is each row? |
---|
108 | } |
---|
109 | |
---|
110 | if (_root.help.tag.scroll<_root.help.tag.maxscroll) { |
---|
111 | _root.help.attachMovie("vertical","scrollbar",6); |
---|
112 | _root.help.scrollbar._x=480; _root.help.scrollbar._y=y; |
---|
113 | _root.help.scrollbar.init(280,_root.help.tag.maxscroll,30, |
---|
114 | function(n) { _root.help.tag.scroll= |
---|
115 | _root.help.total1.scroll= |
---|
116 | _root.help.total2.scroll= |
---|
117 | _root.help.total3.scroll= |
---|
118 | _root.help.total4.scroll= |
---|
119 | _root.help.more.scroll=Math.ceil(n); } |
---|
120 | ); |
---|
121 | } |
---|
122 | |
---|
123 | _root.help.bg.onPress=function() { |
---|
124 | var chosen=Math.floor((_root.help.tag._ymouse-4)/_root.rowheight)+_root.help.tag.scroll-1; |
---|
125 | if (_root.help.tag._xmouse>0 && _root.help.tag._xmouse<180) { |
---|
126 | _root.panel.properties.setTag(tagtable[chosen][0], tagtable[chosen][1]); |
---|
127 | _root.createEmptyMovieClip("help",0xFFFFFD); _root.createEmptyMovieClip("blank",0xFFFFFC); |
---|
128 | } else if (_root.help.more._xmouse>0 && _root.help.more._xmouse<50) { |
---|
129 | beginMoreDetails(tagtable[chosen][0], tagtable[chosen][1]); |
---|
130 | } |
---|
131 | }; |
---|
132 | } |
---|
133 | |
---|
134 | // Request 'more' from the server |
---|
135 | |
---|
136 | function beginMoreDetails(key,value) { |
---|
137 | removeMovieClip(_root.help.total1); removeMovieClip(_root.help.legend1); |
---|
138 | removeMovieClip(_root.help.total2); removeMovieClip(_root.help.legend2); |
---|
139 | removeMovieClip(_root.help.total3); removeMovieClip(_root.help.legend3); |
---|
140 | removeMovieClip(_root.help.total4); removeMovieClip(_root.help.legend4); |
---|
141 | removeMovieClip(_root.help.total5); removeMovieClip(_root.help.more); |
---|
142 | removeMovieClip(_root.help.scrollbar); removeMovieClip(_root.help.tag); |
---|
143 | |
---|
144 | _root.help.headline.text=iText('tags_descriptions',key+"="+value); |
---|
145 | _root.help.createTextField("tag",10,10,40,465,270); |
---|
146 | _root.help.tag.setNewTextFormat(plainWhite); _root.help.tag.selectable=false; |
---|
147 | _root.help.tag.text=iText('loading'); |
---|
148 | |
---|
149 | if (tagsearch.indexOf('=')<1) { |
---|
150 | _root.help.createTextField("returnlink",11,10,320,465,20); |
---|
151 | _root.help.returnlink.setNewTextFormat(moreText); _root.help.returnlink.selectable=false; |
---|
152 | _root.help.returnlink.text=iText('tags_backtolist'); |
---|
153 | _root.help.bg.onPress=function() { |
---|
154 | if (_root.help.bg._ymouse>=320 ) { beginTagTable(); writeTagTable(); } |
---|
155 | }; |
---|
156 | } |
---|
157 | |
---|
158 | var lv=new LoadVars(); |
---|
159 | lv.load("http://richard.dev.openstreetmap.org/cgi-bin/description.cgi?key="+key+"&value="+value); |
---|
160 | lv.onData=writeMoreDetails; |
---|
161 | } |
---|
162 | |
---|
163 | function writeMoreDetails(data) { |
---|
164 | with (_root.help.tag) { |
---|
165 | styleSheet=tagstyles; |
---|
166 | html=true; |
---|
167 | multiline=true; |
---|
168 | wordWrap=true; |
---|
169 | htmlText=data; |
---|
170 | } |
---|
171 | |
---|
172 | if (_root.help.tag.scroll<_root.help.tag.maxscroll) { |
---|
173 | _root.help.attachMovie("vertical","scrollbar",6); |
---|
174 | _root.help.scrollbar._x=480; _root.help.scrollbar._y=40; |
---|
175 | _root.help.scrollbar.init(270,_root.help.tag.maxscroll,30, |
---|
176 | function(n) { _root.help.tag.scroll=Math.ceil(n); } |
---|
177 | ); |
---|
178 | } |
---|
179 | } |
---|