Commit 7e3fb173bc60a771351a0d12954dff0b7240d5e8
- Diff rendering mode:
- inline
- side by side
ffext/alipi.xpi
(219 / 249)
Binary files differ
ffext/chrome/content/overlay.js
(39 / 61)
  | |||
56 | 56 | } | |
57 | 57 | }; | |
58 | 58 | xhr.open("POST","http://x.a11y.in/alipi/menu",true); | |
59 | // xhr.open("POST","http://192.168.1.5/menu",true); | ||
60 | 59 | xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); | |
61 | 60 | xhr.send(String(content.window.location.href)); | |
62 | 61 | } | |
… | … | ||
77 | 77 | for (j=0; j<v.length; j++) { | |
78 | 78 | c = v[0].appendChild(a); | |
79 | 79 | c.setAttribute("src","http://x.a11y.in/alipi/wsgi/page_edit.js"); | |
80 | // c.setAttribute("src","http://192.168.1.5/page_edit.js"); | ||
81 | 80 | c.setAttribute("type","text/javascript"); | |
82 | 81 | } | |
83 | 82 | }, | |
… | … | ||
168 | 168 | { | |
169 | 169 | if(xhr.readyState == 4) | |
170 | 170 | { | |
171 | if(xhr.responseText == "None") | ||
171 | if(xhr.responseText == "empty") | ||
172 | 172 | { | |
173 | 173 | a11ypi.clearMenu(); | |
174 | 174 | } | |
… | … | ||
228 | 228 | ///content.window.location = "http://localhost/replace?url="+url+"&lang="+e.getAttribute("value"); | |
229 | 229 | //content.window.reload(); | |
230 | 230 | }, | |
231 | evaluate: function(path,newContent){ | ||
231 | 232 | ||
232 | // getNarration: function() { | ||
233 | // var doc = content.document; | ||
234 | // //we get the selections | ||
235 | // var selection = content.window.getSelection(); | ||
236 | // var str = ''; | ||
237 | // var currentNode = selection.getRangeAt(0).commonAncestorContainer; | ||
238 | // var xpath = a11ypi.getxPath(currentNode); | ||
239 | |||
240 | // var xhr = new XMLHttpRequest(); | ||
241 | // var url = content.window.location; | ||
242 | // var data="url="+encodeURIComponent(url)+"&xpath="+encodeURIComponent(xpath); | ||
233 | //evaluate the path | ||
243 | 234 | ||
244 | // xhr.onreadystatechange = function() | ||
245 | // { | ||
246 | // if(xhr.readyState == 4) | ||
247 | // { | ||
248 | // if(xhr.responseText =='empty') | ||
249 | // { | ||
250 | // alert("There is no re-narration available for this element!"); | ||
251 | // } | ||
252 | // else | ||
253 | // { | ||
254 | // //alert(xhr.responseText); | ||
255 | // d ={} | ||
256 | // var response=xhr.responseText.substring(3).split('###'); | ||
257 | // for (var j= 0; j< response.length ; j++){ | ||
258 | // chunk = response[j].substring(1).split('&'); | ||
259 | |||
260 | // for (var i= 0; i< chunk.length ; i++){ | ||
261 | // pair =chunk[i].split("::"); | ||
262 | // key = pair[0]; | ||
263 | // value = pair[1]; | ||
264 | // d[key] = value; | ||
265 | // } | ||
266 | // path = d['xpath']; | ||
267 | // data = d['data']; | ||
268 | // alert(path+'\n'+data); | ||
269 | // } | ||
270 | // } | ||
271 | // } | ||
272 | // } | ||
273 | |||
274 | // xhr.open("POST","http://localhost/narration",true); | ||
275 | // xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); | ||
276 | // xhr.send(data);// | ||
277 | |||
278 | // ///content.window.location = "http://localhost/replace?url="+url+"&lang="+e.getAttribute("value"); | ||
279 | // //content.window.reload(); | ||
280 | // }, | ||
235 | var nodes = content.document.evaluate(path, content.document, null, XPathResult.ANY_TYPE,null); | ||
281 | 236 | ||
282 | |||
283 | /* getURL: function(e) { | ||
284 | var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] //The service branch which handles the "Window". | ||
285 | .getService(Components.interfaces.nsIWindowMediator); | ||
286 | var recentWindow = wm.getMostRecentWindow("navigator:browser"); | ||
287 | recentWindow ? recentWindow.content.document.location : null; | ||
288 | var url = content.window.location; | ||
289 | content.window.location = "http://192.168.100.100/replace?url="+url+"&lang="+e.getAttribute("value"); | ||
290 | content.window.reload(); | ||
291 | },*/ | ||
237 | try{ | ||
238 | |||
239 | var result = nodes.iterateNext(); | ||
240 | |||
241 | while (result) | ||
242 | |||
243 | { | ||
244 | |||
245 | if (result.nameTag == "img" || result.nameTag =='IMG'){ | ||
246 | |||
247 | result.setAttribute('src',newContent); | ||
248 | |||
249 | } | ||
250 | |||
251 | else{ | ||
252 | |||
253 | result.textContent = newContent; | ||
254 | |||
255 | } | ||
256 | |||
257 | result=nodes.iterateNext(); | ||
258 | |||
259 | } | ||
260 | |||
261 | } | ||
262 | |||
263 | catch (e) | ||
264 | |||
265 | { | ||
266 | |||
267 | dump( 'error: Document tree modified during iteration ' + e ); | ||
268 | |||
269 | } | ||
270 | |||
271 | }, | ||
292 | 272 | }; | |
293 | 273 | window.addEventListener("load", function () { a11ypi.onLoad(); }, false);gBrowser.addEventListener("DOMContentLoaded", a11ypi.test, false); |