Commit 5c80b835e27e5862a92fb49cefdf81423d968af1

  • avatar
  • arvind
  • Fri Jun 22 11:50:49 IST 2012
Adding .gitignore, config file for js.  Implemented a function for extracting params
  • Diff rendering mode:
  • inline
  • side by side

.gitignore

1*~
2*.pyc
3*.swp
4*.jpeg
5*.png
6*.gif
7google3998b23cc94c0027.html
8conf.py
9apis/
10Sanchaya/
11.#*
12logme
13config.js

server/alipi.py

99 script_test.set("type", "text/javascript")99 script_test.set("type", "text/javascript")
100 script_edit.set("src", conf.APPURL[0] + "/server/wsgi/pageEditor.js")100 script_edit.set("src", conf.APPURL[0] + "/server/wsgi/pageEditor.js")
101 script_edit.set("type","text/javascript")101 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
102 107
103 script_jq_mini = g.root.makeelement('script')108 script_jq_mini = g.root.makeelement('script')
104 g.root.body.append(script_jq_mini)109 g.root.body.append(script_jq_mini)

server/sampleConfig.js

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

36 createMenu: function(menu_list) {36 createMenu: function(menu_list) {
37 var xyz = document.getElementById("show-box");37 var xyz = document.getElementById("show-box");
38 xyz.innerHTML = '';38 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();
45 for(var i=0;i<menu_list.length;i++)40 for(var i=0;i<menu_list.length;i++)
46 {41 {
47 var para = document.createElement("p");42 var para = document.createElement("p");
48 var newel = document.createElement("a");43 var newel = document.createElement("a");
49 newel.textContent = menu_list[i];44 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");
51 para.appendChild(newel);46 para.appendChild(newel);
52 xyz.appendChild(para);47 xyz.appendChild(para);
53 }48 }
59 {59 {
60 if(xhr.responseText == "empty")60 if(xhr.responseText == "empty")
61 {61 {
62 a11ypi.clearMenu();
62 //a11ypi.clearMenu();
63 }63 }
64 else64 else
65 {65 {
70 }70 }
71 }71 }
72 }72 }
73 xhr.open("POST","http://dev.a11y.in/menu",true);
73 xhr.open("POST",config.root+"/menu",true);
74 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");74 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']};
84 $.getJSON('http://127.0.0.1:5000/info?', req, function(data)79 $.getJSON('http://127.0.0.1:5000/info?', req, function(data)
85 {
86 a11ypi.responseJSON = data;
87 });
80 {
81 a11ypi.responseJSON = data;
82 });
88 }83 }
89 },84 },
90 ajax1: function() {85 ajax1: function() {
93 {93 {
94 if(xhr.responseText == "empty")94 if(xhr.responseText == "empty")
95 {95 {
96 a11ypi.clearMenu();
96// a11ypi.clearMenu();
97 }97 }
98 else98 else
99 {99 {
101 }101 }
102 }102 }
103 }103 }
104 xhr.open("POST","http://dev.a11y.in/menu",true);
104 xhr.open("POST",config.root+"/menu",true);
105 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");105 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'];
114 xhr.send(data) ;108 xhr.send(data) ;
115 }109 }
116 },110 },
115 },115 },
116 ren: function()116 ren: function()
117 {117 {
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();
124 var url = decodeURIComponent(a['foruri']);119 var url = decodeURIComponent(a['foruri']);
125 var lang = a['lang'];120 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)
127 {122 {
128 for(var i=0;i<data['r'].length;i++)123 for(var i=0;i<data['r'].length;i++)
129 {124 {
188 {188 {
189 if(xhr.responseText =='empty')189 if(xhr.responseText =='empty')
190 {190 {
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.");
193 }193 }
194 else194 else
195 {195 {
213 }213 }
214 }214 }
215 }215 }
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();
221 var url = a['foruri'];217 var url = a['foruri'];
222 var lang= a['lang'];218 var lang= a['lang'];
223 var blog= a['blog'];219 var blog= a['blog'];
224 var data="url="+url+"&lang="+encodeURIComponent(lang)+"&blog="+encodeURIComponent(blog);220 var data="url="+url+"&lang="+encodeURIComponent(lang)+"&blog="+encodeURIComponent(blog);
225 221
226 xhr.open("POST","http://dev.a11y.in/filter",true);
222 xhr.open("POST",config.root+"/filter",true);
227 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");223 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
228 xhr.send(data);//224 xhr.send(data);//
229 },225 },
227 var xyz = document.getElementById("show-box");227 var xyz = document.getElementById("show-box");
228 xyz.innerHTML = '';228 xyz.innerHTML = '';
229 d = window.location.search.split('?')[1];229 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();
234 var page = a['foruri'];231 var page = a['foruri'];
235 var blog = a['blog'];232 var blog = a['blog'];
236 for(var i=0;i<menu_list.length;i++)233 for(var i=0;i<menu_list.length;i++)
235 var para = document.createElement("p");235 var para = document.createElement("p");
236 var newel = document.createElement("a");236 var newel = document.createElement("a");
237 newel.textContent = menu_list[i];237 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");
239 para.appendChild(newel);239 para.appendChild(newel);
240 xyz.appendChild(para);240 xyz.appendChild(para);
241 }241 }
248 }248 }
249 },249 },
250 getURLFilter: function(e) {250 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";
258 window.reload();253 window.reload();
259 },254 },
260 showOriginal: function(){255 showOriginal: function(){
424 $('#icon-up').attr('down', 'false');424 $('#icon-up').attr('down', 'false');
425 $('#icon-up').show(); $('#icon-down').hide();425 $('#icon-up').show(); $('#icon-down').hide();
426 $('#pub_overlay').addClass('barOnBottom'); $('#pub_overlay').removeClass('barOnTop');426 $('#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');
429 } else {427 } else {
430 $('#icon-up').attr('down', 'true');428 $('#icon-up').attr('down', 'true');
431 $('#icon-down').show(); $('#icon-up').hide();429 $('#icon-down').show(); $('#icon-up').hide();
432 $('#pub_overlay').addClass('barOnTop'); $('#pub_overlay').removeClass('barOnBottom');430 $('#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
435 }432 }
436 },433 },
437 434
451 source: function(req, add){451 source: function(req, add){
452452
453 //pass request to server453 //pass request to server
454 $.getJSON("http://dev.a11y.in/web//getLoc?", req, function(data) {
454 $.getJSON(config.deploy+"/getLoc?", req, function(data) {
455 $('#loc-img').hide();455 $('#loc-img').hide();
456456
457 //create array for response objects457 //create array for response objects
474 source: function(req, add){474 source: function(req, add){
475475
476 //pass request to server476 //pass request to server
477 $.getJSON("http://dev.a11y.in/web//getLang?", req, function(data) {
477 $.getJSON(config.deploy+"/getLang?", req, function(data) {
478 $('#lang-img').hide();478 $('#lang-img').hide();
479479
480 //create array for response objects480 //create array for response objects
597 }597 }
598 }598 }
599 }599 }
600 xhr.open("POST","http://dev.a11y.in/domain",true);
600 xhr.open("POST",config.root+"/domain",true);
601 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");601 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
602 d = window.location.search.split('?')[1];602 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();
607 xhr.send('url='+a['foruri'])604 xhr.send('url='+a['foruri'])
608 },605 },
609 showBox1: function() {606 showBox1: function() {
627 var para = document.createElement("p");627 var para = document.createElement("p");
628 var newel = document.createElement("a");628 var newel = document.createElement("a");
629 newel.textContent = menu_list[i];629 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]));
631 newel.setAttribute("class","alipiShowLink");631 newel.setAttribute("class","alipiShowLink");
632 para.appendChild(newel);632 para.appendChild(newel);
633 xyz.append(para);633 xyz.append(para);
656 }656 }
657 }657 }
658 }658 }
659 xhr.open("POST","http://dev.a11y.in/menu",true);
659 xhr.open("POST",config.root+"/menu",true);
660 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");660 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
661 xhr.send('url='+encodeURIComponent($(this).attr('href'))) ;661 xhr.send('url='+encodeURIComponent($(this).attr('href'))) ;
662 },662 },
689 }689 }
690 }690 }
691 }691 }
692 xhr.open("POST","http://dev.a11y.in/blog",true);
692 xhr.open("POST",config.root+"/blog",true);
693 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");693 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();
699 xhr.send('url='+a['foruri']);695 xhr.send('url='+a['foruri']);
700 }696 }
701 },697 },
703 if ($("#blog-filter").val() == null)703 if ($("#blog-filter").val() == null)
704 { }704 { }
705 else {705 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());
707 }707 }
708 },708 },
709 share: function() {709 share: function() {
718 },718 },
719 editPage: function() {719 editPage: function() {
720 a11ypi.testContext();720 a11ypi.testContext();
721// $('#icon_on_overlay').show(); $('#icon_on_overlay').addClass('barOnTop'); // When 1st time page entered in edit mode
722 $('#pub_overlay').show(); $('#pub_overlay').addClass('barOnTop'); 721 $('#pub_overlay').show(); $('#pub_overlay').addClass('barOnTop');
723 $('#icon-down').show();722 $('#icon-down').show();
724// $('#element_edit_overlay').addClass('barOnTop');
725 $('#renarrated_overlay').hide();723 $('#renarrated_overlay').hide();
726 // $(window).click(function(event){
727 // console.log(event);
728 // event.stopPropagation();
729 // event.preventDefault();
730 // });
731 $('body *').contents().filter(function(){724 $('body *').contents().filter(function(){
732 {725 {
733 try{726 try{
760 '<div id="reference" class="alipi" readonly="yes"></div>'+760 '<div id="reference" class="alipi" readonly="yes"></div>'+
761 '<textarea id="adv-reference" class="alipi" readonly="yes"></textarea> '+761 '<textarea id="adv-reference" class="alipi" readonly="yes"></textarea> '+
762 '<label id="edit-lab" class="alipi" style="left:53%;">Where you should edit (Editor)</label>'+762 '<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" '+
765 '</div>';764 '</div>';
766 $('body').append(template);765 $('body').append(template);
767 $('#pub_overlay').slideUp();766 $('#pub_overlay').slideUp();
768 $('#element_edit_overlay').hide(); 767 $('#element_edit_overlay').hide();
769// $('#icon_on_overlay').slideUp();
770768
771 var tag = pageEditor.event.target.nodeName;769 var tag = pageEditor.event.target.nodeName;
772 $(pageEditor.event.target).removeAttr('m4pageedittype');770 $(pageEditor.event.target).removeAttr('m4pageedittype');
775 $('#editor').html($(pageEditor.event.target).html());775 $('#editor').html($(pageEditor.event.target).html());
776 $("#adv-ref").button({icons:{primary:"ui-icon-script"},text:true}); $('#adv-ref').children().addClass('alipi');776 $("#adv-ref").button({icons:{primary:"ui-icon-script"},text:true}); $('#adv-ref').children().addClass('alipi');
777 $("#close-adv").button({icons:{primary:"ui-icon-bookmark"},text:true}); $('#close-adv').children().addClass('alipi');777 $("#close-adv").button({icons:{primary:"ui-icon-bookmark"},text:true}); $('#close-adv').children().addClass('alipi');
778 // $('#close-adv').button();
779 $('#close-adv').hide();778 $('#close-adv').hide();
780 $('#adv-ref').button();779 $('#adv-ref').button();
781780
861 861
862 reflectInReference: function() {862 reflectInReference: function() {
863 var tag = pageEditor.event.target.nodeName;863 var tag = pageEditor.event.target.nodeName;
864// $('#reference').text('<'+tag+'>'+$("#editor").html()+'</'+tag+'>');
865 $("#reference").html() = $("#editor").html();864 $("#reference").html() = $("#editor").html();
866 },865 },
867866
947 win.infoFullJSON = a11ypi.responseJSON;947 win.infoFullJSON = a11ypi.responseJSON;
948 win.onLoad();948 win.onLoad();
949 },949 },
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 }
950};967};