Commit 137dbb2d345c7720466ad351aa9b1e7ed8ba1e5a
- Diff rendering mode:
- inline
- side by side
server/ui.js
(242 / 241)
  | |||
4 | 4 | elementTagName: " ", | |
5 | 5 | elementId: " ", | |
6 | 6 | flag : 0, | |
7 | showlinks : 0, | ||
8 | showbox : 0, | ||
9 | blog_flag : false, | ||
7 | 10 | testContext : function() | |
8 | 11 | { | |
9 | 12 | ||
10 | $(document).ready(function(){$('body *').contents().filter(function() | ||
11 | { | ||
12 | //console.log(this.nodeName); | ||
13 | try{ | ||
14 | if(this.nodeType == 3) | ||
15 | { | ||
16 | return (this.nodeType == 3) && this.nodeValue.match(/\S/);}} | ||
17 | catch(err) | ||
18 | { | ||
19 | // console.log(err.message); | ||
20 | // console.log(this); | ||
21 | }}).wrap('<span m4pageedittype=text/>')}); | ||
13 | $(document).ready(function(){$('body *').contents().filter(function() | ||
14 | { | ||
15 | try{ | ||
16 | if(this.nodeType == 3) | ||
17 | { | ||
18 | return (this.nodeType == 3) && this.nodeValue.match(/\S/);}} | ||
19 | catch(err) | ||
20 | { | ||
21 | }}).wrap('<span m4pageedittype=text/>')}); | ||
22 | 22 | ||
23 | 23 | ||
24 | 24 | vimg = document.getElementsByTagName('img'); | |
25 | 25 | for(i=0; i<vimg.length; i++) | |
26 | { | ||
27 | vimg[i].setAttribute('m4pageedittype','image'); | ||
28 | } | ||
29 | |||
30 | var v = document.getElementsByTagName("body"); | ||
31 | // var a = document.createElement("script"); | ||
32 | // a.setAttribute("src","http://dev.a11y.in/alipi/wsgi/page_edit.js"); | ||
33 | // // a.setAttribute("src","http://localhost/alipi-1/server/wsgi/page_edit.js"); | ||
34 | // a.setAttribute("type","text/javascript"); | ||
35 | // v[0].appendChild(a); | ||
36 | var alltags = document.getElementsByTagName('*'); | ||
37 | for (x=0; x<alltags.length; x++) { | ||
38 | if (alltags[x].id == 'ren_overlay' || alltags[x].id == 'overlay1' ) { | ||
39 | v[0].removeChild(document.getElementById('ren_overlay')); | ||
40 | v[0].removeChild(document.getElementById('overlay1')); | ||
26 | { | ||
27 | vimg[i].setAttribute('m4pageedittype','image'); | ||
41 | 28 | } | |
42 | } | ||
43 | v[0].removeChild(document.getElementById('overlay2')); | ||
29 | |||
44 | 30 | }, | |
45 | 31 | ||
46 | 32 | createMenu: function(menu_list) { | |
47 | var xyz = document.getElementById("menu-button"); | ||
33 | var xyz = document.getElementById("show-box"); | ||
34 | xyz.innerHTML = ""; | ||
48 | 35 | for(var i=0;i<menu_list.length;i++) | |
49 | { | ||
50 | var newel = document.createElement("option"); | ||
51 | newel.textContent = menu_list[i]; | ||
52 | newel.setAttribute("value",menu_list[i]); | ||
53 | newel.setAttribute("onclick","a11ypi.getURL(event.target);"); | ||
54 | xyz.appendChild(newel); | ||
55 | } | ||
56 | }, | ||
57 | clearMenu: function() { | ||
58 | var xyz = document.getElementById("menu-button"); | ||
59 | while(null!= xyz.firstChild) | ||
60 | { | ||
61 | xyz.removeChild(xyz.firstChild); | ||
62 | } | ||
63 | }, | ||
64 | ajax: function() { | ||
65 | if(a11ypi.flag == '0') | ||
66 | { | ||
67 | a11ypi.flag = 1; | ||
68 | var xhr = new XMLHttpRequest(); | ||
69 | xhr.onreadystatechange = function() | ||
70 | 36 | { | |
71 | if(xhr.readyState == 4) | ||
72 | { | ||
73 | if(xhr.responseText == "empty") | ||
74 | { | ||
75 | a11ypi.clearMenu(); | ||
76 | } | ||
77 | else | ||
78 | { | ||
79 | a11ypi.createMenu(JSON.parse(xhr.responseText)); | ||
80 | } | ||
81 | } | ||
37 | var para = document.createElement("p"); | ||
38 | var newel = document.createElement("a"); | ||
39 | newel.textContent = menu_list[i]; | ||
40 | newel.setAttribute("href", "http://y.a11y.in/web?foruri="+encodeURIComponent(window.location.href)+"&lang="+menu_list[i]+"&interactive=1"); | ||
41 | para.appendChild(newel); | ||
42 | xyz.appendChild(para); | ||
82 | 43 | } | |
83 | xhr.open("POST","http://localhost/menu",true); | ||
84 | xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); | ||
85 | d = window.location.search.split('?')[1]; | ||
86 | var a =[]; | ||
87 | for (var i = 0;i<d.split('&').length;i++){ | ||
88 | a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1]; | ||
89 | } | ||
90 | var url = a['foruri']; | ||
91 | xhr.send('url='+url); | ||
92 | } | ||
93 | 44 | }, | |
94 | 45 | ajax1: function() { | |
95 | if(a11ypi.flag == '0') | ||
46 | var xhr = new XMLHttpRequest(); | ||
47 | xhr.onreadystatechange = function() | ||
96 | 48 | { | |
97 | a11ypi.flag = 1; | ||
98 | var xhr = new XMLHttpRequest(); | ||
99 | xhr.onreadystatechange = function() | ||
100 | { | ||
101 | if(xhr.readyState == 4) | ||
49 | if(xhr.readyState == 4) | ||
102 | 50 | { | |
103 | 51 | if(xhr.responseText == "empty") | |
104 | { | ||
105 | a11ypi.clearMenu(); | ||
106 | } | ||
52 | { } | ||
107 | 53 | else | |
108 | { | ||
109 | a11ypi.createMenuFilter(JSON.parse(xhr.responseText)); | ||
110 | } | ||
54 | { | ||
55 | document.getElementById("see-narration").disabled = false; | ||
56 | document.getElementById("blog-filter").disabled = false; | ||
57 | document.getElementById("go").disabled = false; | ||
58 | a11ypi.showbox = JSON.parse(xhr.responseText); | ||
59 | } | ||
111 | 60 | } | |
112 | } | ||
113 | xhr.open("POST","http://localhost/menu",true); | ||
114 | xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); | ||
115 | d = window.location.search.split('?')[1]; | ||
116 | var a =[]; | ||
117 | for (var i = 0;i<d.split('&').length;i++){ | ||
118 | a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1]; | ||
119 | } | ||
120 | var url = a['foruri']; | ||
121 | var option = a['blog']; | ||
122 | data = 'url='+url+'&option='+option; | ||
123 | xhr.send(data) ; | ||
124 | 61 | } | |
62 | xhr.open("POST","http://y.a11y.in/menu",true); | ||
63 | xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); | ||
64 | xhr.send('url='+encodeURIComponent(window.location.href)) ; | ||
125 | 65 | }, | |
126 | |||
127 | getURL: function(e) { | ||
128 | window.location = window.location.href + "&lang=" + e.value; | ||
129 | window.reload(); | ||
66 | createDomainMenu: function() { | ||
67 | var xyz = document.getElementById("show-links"); | ||
68 | xyz.innerHTML = ""; | ||
69 | menu_list = a11ypi.showlinks; | ||
70 | for(var i=0; i<menu_list.length;i++) | ||
71 | { | ||
72 | var para = document.createElement("p"); | ||
73 | var newel = document.createElement("a"); | ||
74 | newel.textContent = menu_list[i]; | ||
75 | newel.setAttribute("href", menu_list[i]); | ||
76 | para.appendChild(newel); | ||
77 | xyz.appendChild(para); | ||
78 | } | ||
79 | $('a').hover( | ||
80 | function() { | ||
81 | var xhr = new XMLHttpRequest(); | ||
82 | xhr.onreadystatechange = function() | ||
83 | { | ||
84 | if(xhr.readyState == 4) | ||
85 | { | ||
86 | if(xhr.responseText == "empty") | ||
87 | { } | ||
88 | else | ||
89 | { | ||
90 | menu_list = JSON.parse(xhr.responseText); | ||
91 | for(i=0; i<menu_list.length; i++) { | ||
92 | x = document.createElement('span'); | ||
93 | x.setAttribute('style', 'padding:15px;'); | ||
94 | x.textContent = menu_list[i]; | ||
95 | document.getElementById('show-links').appendChild(x); | ||
96 | } | ||
97 | $('span').tooltip(); | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | xhr.open("POST","http://y.a11y.in/menu",true); | ||
102 | xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); | ||
103 | xhr.send('url='+encodeURIComponent($(this).attr('href'))) ; | ||
104 | }, | ||
105 | function () {$('#show-links').find("span").remove();} | ||
106 | ); | ||
130 | 107 | }, | |
131 | ren: function() | ||
132 | { | ||
108 | |||
109 | ajaxLinks1: function() { | ||
133 | 110 | var xhr = new XMLHttpRequest(); | |
134 | 111 | xhr.onreadystatechange = function() | |
135 | 112 | { | |
136 | 113 | if(xhr.readyState == 4) | |
137 | { | ||
138 | if(xhr.responseText =='empty') | ||
139 | 114 | { | |
140 | a11ypi.clearMenu(); | ||
141 | alert("An internal server error occured, please try later."); | ||
142 | } | ||
143 | else | ||
144 | { | ||
145 | |||
146 | d ={}; | ||
147 | var response=xhr.responseText.substring(3).split('###'); | ||
148 | for (var j= 0; j< response.length ; j++){ | ||
149 | chunk = response[j].substring(1).split('&'); | ||
150 | |||
151 | for (var i= 0; i< chunk.length ; i++){ | ||
152 | pair =chunk[i].split("::"); | ||
153 | key = pair[0]; | ||
154 | value = pair[1]; | ||
155 | d[key] = value; | ||
115 | if(xhr.responseText == "empty") | ||
116 | { } | ||
117 | else | ||
118 | { | ||
119 | document.getElementById("see-links").disabled = false; | ||
120 | a11ypi.showlinks = JSON.parse(xhr.responseText); | ||
156 | 121 | } | |
157 | path = d['xpath']; | ||
158 | newContent = d['data']; | ||
159 | elementType = d['elementtype']; | ||
160 | a11ypi.evaluate(path,newContent,elementType); | ||
161 | } | ||
162 | 122 | } | |
163 | } | ||
164 | 123 | } | |
165 | d = window.location.search.split('?')[1]; | ||
166 | var a =[]; | ||
167 | for (var i = 0;i<d.split('&').length;i++){ | ||
168 | a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1]; | ||
169 | } | ||
170 | var url = a['foruri']; | ||
171 | var lang= a['lang']; | ||
172 | var data="url="+url+"&lang="+encodeURIComponent(lang); | ||
173 | |||
174 | xhr.open("POST","http://localhost/replace",true); | ||
124 | xhr.open("POST","http://y.a11y.in/domain",true); | ||
175 | 125 | xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); | |
176 | xhr.send(data);// | ||
126 | xhr.send('url='+encodeURIComponent(window.location.hostname)); | ||
177 | 127 | }, | |
178 | evaluate: function() | ||
179 | { | ||
180 | try{ | ||
181 | var nodes = document.evaluate(path, document, null, XPathResult.ANY_TYPE,null); | ||
182 | } | ||
183 | catch(e) | ||
184 | { | ||
185 | console.log(e); | ||
186 | } | ||
187 | try{ | ||
188 | var result = nodes.iterateNext(); | ||
189 | while (result) | ||
190 | { | ||
191 | if (elementType == 'image') | ||
192 | { | ||
193 | result.setAttribute('src',newContent.split(',')[1]); //A hack to display images properly, the size has been saved in the database. | ||
194 | width = newContent.split(',')[0].split('x')[0]; | ||
195 | height = newContent.split(',')[0].split('x')[1]; | ||
196 | result.setAttribute('width',width); | ||
197 | result.setAttribute('height', height); | ||
198 | } | ||
199 | else if(elementType =='audio/ogg') | ||
200 | { | ||
201 | newContent = decodeURIComponent(newContent); | ||
202 | audio = '<audio controls="controls" src="'+newContent+'"></audio>'; | ||
203 | $(result).before(audio); | ||
204 | } | ||
205 | else{ | ||
206 | result.textContent = newContent; | ||
207 | } | ||
208 | result=nodes.iterateNext(); | ||
209 | } | ||
210 | } | ||
211 | catch (e) | ||
212 | { | ||
213 | dump( 'error: Document tree modified during iteration ' + e ); | ||
214 | } | ||
128 | |||
129 | |||
130 | |||
131 | |||
132 | editPage: function() { | ||
133 | a11ypi.testContext(); page_edit_nele('4seiz', '4l85060vb9', '336e2nootv6nxjsvyjov', 'VISUAL', 'false', ''); | ||
134 | document.getElementById("renarrated_overlay").style.display = "none"; | ||
215 | 135 | }, | |
216 | close: function() { | ||
217 | document.getElementById('ren_overlay').style.display = 'none'; | ||
136 | |||
137 | showBox: function() { | ||
138 | $(function() { | ||
139 | $( "#show-box" ).dialog( "destroy" ); | ||
140 | |||
141 | $( "#show-box" ).dialog({ | ||
142 | width: 300, | ||
143 | height: 300, | ||
144 | modal: true | ||
145 | }); | ||
146 | }); | ||
147 | a11ypi.createMenu(a11ypi.showbox); | ||
218 | 148 | }, | |
219 | filter: function() | ||
220 | { | ||
149 | |||
150 | showBox1: function() { | ||
151 | $(function() { | ||
152 | $( "#show-links" ).dialog( "destroy" ); | ||
153 | |||
154 | $( "#show-links" ).dialog({ | ||
155 | width: 500, | ||
156 | height: 300, | ||
157 | modal: true | ||
158 | }); | ||
159 | }); | ||
160 | a11ypi.createDomainMenu(); | ||
161 | }, | ||
162 | |||
163 | blogFilter: function() { | ||
164 | if (a11ypi.blog_flag == false) { | ||
165 | a11ypi.blog_flag = true; | ||
221 | 166 | var xhr = new XMLHttpRequest(); | |
222 | 167 | xhr.onreadystatechange = function() | |
223 | 168 | { | |
224 | 169 | if(xhr.readyState == 4) | |
225 | { | ||
226 | if(xhr.responseText =='empty') | ||
227 | 170 | { | |
228 | a11ypi.clearMenu(); | ||
229 | alert("An internal server error occured, please try later."); | ||
230 | } | ||
171 | if(xhr.responseText == "empty") | ||
172 | { } | ||
231 | 173 | else | |
232 | { | ||
233 | |||
234 | d ={}; | ||
235 | var response=xhr.responseText.substring(3).split('###'); | ||
236 | for (var j= 0; j< response.length ; j++){ | ||
237 | chunk = response[j].substring(1).split('&'); | ||
238 | |||
239 | for (var i= 0; i< chunk.length ; i++){ | ||
240 | pair =chunk[i].split("::"); | ||
241 | key = pair[0]; | ||
242 | value = pair[1]; | ||
243 | d[key] = value; | ||
174 | { | ||
175 | var sel = document.getElementById("blog-filter"); | ||
176 | var menu_list = JSON.parse(xhr.responseText); | ||
177 | blogArray = []; | ||
178 | for (var i=0; i< menu_list.length; i++) | ||
179 | { | ||
180 | blogArray[i] = menu_list[i].split("http://")[1].split(".com")[0] + ".com"; | ||
181 | } | ||
182 | blogArray.sort(); | ||
183 | for (var i=0; i < blogArray.length; i++) | ||
184 | { | ||
185 | if ( i == 0 ) | ||
186 | { | ||
187 | opt = document.createElement("option"); | ||
188 | opt.textContent = blogArray[0]; | ||
189 | sel.appendChild(opt); | ||
190 | } | ||
191 | else if(blogArray[i] == blogArray[i-1]) | ||
192 | { } | ||
193 | else | ||
194 | { | ||
195 | opt = document.createElement("option"); | ||
196 | opt.textContent = blogArray[i]; | ||
197 | sel.appendChild(opt); | ||
198 | } | ||
199 | } | ||
244 | 200 | } | |
245 | path = d['xpath']; | ||
246 | newContent = d['data']; | ||
247 | a11ypi.evaluate(path,newContent); | ||
248 | } | ||
249 | 201 | } | |
250 | } | ||
251 | 202 | } | |
252 | d = window.location.search.split('?')[1]; | ||
253 | var a =[]; | ||
254 | for (var i = 0;i<d.split('&').length;i++){ | ||
255 | a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1]; | ||
256 | } | ||
257 | var url = a['foruri']; | ||
258 | var lang= a['lang']; | ||
259 | var blog= a['blog']; | ||
260 | var data="url="+encodeURIComponent(url)+"&lang="+encodeURIComponent(lang)+"&blog="+encodeURIComponent(blog); | ||
261 | |||
262 | xhr.open("POST","http://localhost/filter",true); | ||
203 | xhr.open("POST","http://y.a11y.in/blog",true); | ||
263 | 204 | xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); | |
264 | xhr.send(data);// | ||
265 | }, | ||
266 | createMenuFilter: function(menu_list) { | ||
267 | var xyz = document.getElementById("menu-button"); | ||
268 | for(var i in menu_list) | ||
269 | { | ||
270 | var newel = document.createElement("option"); | ||
271 | newel.textContent = menu_list[i]; | ||
272 | newel.setAttribute("value",menu_list[i]); | ||
273 | newel.setAttribute("onclick","a11ypi.getURLFilter(event.target);"); | ||
274 | xyz.appendChild(newel); | ||
205 | xhr.send('url='+encodeURIComponent(window.location.href)); | ||
275 | 206 | } | |
276 | 207 | }, | |
277 | clearMenuFilter: function() { | ||
278 | var xyz = document.getElementById("menu-button"); | ||
279 | while(null!= xyz.firstChild) | ||
280 | { | ||
281 | xyz.removeChild(xyz.firstChild); | ||
208 | go: function() { | ||
209 | if (document.getElementById("blog-filter").value == "Choose a blog name") | ||
210 | { } | ||
211 | else { | ||
212 | window.open("http://y.a11y.in/web?foruri=" + encodeURIComponent(window.location.href) + "&blog=" + document.getElementById("blog-filter").value); | ||
282 | 213 | } | |
283 | 214 | }, | |
284 | getURLFilter: function(e) { | ||
285 | window.location = window.location.href + "&lang=" + e.value+"&interactive=1"; | ||
286 | window.reload(); | ||
287 | }, | ||
288 | 215 | ||
289 | checkbox: function() { | ||
290 | // alert("hi"); | ||
291 | if(document.getElementById("our-check").checked == false) { | ||
292 | document.getElementById("our-check").checked = true; | ||
293 | document.getElementById("your-check").checked = false; | ||
294 | } else { | ||
295 | document.getElementById("our-check").checked = false; | ||
296 | document.getElementById("your-check").checked = true; | ||
297 | } | ||
298 | }, | ||
216 | loadOverlay: function() { | ||
217 | |||
218 | body = document.body; | ||
219 | |||
220 | jq = document.createElement("script"); | ||
221 | jq.setAttribute("type", "text/javascript"); | ||
222 | jq.setAttribute("src", "http://code.jquery.com/jquery-1.7.min.js"); | ||
223 | body.appendChild(jq); | ||
224 | |||
225 | jqlink = document.createElement("link"); | ||
226 | jqlink.setAttribute("rel", "stylesheet"); | ||
227 | jqlink.setAttribute("type", "text/css"); | ||
228 | jqlink.setAttribute("href", "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/ui-lightness/jquery-ui.css"); | ||
229 | body.appendChild(jqlink); | ||
230 | |||
231 | jscript = document.createElement("script"); | ||
232 | jscript.setAttribute("type", "text/javascript"); | ||
233 | jscript.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"); | ||
234 | body.appendChild(jscript); | ||
235 | |||
236 | overlay = document.createElement("div"); | ||
237 | overlay.setAttribute("id", "renarrated_overlay"); | ||
238 | overlay.setAttribute("class", "ui-widget-header ui-corner-all"); | ||
239 | overlay.setAttribute("style", "position:fixed;top:0;width:80%;align:center;text-align:center;"); | ||
240 | body.appendChild(overlay); | ||
241 | |||
242 | show_box = document.createElement("div"); | ||
243 | show_box.setAttribute("id", "show-box"); | ||
244 | show_box.title = "Please choose one of the languages"; | ||
245 | body.appendChild(show_box); | ||
246 | |||
247 | show_links = document.createElement("div"); | ||
248 | show_links.setAttribute("id", "show-links"); | ||
249 | show_links.title = "Please choose one of the links"; | ||
250 | body.appendChild(show_links); | ||
251 | |||
252 | edit_current = document.createElement("input"); | ||
253 | edit_current.setAttribute("id", "edit-current"); | ||
254 | edit_current.setAttribute("type", "submit"); | ||
255 | edit_current.setAttribute("onclick", "a11ypi.editPage();"); | ||
256 | edit_current.setAttribute("value", "Re-narrate this page"); | ||
257 | overlay.appendChild(edit_current); | ||
258 | |||
259 | see_narration = document.createElement("input"); | ||
260 | see_narration.setAttribute("id", "see-narration"); | ||
261 | see_narration.setAttribute("type", "submit"); | ||
262 | see_narration.setAttribute("onclick", "a11ypi.showBox();"); | ||
263 | see_narration.setAttribute("value", "See other narrations"); | ||
264 | see_narration.disabled = true; | ||
265 | overlay.appendChild(see_narration); | ||
266 | a11ypi.ajax1(); | ||
267 | |||
268 | see_links = document.createElement("input"); | ||
269 | see_links.setAttribute("id", "see-links"); | ||
270 | see_links.setAttribute("type", "submit"); | ||
271 | see_links.setAttribute("onclick", "a11ypi.showBox1();"); | ||
272 | see_links.setAttribute("value", "Directory of narrations"); | ||
273 | see_links.disabled = true; | ||
274 | overlay.appendChild(see_links); | ||
275 | a11ypi.ajaxLinks1(); | ||
276 | |||
277 | blog_filter = document.createElement("select"); | ||
278 | blog_filter.setAttribute("id", "blog-filter"); | ||
279 | blog_filter.setAttribute("style", "min-width:200px;max-width:200px;"); | ||
280 | blog_filter.setAttribute("onclick", "a11ypi.blogFilter();"); | ||
281 | blog_option = document.createElement("option"); | ||
282 | blog_option.textContent = "Choose a blog name"; | ||
283 | blog_filter.appendChild(blog_option); | ||
284 | blog_filter.disabled = true; | ||
285 | overlay.appendChild(blog_filter); | ||
286 | |||
287 | go = document.createElement("input"); | ||
288 | go.setAttribute("id", "go"); | ||
289 | go.setAttribute("type", "submit"); | ||
290 | go.setAttribute("onclick", "a11ypi.go();"); | ||
291 | go.setAttribute("value", "Go"); | ||
292 | go.disabled = true; | ||
293 | overlay.appendChild(go); | ||
294 | }, | ||
295 | |||
299 | 296 | }; | |
297 | |||
298 | if (window.location.hostname != "y.a11y.in") { | ||
299 | $(document).load(a11ypi.loadOverlay()); | ||
300 | } |
server/wsgi/page_edit.js
(37 / 36)
  | |||
1 | 1 | function page_edit( boltSlug, pageSlug, uploadSlug, editMode, hasEditPermission, successUrl) | |
2 | 2 | { | |
3 | 3 | ||
4 | var console, PopupControl, M4ImageElement,locName='',langName = '',styleName='',authorValue; | ||
4 | var console, PopupControl, M4ImageElement,locName='',langName = '',styleName='',authorValue,locSel='',langSel=''; | ||
5 | 5 | var editAttributes, elementAttributes, fontTypeAttributes, normalFontAttributes, popupContainerAttributes, editButtonAttributes, editTextInputAttributes, editSubmitAttributes, editTitleAttributes, panelButtonAttributes, buttonPanelAttributes, actionPanelAttributes, closeButtonAttributes, actionButtonAttributes, redButtonAttributes, leftBorderStyle, rightBorderStyle, titleButtonImageAttributes, titleButtonDisplayTextAttributes, actionButtonImageAttributes, actionButtonDisplayTextAttributes,greyArrowAttributes, pageEditor, splashWindow, loadingTimerId, keepOriginal = false; | |
6 | 6 | ||
7 | 7 | /** | |
… | … | ||
47 | 47 | buffer.push(string); | |
48 | 48 | return this; | |
49 | 49 | }; | |
50 | |||
50 | console.log("inside buffer"); | ||
51 | console.log(buffer); | ||
51 | 52 | this.toString = function toString() { | |
52 | 53 | return buffer.join(''); | |
53 | 54 | }; | |
… | … | ||
1808 | 1808 | overlayBar.blogpost(); | |
1809 | 1809 | } | |
1810 | 1810 | }, | |
1811 | close: function() { | ||
1811 | close: function() { | ||
1812 | 1812 | $( "#targetoverlay" ).hide(); | |
1813 | 1813 | }, | |
1814 | 1814 | }); | |
1815 | //$('.ui-dialog').hover(function() { | ||
1816 | // $(this).animate({ | ||
1817 | // width: '700px' | ||
1818 | // }, 300); | ||
1819 | // },function() { | ||
1820 | // $(this).animate({ | ||
1821 | // width: '500px' | ||
1822 | // }, 300); | ||
1823 | // }); | ||
1824 | 1815 | }); | |
1825 | |||
1816 | |||
1826 | 1817 | $("#loc-bt").click(function () { | |
1827 | 1818 | if(document.getElementById('loc-bt').value == '+'){ | |
1828 | 1819 | //remove input field and create a combo box | |
1829 | 1820 | $('#loc-select').hide(); | |
1830 | //var suggst = ['Srilanka','su','sa']; | ||
1821 | var def_loc = ['Srilanka','Colombo','Moratuwa']; | ||
1831 | 1822 | locSel= document.createElement("select"); | |
1832 | 1823 | locSel.setAttribute("id","loct-select"); | |
1833 | 1824 | locSel.setAttribute("type","text"); | |
1834 | 1825 | locSel.setAttribute("alipielements", "alipi"); | |
1835 | 1826 | locSel.setAttribute("style","position:absolute;top:5%;left:40%;width:250px;"); | |
1836 | for(i=0;i<client_json.def_loc.length;i++){ | ||
1827 | for(i=0;i<def_loc.length;i++){ | ||
1837 | 1828 | locopt = document.createElement("option"); | |
1838 | theText=document.createTextNode(suggst[i]); | ||
1829 | theText=document.createTextNode(def_loc[i]); | ||
1839 | 1830 | locopt.appendChild(theText); | |
1840 | 1831 | locSel.appendChild(locopt); | |
1841 | 1832 | } | |
… | … | ||
1849 | 1849 | if(document.getElementById('lang-bt').value == '+'){ | |
1850 | 1850 | //remove input field and create a combo box | |
1851 | 1851 | $('#lang-select').hide(); | |
1852 | //var suggst = ['Srilanka','su','sa']; | ||
1852 | var def_lang = ['Sinhala','Tamil','English']; | ||
1853 | 1853 | langSel= document.createElement("select"); | |
1854 | 1854 | langSel.setAttribute("id","langs-select"); | |
1855 | 1855 | langSel.setAttribute("type","text"); | |
1856 | 1856 | langSel.setAttribute("alipielements", "alipi"); | |
1857 | 1857 | langSel.setAttribute("style","position:absolute;top:25%;left:40%;width:250px;"); | |
1858 | for(i=0;i<client_json.def_lang.length;i++){ | ||
1858 | for(i=0;i<def_lang.length;i++){ | ||
1859 | 1859 | langopt = document.createElement("option"); | |
1860 | theText=document.createTextNode(client_json.def_lang[i]); | ||
1860 | theText=document.createTextNode(def_lang[i]); | ||
1861 | 1861 | langopt.appendChild(theText); | |
1862 | 1862 | langSel.appendChild(langopt); | |
1863 | 1863 | } | |
… | … | ||
2960 | 2960 | overlayDiv = document.createElement("div"); | |
2961 | 2961 | overlayDiv.setAttribute("id", "overlay-div"); | |
2962 | 2962 | overlayDiv.setAttribute("alipielements", "alipi"); | |
2963 | overlayDiv.setAttribute("style", "overflow:inherit; overflow-x:visible; position:fixed; z-index:2147483645; left:0; top:0; min-width:800px; width:100%; height:30px; background-color:rgba(0, 0, 0, 0.5);"); | ||
2963 | overlayDiv.setAttribute("style", "position:fixed; z-index:1001; left:0; top:0; min-width:800px; width:100%; height:30px; background-color:rgba(0, 0, 0, 0.5);"); | ||
2964 | 2964 | document.body.appendChild(overlayDiv); | |
2965 | 2965 | ||
2966 | 2966 | ||
… | … | ||
2968 | 2968 | image.setAttribute("id", "close-image"); | |
2969 | 2969 | image.setAttribute("alipielements", "alipi"); | |
2970 | 2970 | image.setAttribute("src", "http://dev.a11y.in/alipi/images/close_button.png"); | |
2971 | image.setAttribute("style", "position:relative;width:25px;height:28px;"); | ||
2971 | image.setAttribute("style", "position:fixed;left:1px;width:25px;height:28px;"); | ||
2972 | 2972 | overlayDiv.appendChild(image); | |
2973 | 2973 | image.onclick=function(){ | |
2974 | 2974 | answer = confirm("Do you really want to exit the editor?") | |
… | … | ||
2982 | 2982 | messageDiv = document.createElement("div"); | |
2983 | 2983 | messageDiv.setAttribute("id", "message-div"); | |
2984 | 2984 | messageDiv.setAttribute("alipielements", "alipi"); | |
2985 | messageDiv.setAttribute("style", "position:relative;left:150px;bottom:26px;font-size:23px;font-weight:bold;color:#ffe;"); | ||
2985 | messageDiv.setAttribute("style", "position:fixed;left:10%;top:0;font-size:23px;font-weight:bold;color:#ffe;"); | ||
2986 | 2986 | overlayDiv.appendChild(messageDiv); | |
2987 | 2987 | ||
2988 | 2988 | helpLink = document.createElement("input"); | |
… | … | ||
2990 | 2990 | helpLink.setAttribute("alipielements", "alipi"); | |
2991 | 2991 | helpLink.setAttribute("type", "submit"); | |
2992 | 2992 | helpLink.setAttribute("Value", "Help"); | |
2993 | helpLink.setAttribute("style", "position:relative;top:-55px;left:750px;font-size:18px;font-weight:bold;width:100px;height:30px;"); | ||
2993 | helpLink.setAttribute("style", "position:fixed;top:0;right:35%;font-size:18px;font-weight:bold;width:100px;height:30px;"); | ||
2994 | 2994 | overlayDiv.appendChild(helpLink); | |
2995 | 2995 | helpLink.onclick = function helpLinkOnClick() { | |
2996 | 2996 | helpWindow = new HelpWindow(pageEditor); | |
… | … | ||
3005 | 3005 | undoButton.setAttribute("alipielements", "alipi"); | |
3006 | 3006 | undoButton.setAttribute("type", "submit"); | |
3007 | 3007 | undoButton.setAttribute("Value", "Undo"); | |
3008 | undoButton.setAttribute("style", "position:relative;top:-55px;left:825px;font-size:18px;font-weight:bold;width:100px;height:30px;"); | ||
3008 | undoButton.setAttribute("style", "position:fixed;top:0;right:20%;font-size:18px;font-weight:bold;width:100px;height:30px;"); | ||
3009 | 3009 | overlayDiv.appendChild(undoButton); | |
3010 | 3010 | undoButton.onclick = function undoButtonOnClick() { | |
3011 | 3011 | pageEditor.commandUndo(); | |
… | … | ||
3018 | 3018 | publishButton.setAttribute("alipielements", "alipi"); | |
3019 | 3019 | publishButton.setAttribute("type", "submit"); | |
3020 | 3020 | publishButton.setAttribute("Value", "Publish"); | |
3021 | publishButton.setAttribute("style", "position:relative;top:-55px;left:900px;font-size:18px;font-weight:bold;width:100px;height:30px;"); | ||
3021 | publishButton.setAttribute("style", "position:fixed;top:0;right:5%;font-size:18px;font-weight:bold;width:100px;height:30px;"); | ||
3022 | 3022 | overlayDiv.appendChild(publishButton); | |
3023 | 3023 | var dialog = 0; | |
3024 | 3024 | publishButton.onclick = function publishButtonOnClick() { | |
… | … | ||
3037 | 3037 | ||
3038 | 3038 | ||
3039 | 3039 | this.blogpost = function blogpost() { | |
3040 | if (locName.value == "" || langName.value == "" || styleSelect.value == "" || author.value == "" || (ourcheck.checked == false && yourcheck.checked == false)) { | ||
3040 | console.log("locSel.value"); | ||
3041 | console.log(locSel.value); | ||
3042 | console.log("langSel.value"); | ||
3043 | console.log(langSel.value); | ||
3044 | if (styleSelect.value == "" || author.value == "" ||(ourcheck.checked == false && yourcheck.checked == false) || locName.value == "" && document.getElementById('loct-select') === null || langName.value == "" && document.getElementById('langs-select') === null){ | ||
3041 | 3045 | alert("Please give all the details, it will be used further"); | |
3042 | } else { | ||
3046 | } else { | ||
3043 | 3047 | pageEditor.commandPublish(); | |
3044 | 3048 | pageEditor.showMessage("... Please wait, your blog is being posted"); | |
3045 | 3049 | $('#targetoverlay').remove(); | |
… | … | ||
3052 | 3052 | // End of okButton function | |
3053 | 3053 | ||
3054 | 3054 | this.show = function show(activate) { | |
3055 | // overlayDiv.style.display = 'block'; | ||
3056 | 3055 | var disabled = true; | |
3057 | 3056 | var opacity = '0.4'; | |
3058 | 3057 | if (activate) { | |
… | … | ||
3156 | 3156 | switch (event.keyCode) { | |
3157 | 3157 | case 27: | |
3158 | 3158 | // ESC | |
3159 | event.preventDefault(); | ||
3160 | event.stopPropagation(); | ||
3161 | pageEditor.close(); | ||
3162 | return false; | ||
3159 | // event.preventDefault(); | ||
3160 | // event.stopPropagation(); | ||
3161 | // pageEditor.close(); | ||
3162 | // return false; | ||
3163 | 3163 | // case 77: | |
3164 | 3164 | // // "m" | |
3165 | 3165 | // if (pageEditor.hasFocus()) { | |
… | … | ||
3354 | 3354 | ||
3355 | 3355 | this.publish = function publish() { | |
3356 | 3356 | var result; | |
3357 | if(document.getElementById('our-check').checked) | ||
3357 | if(document.getElementById('your-check').checked && window.location.hostname !='y.a11y.in') | ||
3358 | 3358 | { | |
3359 | 3359 | localStorage.myContent = buildDataString(); | |
3360 | 3360 | window.location.href = "http://localhost/test.html"; | |
… | … | ||
3418 | 3418 | buffer.append('about='); //url=about //removed '&' on purpose | |
3419 | 3419 | buffer.append(window.location.search.split('=')[1]); | |
3420 | 3420 | buffer.append('&lang=');//lang | |
3421 | buffer.append(encodeURIComponent(langName.value)); | ||
3421 | if (langName.value != "") | ||
3422 | buffer.append(encodeURIComponent(langName.value)); | ||
3423 | else | ||
3424 | buffer.append(encodeURIComponent(langSel.value)); | ||
3422 | 3425 | buffer.append('&location=');//location | |
3423 | buffer.append(encodeURIComponent(locName.value)); | ||
3426 | if (locName.value != "") | ||
3427 | buffer.append(encodeURIComponent(locName.value)); | ||
3428 | else | ||
3429 | buffer.append(encodeURIComponent(locSel.value)); | ||
3424 | 3430 | buffer.append('&style=');//style | |
3425 | 3431 | buffer.append(encodeURIComponent(styleSelect.value)); | |
3426 | 3432 | buffer.append('&blog='); //blog where to post | |
… | … | ||
3527 | 3527 | // passthrough | |
3528 | 3528 | } else if (event.target.getAttribute('m4pageedittype')) { | |
3529 | 3529 | // passthrough | |
3530 | } else if (event.target.id == "lang-select" || event.target.id == "loc-select" || alipiElements) { | ||
3530 | } else if (event.target.id == "lang-select" || event.target.id == "loc-select" || event.target.id == "loc-bt" || event.target.id == "lang-bt" || alipiElements) { | ||
3531 | 3531 | // passthrough | |
3532 | 3532 | } else if (event.clientX > document.body.clientWidth || event.clientY > document.body.clientHeight) { | |
3533 | 3533 | // passthrough if this click was outside of the html page, meaning on a scrollbar |