Commit 5c80b835e27e5862a92fb49cefdf81423d968af1

  • avatar
  • arvind
  • Fri Jun 22 11:50:49 IST 2012
Adding .gitignore, config file for js.  Implemented a function for extracting params
.gitignore
(13 / 0)
  
1*~
2*.pyc
3*.swp
4*.jpeg
5*.png
6*.gif
7google3998b23cc94c0027.html
8conf.py
9apis/
10Sanchaya/
11.#*
12logme
13config.js
  
9999 script_test.set("type", "text/javascript")
100100 script_edit.set("src", conf.APPURL[0] + "/server/wsgi/pageEditor.js")
101101 script_edit.set("type","text/javascript")
102 script_config = g.root.makeelement('script')
103 g.root.body.append(script_config)
104 script_config.set("src", conf.APPURL[0] + "/server/config.js")
105 script_config.set("type", "text/javascript")
106
102107
103108 script_jq_mini = g.root.makeelement('script')
104109 g.root.body.append(script_jq_mini)
  
1//A sample configuration file for JS variables. Copy this file to "config.js"
2var config = {
3 'hostname': "127.0.0.1",
4 'deploy': "http://127.0.0.1:5000",
5 'root': "http://localhost"
6}
server/ui.js
(52 / 89)
  
3636 createMenu: function(menu_list) {
3737 var xyz = document.getElementById("show-box");
3838 xyz.innerHTML = '';
39 d = window.location.search.split('?')[1];
40 var a =[];
41 for (var i = 0;i<d.split('&').length;i++){
42 a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1];
43 }
44 var page = a['foruri'];
39 a = a11ypi.getParams();
4540 for(var i=0;i<menu_list.length;i++)
4641 {
4742 var para = document.createElement("p");
4843 var newel = document.createElement("a");
4944 newel.textContent = menu_list[i];
50 $(newel).attr("href","http://127.0.0.1:5000/?foruri="+page+"&lang="+menu_list[i]+"&interactive=1");
45 $(newel).attr("href",config.url+"/?foruri="+a['foruri']+"&lang="+menu_list[i]+"&interactive=1");
5146 para.appendChild(newel);
5247 xyz.appendChild(para);
5348 }
5959 {
6060 if(xhr.responseText == "empty")
6161 {
62 a11ypi.clearMenu();
62 //a11ypi.clearMenu();
6363 }
6464 else
6565 {
7070 }
7171 }
7272 }
73 xhr.open("POST","http://dev.a11y.in/menu",true);
73 xhr.open("POST",config.root+"/menu",true);
7474 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
75 d = window.location.search.split('?')[1];
76 var a =[];
77 for (var i = 0;i<d.split('&').length;i++){
78 a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1];
79 }
80 var url = a['foruri'];
81 xhr.send('url='+url);
75 a = a11ypi.getParams();
76 xhr.send('url='+a['foruri']);
8277
83 req = {"about":encodeURIComponent(decodeURIComponent(url)), "lang":a['lang']};
78 req = {"about":decodeURIComponent(a['foruri']), "lang":a['lang']};
8479 $.getJSON('http://127.0.0.1:5000/info?', req, function(data)
85 {
86 a11ypi.responseJSON = data;
87 });
80 {
81 a11ypi.responseJSON = data;
82 });
8883 }
8984 },
9085 ajax1: function() {
9393 {
9494 if(xhr.responseText == "empty")
9595 {
96 a11ypi.clearMenu();
96// a11ypi.clearMenu();
9797 }
9898 else
9999 {
101101 }
102102 }
103103 }
104 xhr.open("POST","http://dev.a11y.in/menu",true);
104 xhr.open("POST",config.root+"/menu",true);
105105 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
106 d = window.location.search.split('?')[1];
107 var a =[];
108 for (var i = 0;i<d.split('&').length;i++){
109 a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1];
110 }
111 var url = a['foruri'];
112 var option = a['blog'];
113 data = 'url='+url+'&option='+option;
106 a = a11ypi.getParams();
107 data = 'url='+a['foruri']+'&option='+a['blog'];
114108 xhr.send(data) ;
115109 }
116110 },
115115 },
116116 ren: function()
117117 {
118
119 d = window.location.search.split('?')[1];
120 var a =[];
121 for (var i = 0;i<d.split('&').length;i++){
122 a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1];
123 }
118 a = a11ypi.getParams();
124119 var url = decodeURIComponent(a['foruri']);
125120 var lang = a['lang'];
126 $.getJSON("http://dev.a11y.in/web/replace?",{"url":url,"lang":lang},function(data)
121 $.getJSON(config.deploy+"/replace?",{"url":url,"lang":lang},function(data)
127122 {
128123 for(var i=0;i<data['r'].length;i++)
129124 {
188188 {
189189 if(xhr.responseText =='empty')
190190 {
191 a11ypi.clearMenu();
192 alert("An internal server error occured, please try later.");
191// a11ypi.clearMenu();
192// alert("An internal server error occured, please try later.");
193193 }
194194 else
195195 {
213213 }
214214 }
215215 }
216 d = window.location.search.split('?')[1];
217 var a =[];
218 for (var i = 0;i<d.split('&').length;i++){
219 a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1];
220 }
216 a = a11ypi.getParams();
221217 var url = a['foruri'];
222218 var lang= a['lang'];
223219 var blog= a['blog'];
224220 var data="url="+url+"&lang="+encodeURIComponent(lang)+"&blog="+encodeURIComponent(blog);
225221
226 xhr.open("POST","http://dev.a11y.in/filter",true);
222 xhr.open("POST",config.root+"/filter",true);
227223 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
228224 xhr.send(data);//
229225 },
227227 var xyz = document.getElementById("show-box");
228228 xyz.innerHTML = '';
229229 d = window.location.search.split('?')[1];
230 var a =[];
231 for (var i = 0;i<d.split('&').length;i++){
232 a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1];
233 }
230 a = a11ypi.getParams();
234231 var page = a['foruri'];
235232 var blog = a['blog'];
236233 for(var i=0;i<menu_list.length;i++)
235235 var para = document.createElement("p");
236236 var newel = document.createElement("a");
237237 newel.textContent = menu_list[i];
238 $(newel).attr("href","http://dev.a11y.in/web/?foruri="+page+"&blog="+blog+"&lang="+menu_list[i]+"&interactive=1");
238 $(newel).attr("href",config.deploy+"/?foruri="+page+"&blog="+blog+"&lang="+menu_list[i]+"&interactive=1");
239239 para.appendChild(newel);
240240 xyz.appendChild(para);
241241 }
248248 }
249249 },
250250 getURLFilter: function(e) {
251 d = window.location.search.split('?')[1];
252 var a =[];
253 for (var i = 0;i<d.split('&').length;i++){
254 a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1];
255 }
256
257 window.location = "http://dev.a11y.in/web/?foruri="+a['foruri']+"&blog="+a['blog'] + "&lang=" + e.value+"&interactive=1";
251 a= a11ypi.getParams();
252 window.location = config.deploy+"/?foruri="+a['foruri']+"&blog="+a['blog'] + "&lang=" + e.value+"&interactive=1";
258253 window.reload();
259254 },
260255 showOriginal: function(){
424424 $('#icon-up').attr('down', 'false');
425425 $('#icon-up').show(); $('#icon-down').hide();
426426 $('#pub_overlay').addClass('barOnBottom'); $('#pub_overlay').removeClass('barOnTop');
427// $('#element_edit_overlay').addClass('barOnBottom'); $('#element_edit_overlay').removeClass('barOnTop');
428// $('#icon_on_overlay').addClass('barOnBottom'); $('#icon_on_overlay').removeClass('barOnTop');
429427 } else {
430428 $('#icon-up').attr('down', 'true');
431429 $('#icon-down').show(); $('#icon-up').hide();
432430 $('#pub_overlay').addClass('barOnTop'); $('#pub_overlay').removeClass('barOnBottom');
433// $('#element_edit_overlay').addClass('barOnTop'); $('#element_edit_overlay').removeClass('barOnBottom');
434// $('#icon_on_overlay').addClass('barOnTop'); $('#icon_on_overlay').removeClass('barOnBottom');
431
435432 }
436433 },
437434
451451 source: function(req, add){
452452
453453 //pass request to server
454 $.getJSON("http://dev.a11y.in/web//getLoc?", req, function(data) {
454 $.getJSON(config.deploy+"/getLoc?", req, function(data) {
455455 $('#loc-img').hide();
456456
457457 //create array for response objects
474474 source: function(req, add){
475475
476476 //pass request to server
477 $.getJSON("http://dev.a11y.in/web//getLang?", req, function(data) {
477 $.getJSON(config.deploy+"/getLang?", req, function(data) {
478478 $('#lang-img').hide();
479479
480480 //create array for response objects
597597 }
598598 }
599599 }
600 xhr.open("POST","http://dev.a11y.in/domain",true);
600 xhr.open("POST",config.root+"/domain",true);
601601 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
602602 d = window.location.search.split('?')[1];
603 var a =[];
604 for (var i = 0;i<d.split('&').length;i++){
605 a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1];
606 }
603 a = a11ypi.getParams();
607604 xhr.send('url='+a['foruri'])
608605 },
609606 showBox1: function() {
627627 var para = document.createElement("p");
628628 var newel = document.createElement("a");
629629 newel.textContent = menu_list[i];
630 newel.setAttribute("href", "http://dev.a11y.in/web/?foruri="+encodeURIComponent(menu_list[i]));
630 newel.setAttribute("href", config.deploy+"/?foruri="+encodeURIComponent(menu_list[i]));
631631 newel.setAttribute("class","alipiShowLink");
632632 para.appendChild(newel);
633633 xyz.append(para);
656656 }
657657 }
658658 }
659 xhr.open("POST","http://dev.a11y.in/menu",true);
659 xhr.open("POST",config.root+"/menu",true);
660660 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
661661 xhr.send('url='+encodeURIComponent($(this).attr('href'))) ;
662662 },
689689 }
690690 }
691691 }
692 xhr.open("POST","http://dev.a11y.in/blog",true);
692 xhr.open("POST",config.root+"/blog",true);
693693 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
694 d = window.location.search.split('?')[1];
695 var a =[];
696 for (var i = 0;i<d.split('&').length;i++){
697 a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1];
698 }
694 a = a11ypi.getParams();
699695 xhr.send('url='+a['foruri']);
700696 }
701697 },
703703 if ($("#blog-filter").val() == null)
704704 { }
705705 else {
706 window.open("http://dev.a11y.in/web/?foruri=" + a['foruri'] + "&blog=" + $("#blog-filter").val());
706 window.open(config.deploy+"/?foruri=" + a['foruri'] + "&blog=" + $("#blog-filter").val());
707707 }
708708 },
709709 share: function() {
718718 },
719719 editPage: function() {
720720 a11ypi.testContext();
721// $('#icon_on_overlay').show(); $('#icon_on_overlay').addClass('barOnTop'); // When 1st time page entered in edit mode
722721 $('#pub_overlay').show(); $('#pub_overlay').addClass('barOnTop');
723722 $('#icon-down').show();
724// $('#element_edit_overlay').addClass('barOnTop');
725723 $('#renarrated_overlay').hide();
726 // $(window).click(function(event){
727 // console.log(event);
728 // event.stopPropagation();
729 // event.preventDefault();
730 // });
731724 $('body *').contents().filter(function(){
732725 {
733726 try{
760760 '<div id="reference" class="alipi" readonly="yes"></div>'+
761761 '<textarea id="adv-reference" class="alipi" readonly="yes"></textarea> '+
762762 '<label id="edit-lab" class="alipi" style="left:53%;">Where you should edit (Editor)</label>'+
763 '<div id="editor" class="alipi" contenteditable="true" '+ // onkeyup="a11ypi.reflectInReference();">
764// '<div id="forPrevData" class="alipi"></div>'+
763 '<div id="editor" class="alipi" contenteditable="true" '+
765764 '</div>';
766765 $('body').append(template);
767766 $('#pub_overlay').slideUp();
768767 $('#element_edit_overlay').hide();
769// $('#icon_on_overlay').slideUp();
770768
771769 var tag = pageEditor.event.target.nodeName;
772770 $(pageEditor.event.target).removeAttr('m4pageedittype');
775775 $('#editor').html($(pageEditor.event.target).html());
776776 $("#adv-ref").button({icons:{primary:"ui-icon-script"},text:true}); $('#adv-ref').children().addClass('alipi');
777777 $("#close-adv").button({icons:{primary:"ui-icon-bookmark"},text:true}); $('#close-adv').children().addClass('alipi');
778 // $('#close-adv').button();
779778 $('#close-adv').hide();
780779 $('#adv-ref').button();
781780
861861
862862 reflectInReference: function() {
863863 var tag = pageEditor.event.target.nodeName;
864// $('#reference').text('<'+tag+'>'+$("#editor").html()+'</'+tag+'>');
865864 $("#reference").html() = $("#editor").html();
866865 },
867866
947947 win.infoFullJSON = a11ypi.responseJSON;
948948 win.onLoad();
949949 },
950 getParams: function()
951 {
952 var a = [];
953 if(window.location.hostname == config.hostname)
954 {
955 d = window.location.search.split('?')[1];
956 for (var i = 0;i<d.split('&').length;i++){
957 a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1];
958 }
959 return a;
960 }
961 else
962 {
963 a['foruri'] = window.location.href;
964 return a;
965 }
966 }
950967};