From: Danny Date: Wed, 19 Aug 2009 21:34:03 +0000 (+0200) Subject: * Insipid Firefox/Flock extension - Initial import X-Git-Tag: 2.1-alpha-2019-0-29~144 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=1aa1c4eb503fa7aeadbcf954c3c56ff916532c2e;p=insipid.git * Insipid Firefox/Flock extension - Initial import --- diff --git a/ff_ext/inspd@danny/chrome.manifest b/ff_ext/inspd@danny/chrome.manifest new file mode 100644 index 0000000..1ec8b50 --- /dev/null +++ b/ff_ext/inspd@danny/chrome.manifest @@ -0,0 +1,8 @@ +content inspd chrome/inspd/content/ +content inspd chrome/inspd/content/ contentaccessible=yes + +overlay chrome://browser/content/browser.xul chrome://inspd/content/inspdoverlay.xul + +skin inspd classic/1.0 chrome/inspd/skin/classic/ +style chrome://browser/content/browser.xul chrome://inspd/skin/inspd.css +style chrome://global/content/customizeToolbar.xul chrome://inspd/skin/inspd.css \ No newline at end of file diff --git a/ff_ext/inspd@danny/chrome/inspd/content/inc/globals.js b/ff_ext/inspd@danny/chrome/inspd/content/inc/globals.js new file mode 100644 index 0000000..3aa1462 --- /dev/null +++ b/ff_ext/inspd@danny/chrome/inspd/content/inc/globals.js @@ -0,0 +1,774 @@ +function $id(elid,doc){if(!doc){doc=document;} return doc.getElementById(elid); } +if(typeof(Insipid) == 'undefined') var Insipid = {}; +var Inspd_gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper); +var prefs_getBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); +var prefs_getservice = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService); +var $prefs = { + + set : function(pref_name, pref_value) { + var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); + str.data = $utils.trim(pref_value); + prefs_getBranch.setComplexValue('extensions.inspd.'+pref_name, Components.interfaces.nsISupportsString, str); + }, + + set2 : function(pref_name, pref_value) { + var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); + str.data = $utils.trim(pref_value); + prefs_getBranch.setComplexValue(pref_name, Components.interfaces.nsISupportsString, str); + }, + + + + get : function(pref_name){ + try{ + return prefs_getBranch.getComplexValue('extensions.inspd.'+pref_name,Components.interfaces.nsISupportsString).data; + } + catch(e){ return false;} + }, + + remove : function(pref_name){ + try{prefs_getBranch.clearUserPref('extensions.inspd.'+pref_name) + }catch(e){} + }, + + remove_all : function(pref_name){ + try{prefs_getBranch.deleteBranch('extensions.inspd.'+pref_name,'') + }catch(e){} + }, + + + branch : function(pref_name){ + var serialBranch = prefs_getservice.getBranch('extensions.inspd.'+pref_name+'.'); + return serialBranch.getChildList("",{}); + } +} + + +var $ajax = { + + get : function(url,func){ + var http_request = new XMLHttpRequest(); + http_request.onreadystatechange = function() { func(http_request); }; + http_request.open('GET', url, true); + http_request.setRequestHeader("Connection", "close"); + http_request.setRequestHeader("Keep-Alive", ""); + http_request.send(null); + } + +} + + +var $effects = { + + toggleFade: function(elid) { + if ($id(elid).style.display == 'none'){ + this.fadeIn(elid); + }else{ + this.fadeOut(elid); + } + }, + + toggleShow: function(elid) { + if ($id(elid).style.display == 'none'){ + $id(elid).style.display = 'block'; + } + else{ + $id(elid).style.display = 'none'; + } + }, + + + + fadeOut : function(elid) { + var opacs = ["0",".1",".2",".3",".4",".5",".6",".7",".8",".9","1"]; + opacs.reverse(); + for (var i = 0; i < 11; i++) { + setTimeout('$id(\''+elid+'\').style.opacity = "'+opacs[i]+'";', i * 40); + } + setTimeout('$id(\''+elid+'\').style.display = "none";', i * 40); + }, + + + fadeIn : function(elid) { + var opacs = [".1",".2",".3",".4",".5",".6",".7",".8",".9","1"]; + $id(elid).style.opacity = '0'; + $id(elid).style.display = 'block'; + for (var i = 0; i < 10; i++) { + setTimeout('$id(\''+elid+'\').style.opacity = "'+opacs[i]+'";', i * 40); + } + + }, + + hide : function(elid,delay){ + setTimeout('$effects.fadeOut(\''+elid+'\');',parseInt(delay)*1000) + }, + + initializedrag : function(e,main_id,drag_id){ + var crossobj=$id(main_id) ; + var firedobj= e.target ; + var topelement= "body" ; + while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!=drag_id){ + firedobj=firedobj.parentNode ; + } + + if (firedobj.id==drag_id){ + var offsetx= e.clientX ; + var offsety= e.clientY ; + + var tempx=parseInt(crossobj.style.left) ; + var tempy=parseInt(crossobj.style.top) ; + + dragapproved=true ; + document.onmousemove=(function(e){ + if (dragapproved){ + crossobj.style.left=tempx+e.clientX-offsetx+"px" + crossobj.style.top=tempy+e.clientY-offsety+"px" + return false + } + return false; + }) + } + + }, + + pos2Anchor : function(obj,e,commentbox) { + + + var tempX = 0; + var tempY = 0; + var offset = 5; + + obj = $id(obj); + + tempX = e.pageX; + tempY = e.pageY; + if (tempX < 0){tempX = 0} + if (tempY < 0){tempY = 0} + + + + obj.style.top = (tempY + offset) + 'px'; + if (commentbox == true){ + obj.style.left = ((tempX + offset)+0) + 'px'; + } + else { + obj.style.left = ((tempX + offset)-155) + 'px'; + } + + + }, + + show : function(obj,show) { + + $id(obj).style.display = show ? 'block' : 'none'; + //obj.style.visibility = show ? 'visible' : 'hidden'; + }, + + + getAnchorPos: function(anchorname) { + // This function will return an Object with x and y properties + var useWindow=false; + var coordinates=new Object(); + var x=0,y=0; + var use_gebi=false, use_css=false, use_layers=false; + if (document.getElementById) { use_gebi=true; } + else if (document.all) { use_css=true; } + else if (document.layers) { use_layers=true; } + if (use_gebi && document.all) { + x=this.AnchorPosition_getPageOffsetLeft(document.all[anchorname]); + y=this.AnchorPosition_getPageOffsetTop(document.all[anchorname]); + } + else if (use_gebi) { + var o=document.getElementById(anchorname); + x=this.AnchorPosition_getPageOffsetLeft(o); + y=this.AnchorPosition_getPageOffsetTop(o); + } + else if (use_css) { + x=this.AnchorPosition_getPageOffsetLeft(document.all[anchorname]); + y=this.AnchorPosition_getPageOffsetTop(document.all[anchorname]); + } + else if (use_layers) { + var found=0; + for (var i=0; i'; + $id('nav').style.display= 'none'; + return headertxt ; + } + }, + + remove_all : function(){ + if (confirm('Are you sure you want to delete all your stars?')){ + $prefs.set('stars.list',''); + document.location.href = Inspd_JSON_HOME_PAGE ; + } + else { + return false; + } + return false; + } + + + + + + + +} + +var $conditions = { + + page_with_qs_tags : function() { + if ($utils.qs('tag') && $utils.qs('tag').split('+').length < 2){ + return true ; + } + else { + return false ; + } + }, + gate : function(){ + if (!document.location.href.match(Inspd_JSON_BOOKMARKS_PAGE) && $utils.qs('tag')){ + document.location.href = Inspd_JSON_BOOKMARKS_PAGE+'?tag='+$utils.qs('tag')+'' ; + } + + else if (!document.location.href.match(Inspd_JSON_ALLITEMS_PAGE) && $utils.qs('q')){ + document.location.href = Inspd_JSON_ALLITEMS_PAGE+'?q='+$utils.qs('q')+'' ; + } + else if (document.location.href.match(Inspd_JSON_HOME_PAGE) && $utils.qs('tag')){ + document.location.href = Inspd_JSON_BOOKMARKS_PAGE+'?tag='+$utils.qs('tag')+'' ; + } + else if (document.location.href.match(Inspd_JSON_HOME_PAGE) && $utils.qs('q')){ + document.location.href = Inspd_JSON_ALLITEMS_PAGE+'?q='+$utils.qs('q')+'' ; + } + else if (document.location.href.match(Inspd_JSON_ALLITEMS_PAGE) && $utils.qs('q') == ''){ + document.location.href = Inspd_JSON_HOME_PAGE ; + } + else if (document.location.href.match(Inspd_JSON_BOOKMARKS_PAGE) && $utils.qs('tag') == ''){ + document.location.href = Inspd_JSON_HOME_PAGE ; + } + }, + + getProtocol : function(url,protocol_name){ + if(url.split(':')[0] == protocol_name){ + return true ; + } + else{ + return false; + } + + + } + + + + +} + + +var $delpage = { + + draw_postToInsipid : function(doc){ + var posts = this.getNodes("//div[@class='data']//h4", doc,doc); + for (var i = 0, k = posts.snapshotLength ; i < k ; i++) { + var row = posts.snapshotItem(i) ; + var url , title , tags, user ; + var extended = ''; + var metaNode = null; + var tagsNode = null ; + var original_save_link_href = row.getElementsByTagName('a')[1].getAttribute('href'); + original_save_link_href = original_save_link_href.replace(/^\/save;_y(.*)\?/,$prefs.get('defurl')+'?op=add_bookmark&'); + original_save_link_href = original_save_link_href.replace(/jump=(.*)original_user=/,'copy_user='); + original_save_link_href = original_save_link_href.replace(/%20/g,'+'); + var new_save_link_href = original_save_link_href ; + row.innerHTML += ' SAVE TO INSIPID'; + } + + }, + + getNodes: function(what, where, doc) { + return doc.evaluate(what, where, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); + } + +} + +var $alt_Post = { + + trigger : function(doc){ + //$utils.appendFavIcon('chrome://inspd/content/v2/json/images/inspd_icon7_posttoinsipid_icon_1616.ico',doc); + $utils.appendcssfile(''+Inspd_BASE_ALTPOST_URL+'altpost.css',doc); + $utils.appendjsHTML(''+$alt_Post.write_jsoptions()+'',doc); + + var title_tmp = doc.evaluate("//div[@class='title']",doc,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null).snapshotItem(0).innerHTML ; + doc.evaluate("//div[@class='title']",doc,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null).snapshotItem(0).innerHTML = 'Post to '+title_tmp+'.  With tag autocompletion.'; + + doc.evaluate("//div[@class='search']",doc,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null).snapshotItem(0).innerHTML = ''; + + doc.forms[0].getElementsByTagName('input')[1].setAttribute('value',(''+(''+doc.forms[0].getElementsByTagName('input')[1].value+'').replace(//g,'>')); + + if (doc.evaluate("//span[@class='formtext']",doc,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null).snapshotItem(0).innerHTML.match('already bookmarked')){ + //'this is an edit' + var linkdelete = ''+$prefs.get('defurl')+'?op=delete_bookmark&id=\'+document.forms[0].id.value+\''; + doc.forms[0].innerHTML += '   » delete this bookmark'; + } + else{ + doc.evaluate("//span[@class='formtext']",doc,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null).snapshotItem(0).innerHTML ='URL (new bookmark):'; + + } + + doc.forms[0].innerHTML +='
'+ + '
'+ + '
    '+ + '
  • '+ + '
  • '+ + '
  • '+ + '
  • '+ + '
  • '+ + '
  • '+ + '
'+ + ''; + + $utils.appendjs('chrome://inspd/content/inc/vars.js',doc) + $utils.appendjs('chrome://inspd/content/inc/md5.js',doc) + $alt_Post.setInitialUI(doc); + //$utils.appendjs(''+Inspd_BASE_ALTPOST_URL+'altpost_trigger.js',doc) + + }, + + write_jsoptions : function(){ + + var jstxt = 'window.focus();var tagRec = [];var tagPop = [];var tagPop2 = []; var tagPop3 = []; var tagFor = [];var copyuser = "" ; var copytags = [];'; + + $utils.get_deliciousUser() ? jstxt +='var Inspd_delicious_username=\''+$utils.get_deliciousUser()+'\';' : jstxt+=''; + return jstxt ; + }, + + setInitialUI : function(doc){ + var url = doc.getElementsByTagName('input')[0].getAttribute('value') ; + if($prefs.get('delintegratecommontags') != '0' && !url.match(''+$prefs.get('defurl')+'') && !url.match('^chrome|about|color\\:') && url.match('^http||https\\://') && !url.match('^.*\\://(localhost|127.0.0.|192.168.0.|10.0.0.)') ){ + doc.evaluate("//span[@class='poptags_msg']",doc,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null).snapshotItem(0).innerHTML += 'getting popular tags for this url from del.icio.us ....'; + + $utils.appendjsHTML('Inspd_delintegrate_commontags = 1;',doc); + $alt_Post.GetPopTagsFromDeliciousChooser(doc,''+$prefs.get('delintegratecommontags')+''); + + + } + else{ + $utils.appendjsHTML('Inspd_delintegrate_commontags = 0;',doc); + $utils.appendjs(''+Inspd_BASE_ALTPOST_URL+'altpost_trigger.js',doc) ; + } + }, + + + + GetPopTagsFromDeliciousPersonal : function(doc){ + //var urlDeliciousPersonal = 'http://del.icio.us/'+$utils.get_deliciousUser()+'?v=4&noui&jump=close&url='+doc.getElementsByTagName('input')[0].getAttribute('value')+''; + var urlDeliciousPersonal = 'http://feeds.delicious.com/v2/json/tags/'+$utils.get_deliciousUser() ; + + + + var http_requestDeliciousPersonal = new XMLHttpRequest(); + http_requestDeliciousPersonal.onreadystatechange = function() { + if (http_requestDeliciousPersonal.readyState == 4) { + try{ + if (http_requestDeliciousPersonal.status == 200) { + //if(http_requestDeliciousPersonal.responseText.match('tagPop = \\[.*\\]') != 'tagPop = []'){ + //$utils.appendjsHTML('Inspd_delintegrate_commontags_found = 1;'+(''+http_requestDeliciousPersonal.responseText.match('var tagPop = \\[.*\\]')+'').toLowerCase()+';tagPop = tagpop;',doc) ; + var tags_txt = http_requestDeliciousPersonal.responseText ; + tags_txt = tags_txt.replace(/\{|\}|\:[0-9]{1}|\:[0-9]{2}|\:[0-9]{3}|\:[0-9]{4}/g,''); + $utils.appendjsHTML('Inspd_delintegrate_commontags_found = 1; tagPop = ['+tags_txt.toLowerCase()+'];',doc) ; + //} + //else{ + //$utils.appendjsHTML('Inspd_delintegrate_commontags_found = 2;',doc); + //} + $utils.appendjs(''+Inspd_BASE_ALTPOST_URL+'altpost_trigger.js',doc) ; + } + else { + //alert(e); + $utils.appendjsHTML('Inspd_delintegrate_commontags_found = 3;',doc); + $utils.appendjs(''+Inspd_BASE_ALTPOST_URL+'altpost_trigger.js',doc) ; + } + } + catch(e){ + //alert(e); + $utils.appendjsHTML('Inspd_delintegrate_commontags_found = 3;',doc); + $utils.appendjs(''+Inspd_BASE_ALTPOST_URL+'altpost_trigger.js',doc) ; + } + } + }; + //http_requestDeliciousPersonal.overrideMimeType('text/xml'); + http_requestDeliciousPersonal.open('GET', urlDeliciousPersonal, true); + http_requestDeliciousPersonal.setRequestHeader("Connection", "close"); + http_requestDeliciousPersonal.setRequestHeader("Keep-Alive", ""); + http_requestDeliciousPersonal.send(null); + }, + + GetPopTagsFromDeliciousFetchURL : function(doc){ + //$utils.inc('chrome://inspd/content/inc/md5.js'); + var urlDeliciousURL = 'http://delicious.com/url/'+hex_md5(''+doc.getElementsByTagName('input')[0].getAttribute('value')+'')+'?settagview=cloud'; + + var http_requestDeliciousURL = new XMLHttpRequest(); + http_requestDeliciousURL.onreadystatechange = function() { + if (http_requestDeliciousURL.readyState == 4) { + try{ + if (http_requestDeliciousURL.status == 200) { + //var alphacloud_txt = (''+http_requestDeliciousURL.responseText.match(/
[\s\S]+/)+'').replace(/