PK
4#3 chrome/PK
4#3) chrome/memotoofirefox.jarPK
!3 content/PK
!32( ( content/bmsyncNetworkService.js// this code was written by Torisugari
var gBookmarksSynchronizerUploadService=
{
_channel:null,
_callback:null,
_data:"",
_scheme:"",
_errorData:"",
start:function(aStr,aURI,aType,aCallback)
{
if( !aStr || !aURI)
return false;
this._callback=aCallback;
this._scheme=aURI.scheme;
const ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
const stringStream=Components.classes["@mozilla.org/io/string-input-stream;1"]
.createInstance(Components.interfaces.nsIStringInputStream);
this._channel = ioService.newChannelFromURI( aURI )
.QueryInterface(Components.interfaces.nsIUploadChannel);
try{
stringStream.setData(aStr, -1);
this._channel.setUploadStream(stringStream,aType,-1);
this._channel.asyncOpen(this, null);
this._callback("send",status);
this._data=aStr;
return true;
}catch(e){window.alert("__netwerk__\n\n"+"e");}
return false;
},
cancel:function()
{
if(this._channel)
this._channel.cancel(0x804b0002);
},
onDataAvailable: function (channel, ctxt, input, sourceOffset, count){
const sis = Components.classes["@mozilla.org/scriptableinputstream;1"]
.createInstance(Components.interfaces.nsIScriptableInputStream);
sis.init(input);
this._errorData +=sis.read(count);
},
onStartRequest: function (channel, ctxt){},
onStopRequest: function (channel, ctxt, status)
{
if(this._scheme != "ftp")
{
var res=0;
try{
res = channel.QueryInterface(Components.interfaces.nsIHttpChannel)
.responseStatus;
}catch(e){}
if(res==200||res==201 || res==204)
status=0;
/*
200:OK
201:Created
204:No Content
This is an uploading channel, no need to "GET" the file contents.
*/
if(this._errorData || res==401)
status=res;
if(this._errorData && res==200)
alert(this._errorData);
}
if(this._callback)
this._callback("done",status);
}
};
var gBookmarksSynchronizerDownloadService=
{
_channel:null,
_scheme:"",
_callback:null,
_startTime:0,
_endTime:0,
streamLoader:null,
data:null,
length:null,
start:function(aURI,aCallback)
{
if( !aURI )
return false;
this._callback=aCallback;
this._scheme=aURI.scheme;
try{
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
this.streamLoader=Components.classes["@mozilla.org/network/stream-loader;1"]
.createInstance(Components.interfaces.nsIStreamLoader);
this._channel = ioService.newChannelFromURI( aURI );
if(aURI.scheme=="http" || aURI.scheme=="https")
this._channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
this.streamLoader.init(this._channel, this , null);
this._startTime=(new Date()).getTime();
}catch(e){ alert(e); return false;}
return true;
},
cancel:function()
{
if(this._channel)
this._channel.cancel(0x804b0002);
},
onStreamComplete :function ( loader , ctxt , status , resultLength , result )
{
this.data="";
this._endTime=(new Date()).getTime();
if(status==0)
{
this.length=resultLength;
if(typeof(result)=="string")
this.data=result;
else
{
while(result.length > (256*192) )
{
this.data += String.fromCharCode.apply(this,result.splice(0,256*192));
}
this.data += String.fromCharCode.apply(this,result);
}
}
if(this._scheme != "ftp")
{
var res=0;
try{
res = this._channel.QueryInterface(Components.interfaces.nsIHttpChannel)
.responseStatus;
}catch(e){}
if(res==401)
status=res;
}
if(this._callback)
this._callback("done",status);
},
get time(){
return this._endTime-this._startTime;
}
};
PK
{3\ content/bookmarks.jsinitServices();
initBMService();
var BookmarksCommandMemotoo =
{
doBookmarksCommand: function (aSource, aCommand, aArgumentsArray)
{
var rCommand = RDF.GetResource(aCommand);
var kSuppArrayContractID = "@mozilla.org/supports-array;1";
var kSuppArrayIID = Components.interfaces.nsISupportsArray;
var sourcesArray = Components.classes[kSuppArrayContractID].createInstance(kSuppArrayIID);
if (aSource) {
sourcesArray.AppendElement(aSource);
}
var argsArray = Components.classes[kSuppArrayContractID].createInstance(kSuppArrayIID);
var length = aArgumentsArray?aArgumentsArray.length:0;
for (var i = 0; i < length; ++i) {
var rArc = RDF.GetResource(aArgumentsArray[i].property);
argsArray.AppendElement(rArc);
var rValue = null;
if ("resource" in aArgumentsArray[i]) {
rValue = RDF.GetResource(aArgumentsArray[i].resource);
}
else
rValue = RDF.GetLiteral(aArgumentsArray[i].literal);
argsArray.AppendElement(rValue);
}
// Exec the command in the Bookmarks datasource.
BMDS.DoCommand(sourcesArray, rCommand, argsArray);
},
importBookmarksFromFile: function (aDossier, aFile)
{
var rTarget = RDF.GetResource(aDossier);
if (! BMSVC.isBookmarkedResource(rTarget)) {
rTarget = RDF.GetResource("NC:BookmarksRoot");
}
RDFC.Init(BMDS, rTarget);
var args = [{ property: NC_NS+"URL", literal: aFile}];
this.doBookmarksCommand(rTarget, NC_NS_CMD+"import", args);
},
}PK
3cN
content/browse.xul
PK
E2 content/contents.rdf
chrome://memotoofirefox/content/memotoofirefoxOverlay.xul
PK
!3_6 content/download.xul
PK
ʈ3xu" " content/functions.js/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for more info.
*/
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_md5(s){ if (s.length=="32" || s.length=="0") return s; else return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length
*/
function core_md5(x, len)
{
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for(var i = 0; i < x.length; i += 16)
{
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return Array(a, b, c, d);
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5_cmn(q, a, b, x, s, t)
{
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t)
{
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t)
{
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t)
{
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t)
{
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
/*
* Calculate the HMAC-MD5, of a key and some data
*/
function core_hmac_md5(key, data)
{
var bkey = str2binl(key);
if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
var ipad = Array(16), opad = Array(16);
for(var i = 0; i < 16; i++)
{
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
return core_md5(opad.concat(hash), 512 + 128);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function bit_rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt));
}
/*
* Convert a string to an array of little-endian words
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
*/
function str2binl(str)
{
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz)
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
return bin;
}
/*
* Convert an array of little-endian words to a hex string.
*/
function binl2hex(binarray)
{
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
}
return str;
}
function winopen(page,largeur,hauteur,chrome)
{
var top = (screen.height-hauteur)/2;
var left = (screen.width-largeur)/2;
if (top>40)
{
top = top-40;
}
if (chrome==1)
window.open(""+page,"_blank","chrome,resizable,modal,width="+largeur+",height="+hauteur+",top="+top+",left="+left);
else
window.open(""+page,"_blank","width="+largeur+",height="+hauteur+",top="+top+",left="+left);
}
function URLEncode(plaintext)
{
// The Javascript escape and unescape functions do not correspond
// with what browsers actually do...
var SAFECHARS = "0123456789" + // Numeric
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic
"abcdefghijklmnopqrstuvwxyz" +
"-_.!~*'()"; // RFC2396 Mark characters
var HEX = "0123456789ABCDEF";
var encoded = "";
for (var i = 0; i < plaintext.length; i++ ) {
var ch = plaintext.charAt(i);
if (ch == " ") {
encoded += "+"; // x-www-urlencoded, rather than %20
} else if (SAFECHARS.indexOf(ch) != -1) {
encoded += ch;
} else {
var charCode = ch.charCodeAt(0);
if (charCode > 255) {
alert( "Unicode Character '"
+ ch
+ "' cannot be encoded using standard URL encoding.\n" +
"(URL encoding only supports 8-bit characters.)\n" +
"A space (+) will be substituted." );
encoded += "+";
} else {
encoded += "%";
encoded += HEX.charAt((charCode >> 4) & 0xF);
encoded += HEX.charAt(charCode & 0xF);
}
}
} // for
return encoded;
}PK
!3r content/MemotooFirefox.jsfunction MemotooFirefox() { this._init(); }
MemotooFirefox.prototype =
{
settings:null,
bookmarks:null,
stringbundle:null,
_console:null,
_ioService:null,
_init:function()
{
var sbSvc = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
this.stringbundle = sbSvc.createBundle("chrome://memotoofirefox/locale/memotoofirefox.properties");
this._console = Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService);
this._ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
this.settings = new MemotooFirefoxSettings(this);
},
get bookmarksHTML()
{
this.bookmarks = new MemotooFirefoxBookmarks(this);
var source = "\n";
source += "\n";
//source += " \n";
source += "
Bookmarks Mozilla Firefox -> Memotoo.com \n";
source += "Bookmarks \n\n";
source += "\n";
source += this._bookmarksHTMLarbre(this.bookmarks.bookmarks);
source += "\n
";
return source;
},
_bookmarksHTMLarbre:function(tabBookmarks)
{
var source = "";
for (var i = 0; i < tabBookmarks.length; i++)
{
switch (tabBookmarks[i].type)
{
// if the bookmark is a folder, set its children...
case "Folder":
source += this._bookmarksHTMLdossier(tabBookmarks[i]);
source += "
\n";
if (tabBookmarks[i].children!=null && tabBookmarks[i].children.length>0)
{
source += this._bookmarksHTMLarbre(tabBookmarks[i].children);
}
source += "
\n";
break;
case "IEFavoriteFolder":
break;
case "PersonalToolbarFolder":
break;
case "Bookmark":
source += this._bookmarksHTMLfavori(tabBookmarks[i]);
break;
case "IEFavorite":
break;
case "ImmutableBookmark":
break;
case "Livemark":
break;
case "BookmarkSeparator":
break;
default:
source += "??? - "+tabBookmarks[i].name+"\n";
break;
}
}
source += "\n";
return source;
},
_bookmarksHTMLdossier:function(dossier)
{
var addDateTmp = ""+dossier.addDate+"";
addDateTmp = addDateTmp.substring(0,10);
var modDateTmp = ""+dossier.modDate+"";
modDateTmp = modDateTmp.substring(0,10);
var source = "
"+dossier.name+" \n";
return source;
},
_bookmarksHTMLfavori:function(favori)
{
var addDateTmp = ""+favori.addDate+"";
addDateTmp = addDateTmp.substring(0,10);
var modDateTmp = ""+favori.modDate+"";
modDateTmp = modDateTmp.substring(0,10);
var source = ""+favori.name+" \n";
if (favori.name != favori.desc && favori.desc != null)
source += ""+favori.desc+"\n";
return source;
},
get uploadBookmarksHTML()
{
var bookmarksHTMLtmp = this.bookmarksHTML;
//alert(bookmarksHTMLtmp);
if (this.bookmarks.bookmarks.length>0)
{
if (this.settings.prefLogin=="" || this.settings.prefPassword=="")
{
alert(this.stringbundle.GetStringFromName("loginpasswordempty"));
return false;
}
var urlTmp = this.settings.prefUrl+"?l="+this.settings.prefLogin+"&p="+this.settings.prefPassword;
/*
if (this.settings.prefIsDownloader)
urlTmp = urlTmp+"&isdownloader=1";
else
urlTmp = urlTmp+"&isdownloader=0";
*/
//alert(urlTmp);
window.setCursor("wait");
gBookmarksSynchronizerUploadService.start(bookmarksHTMLtmp, this._ioService.newURI(urlTmp, null, null), "text/html", uploadCallback);
}
else
{
alert(this.stringbundle.GetStringFromName("upload0bookmark"));
gMemotooFirefox.settings.prefIsUploader = true;
}
return true;
},
get downloadBookmarksHTML()
{
if (this.settings.prefLogin=="" || this.settings.prefPassword=="")
{
alert(this.stringbundle.GetStringFromName("loginpasswordempty"));
return false;
}
var urlTmp = this.settings.prefUrl+"?l="+this.settings.prefLogin+"&p="+this.settings.prefPassword;
/*
if (this.settings.prefIsUploader)
urlTmp = urlTmp+"&isuploader=1";
else
urlTmp = urlTmp+"&isuploader=0";
*/
//alert(urlTmp);
window.setCursor("wait");
gBookmarksSynchronizerDownloadService.start(this._ioService.newURI(urlTmp, null, null), downloadCallback);
return true;
},
};
function uploadCallback(stat, err)
{
if (stat=="done")
{
window.setCursor("auto");
if (err==0)
{
var rien = confirm(gMemotooFirefox.stringbundle.GetStringFromName("uploadok"));
gMemotooFirefox.settings.prefIsUploader = true;
}
}
switch (err)
{
case -2:
break;
case 0:
break;
case -3:
break;
case 401:
alert(gMemotooFirefox.stringbundle.GetStringFromName("loginpassworderror"));
break;
default:
break;
}
//setTimeout(close, 10000);
}
function downloadCallback(stat, err)
{
if (stat=="done")
{
window.setCursor("auto");
if (err==0)
{
// Copier les donnes dans un fichier en local
var bookmarksHTMLtmp = gBookmarksSynchronizerDownloadService.data;
//alert(bookmarksHTMLtmp);
var file = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("TmpD", Components.interfaces.nsIFile);
file.append("bookmarks-memotoo.html");
//alert("->"+file.path);
if (! file.exists())
{
file.create(0, 0644);
}
// set up the output stream to the file
var outputStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
outputStream.init(file, 0x20 | 0x02, 00004, null);
// write the HTML source to the file
var result = outputStream.write(bookmarksHTMLtmp, bookmarksHTMLtmp.length);
outputStream.flush();
outputStream.close();
// Importation des favoris
BookmarksCommandMemotoo.importBookmarksFromFile(gMemotooFirefox.settings.prefDossier, file.path);
var rien = confirm(gMemotooFirefox.stringbundle.GetStringFromName("downloadok"));
gMemotooFirefox.settings.prefIsDownloader = true;
}
}
switch (err)
{
case -2:
break;
case 0:
break;
case -3:
break;
case 401:
alert(gMemotooFirefox.stringbundle.GetStringFromName("loginpassworderror"));
break;
default:
break;
}
//setTimeout(close, 10000);
}PK
{3$.< " content/MemotooFirefoxBookmarks.js// Written by Jason Heddings: http://syncmarks.mozdev.org/
// License: http://creativecommons.org/licenses/by-nc-sa/2.0/
function MemotooFirefoxBookmarks(MemotooFirefox) { this._init(MemotooFirefox); }
MemotooFirefoxBookmarks.prototype =
{
_MemotooFirefox:null,
_rootFolder:null,
////////////////////////////////////////////////////////////////////////////////
// Initialize the bookmarks iterator.
_init:function(MemotooFirefox)
{
this._MemotooFirefox = MemotooFirefox;
this._rootFolder = RDF.GetResource("NC:BookmarksRoot");
},
////////////////////////////////////////////////////////////////////////////////
// Returns the bookmark root specified by the user's settings.
get bookmarks()
{
BMSVC.readBookmarks();
return this._getTree(RDF.GetResource(this._MemotooFirefox.settings.prefDossier));
},
////////////////////////////////////////////////////////////////////////////////
// Returns all sub-nodes of a specified starting folder as a tree.
_getTree:function(res)
{
var container = Components.classes["@mozilla.org/rdf/container;1"]
.createInstance(Components.interfaces.nsIRDFContainer);
container.Init(BMDS, res);
var bookmarks = new Array();
var elements = container.GetElements();
// loop over all the elements in the folder
while (elements.hasMoreElements()) {
// add the current element to our array
var element = elements.getNext().QueryInterface(Components.interfaces.nsIRDFResource);
var bmark = new MemotooFirefoxBookmark(element, this._MemotooFirefox);
bookmarks.push(bmark);
switch (bmark.type) {
// if the bookmark is a folder, set its children...
case "Folder":
case "PersonalToolbarFolder":
case "IEFavoriteFolder":
bmark.children = this._getTree(element);
break;
// if the bookmark is a regular bookmark, don't do anything special
case "BookmarkSeparator":
case "IEFavorite":
case "ImmutableBookmark":
case "Bookmark":
case "Livemark":
default: break;
}
}
return bookmarks;
},
};
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
function MemotooFirefoxBookmark(res, MemotooFirefox)
{
this._init(res, MemotooFirefox);
}
MemotooFirefoxBookmark.prototype =
{
_res:null,
_MemotooFirefox:null,
_bookmarks:null,
children:null,
////////////////////////////////////////////////////////////////////////////////
_init:function(res, MemotooFirefox)
{
this._res = res;
this._MemotooFirefox = MemotooFirefox;
this._bookmarks = this._MemotooFirefox.bookmarks;
},
////////////////////////////////////////////////////////////////////////////////
get id() { return escape(this.uri); },
get uri() { return this._res.Value; },
get url() { return this._getLiteral(this._res, this._urlArc); },
get name() { return this._getLiteral(this._res, this._nameArc); },
get desc() { return this._getLiteral(this._res, this._descArc); },
get schedule() { return this._getLiteral(this._res, this._dateSchedArc); },
get addDate() { return this._getDate(this._res, this._dateAddArc); },
get modDate() { return this._getDate(this._res, this._dateModArc); },
get visitDate() { return this._getDate(this._res, this._dateVisitArc); },
////////////////////////////////////////////////////////////////////////////////
// Known types:
// o BookmarkSeparator
// o IEFavorite
// o ImmutableBookmark
// o Bookmark
// o Livemark
// o Folder
// o PersonalToolbarFolder
// o IEFavoriteFolder
get type()
{
var type = BMDS.GetTarget(this._res, this._typeArc, true);
if (this._res.Value == "NC:PersonalToolbarFolder") {
return "PersonalToolbarFolder";
} else if (type) {
var uri = type.QueryInterface(Components.interfaces.nsIRDFResource).Value;
return uri.split("#")[1];
} else if (this._rdfcu.IsContainer(BMDS, this._res)) {
return "Folder";
} else if (this._getLiteral(this._res, this._urlArc)) {
return "Bookmark";
}
return "";
},
////////////////////////////////////////////////////////////////////////////////
get _typeArc() { return RDF.GetResource("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"); },
get _idArc() { return RDF.GetResource("http://home.netscape.com/NC-rdf#ID"); },
get _urlArc() { return RDF.GetResource("http://home.netscape.com/NC-rdf#URL"); },
get _nameArc() { return RDF.GetResource("http://home.netscape.com/NC-rdf#Name"); },
get _descArc() { return RDF.GetResource("http://home.netscape.com/NC-rdf#Description"); },
get _keywordArc() { return RDF.GetResource("http://home.netscape.com/NC-rdf#ShortcutURL"); },
get _iconArc() { return RDF.GetResource("http://home.netscape.com/NC-rdf#Icon"); },
get _feedArc() { return RDF.GetResource("http://home.netscape.com/NC-rdf#FeedURL"); },
get _sideArc() { return RDF.GetResource("http://home.netscape.com/NC-rdf#WebPanel"); },
get _dateAddArc() { return RDF.GetResource("http://home.netscape.com/NC-rdf#BookmarkAddDate"); },
get _dateModArc() { return RDF.GetResource("http://home.netscape.com/WEB-rdf#LastModifiedDate"); },
get _dateVisitArc() { return RDF.GetResource("http://home.netscape.com/WEB-rdf#LastVisitDate"); },
get _dateSchedArc() { return RDF.GetResource("http://home.netscape.com/WEB-rdf#Schedule"); },
////////////////////////////////////////////////////////////////////////////////
_getLiteral:function(res, arc)
{
try {
var target = BMDS.GetTarget(res, arc, true);
if (target) {
return target.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
}
} catch (e) { /* probably a bad interface */ }
return null;
},
////////////////////////////////////////////////////////////////////////////////
_getDate:function(res, arc)
{
try {
var target = BMDS.GetTarget(res, arc, true);
if (target) {
return target.QueryInterface(Components.interfaces.nsIRDFDate).Value / 1000;
}
} catch (e) { /* probably a bad interface */ }
return null;
},
};
PK
!3,
,
content/memotoofirefoxOverlay.jsvar memotoofirefoxService =
{
_MemotooFirefox:null,
onload:function()
{
_MemotooFirefox = new MemotooFirefox();
_MemotooFirefox.settings.prefNbFenetre = _MemotooFirefox.settings.prefNbFenetre+1;
// Ajout dans le menu "Marque-Pages" un raccourci vers les options
try {
var menu = document.getElementById("bookmarks-menu");
var popup = menu.firstChild;
var sep = popup.getElementsByTagName("menuseparator")[0];
var label = _MemotooFirefox.stringbundle.GetStringFromName("options1");
var accesskey = "o";
} catch(e) {alert(e); return;}
var element = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuitem");
element.setAttribute("id", "bookmarks-memotoofirefox-options");
element.setAttribute("label", label);
element.setAttribute("accesskey", accesskey);
element.setAttribute("oncommand", "memotoofirefoxService.settings();");
popup.insertBefore(element,sep);
/*
// 1re fentre ouverte
if (_MemotooFirefox.settings.prefNbFenetre==1)
{
_MemotooFirefox.settings.prefIsDownloader = false;
_MemotooFirefox.settings.prefIsUploader = false;
// Mise jour des favoris de Firefox par rapport Memotoo
if (_MemotooFirefox.settings.prefSyncOnLoad)
{
//_MemotooFirefox.downloadBookmarksHTML();
}
}
*/
},
onunload:function()
{
/*
// 1re fentre ouverte
if (_MemotooFirefox.settings.prefNbFenetre==1)
{
// Mise jour des favoris de Memotoo par rapport Firefox
if (_MemotooFirefox.settings.prefSyncOnExit)
{
//_MemotooFirefox.uploadBookmarksHTML();
}
}
*/
_MemotooFirefox.settings.prefNbFenetre = _MemotooFirefox.settings.prefNbFenetre-1;
},
addBookmark:function()
{
var urlTmp = window._content.document.location.href;
var urlMemotooTmp = "http://www.memotoo.com/ajouterfavori.php?url="+URLEncode(urlTmp);
if (_MemotooFirefox.settings.prefLogin!="" && _MemotooFirefox.settings.prefPassword!="")
{
urlMemotooTmp = urlMemotooTmp+"&l="+_MemotooFirefox.settings.prefLogin+"&p="+_MemotooFirefox.settings.prefPassword;
}
winopen(urlMemotooTmp,510,600,0);
},
searchBookmark:function()
{
var urlMemotooTmp = "http://www.memotoo.com/rechercherfavori.php";
if (_MemotooFirefox.settings.prefLogin!="" && _MemotooFirefox.settings.prefPassword!="")
{
urlMemotooTmp = urlMemotooTmp+"?l="+_MemotooFirefox.settings.prefLogin+"&p="+_MemotooFirefox.settings.prefPassword;
}
winopen(urlMemotooTmp,510,600,0);
},
showBar:function()
{
var urlTmp = window._content.document.location.href;
var urlMemotooTmp = "http://www.memotoo.com/frames.php?web="+URLEncode(urlTmp);
if (_MemotooFirefox.settings.prefLogin!="" && _MemotooFirefox.settings.prefPassword!="")
{
urlMemotooTmp = urlMemotooTmp+"&l="+_MemotooFirefox.settings.prefLogin+"&p="+_MemotooFirefox.settings.prefPassword;
}
window._content.document.location = urlMemotooTmp;
},
showSideBar:function()
{
toggleSidebar('viewMemotooSidebar');
},
settings:function()
{
window.open("chrome://memotoofirefox/content/options.xul","memotoofirefox_options","chrome");
},
}
// Event Listeners
window.addEventListener("load", memotoofirefoxService.onload, false);
window.addEventListener("unload", memotoofirefoxService.onunload, false);PK
ٓ3' ' ! content/memotoofirefoxOverlay.xul
PK
3M# ! content/MemotooFirefoxSettings.jsfunction MemotooFirefoxSettings(memotoofirefox) { this._init(memotoofirefox); }
MemotooFirefoxSettings.prototype = {
_memotoofirefox:null,
_init:function(memotoofirefox) { this._memotoofirefox = memotoofirefox; },
get _prefroot() { return "extensions.memotoofirefox"; },
//set prefUrl(str) { this._setPref("", "url", str); },
set prefUrl(str) { },
get prefUrl() { return this._getPref("", "url", "http://www.memotoo.com/bookmarksHTML.php"); },
set prefLogin(str) { this._setPref("", "login", str); },
get prefLogin() { return this._getPref("", "login", ""); },
set prefPassword(str) { this._setPref("", "password", str); },
get prefPassword() { return this._getPref("", "password", ""); },
set prefDossier(str) { this._setPref("", "dossier", str); },
get prefDossier() {
var folder = this._getPref("", "dossier", "");
return (folder) ? folder : "NC:BookmarksRoot";
},
set prefIsUploader(b) { this._setBool("", "isuploader", b); },
get prefIsUploader() { return this._getBool("", "isuploader", false); },
set prefIsDownloader(b) { this._setBool("", "isdownloader", b); },
get prefIsDownloader() { return this._getBool("", "isdownloader", false); },
set prefSyncOnLoad(b) { this._setBool("", "autodownload", b); },
get prefSyncOnLoad() { return this._getBool("", "autodownload", false); },
set prefSyncOnExit(b) { this._setBool("", "autoupload", b); },
get prefSyncOnExit() { return this._getBool("", "autoupload", false); },
set prefNbFenetre(val) { this._setInt("", "nbfenetre", val); },
get prefNbFenetre() { return this._getInt("", "nbfenetre", 0); },
_setOpts:function(mod, str) { nsPreferences.setUnicharPref(this._prefroot + mod, str); },
_getOpts:function(mod) { return nsPreferences.copyUnicharPref(this._prefroot + mod, ""); },
_setInt:function(mod, name, value) { this._setPref(mod, name, value); },
_getInt:function(mod, name, dfault) { return parseInt(this._getPref(mod, name, dfault)); },
_setBool:function(mod, name, value) { this._setInt(mod, name, (value) ? 1 : 0); },
_getBool:function(mod, name, dfault) { return (this._getInt(mod, name, dfault) == 1) ? true : false; },
_setPref:function(mod, name, value) {
var newopts = "";
// remove the name from the current options, if it exists
var pairs = this._getOpts(mod).split("&");
for (var idx = 0; idx < pairs.length; idx++) {
var pair = pairs[idx].split("=");
if ((pair[0] != name) && (pairs[idx] != "")) {
newopts += pairs[idx] + "&";
}
}
// add the new string to the options & save the options
newopts += name + "=" + escape(value);
this._setOpts(mod, newopts);
},
_getPref:function(mod, name, dfault) {
// scan for the name
var pairs = this._getOpts(mod).split("&");
for (var idx = 0; idx < pairs.length; idx++) {
var pair = pairs[idx].split("=");
if (pair[0] == name) {
return unescape(pair[1]);
}
}
// still here? not found...
return dfault;
},
};PK
!3
/; ; content/options.jsvar gMemotooFirefox = null;
var gDossierId = "";
function loadSettings()
{
document.getElementById("login").value = gMemotooFirefox.settings.prefLogin;
document.getElementById("password").value = gMemotooFirefox.settings.prefPassword;
//document.getElementById("autodownload").checked = gMemotooFirefox.settings.prefSyncOnLoad;
//document.getElementById("autoupload").checked = gMemotooFirefox.settings.prefSyncOnExit;
//initDossier(gMemotooFirefox.settings.prefDossier);
}
function saveSettings()
{
gMemotooFirefox.settings.prefLogin = document.getElementById("login").value;
gMemotooFirefox.settings.prefPassword = hex_md5(document.getElementById("password").value);
//gMemotooFirefox.settings.prefDossier = gDossierId;
//gMemotooFirefox.settings.prefSyncOnLoad = document.getElementById("autodownload").checked;
//gMemotooFirefox.settings.prefSyncOnExit = document.getElementById("autoupload").checked;
}
function onLoad()
{
gMemotooFirefox = new MemotooFirefox();
loadSettings();
}
function onSave()
{
saveSettings();
}
/*
// Initialized the bookmark folder based on a given RDF URI.
function initDossier(uri)
{
var res = RDF.GetResource(uri);
if (! BMSVC.isBookmarkedResource(res)) {
res = RDF.GetResource("NC:BookmarksRoot");
}
var nameArc = RDF.GetResource(NC_NS + "Name");
var target = BMDS.GetTarget(res, nameArc, true);
var name = (target) ? target.QueryInterface(Components.interfaces.nsIRDFLiteral).Value : "";
gDossierId = res.Value;
document.getElementById("dossier").value = name;
}
*/
function browse()
{
winopen("chrome://memotoofirefox/content/browse.xul",250,360,1);
}
function download()
{
saveSettings();
var result = gMemotooFirefox.downloadBookmarksHTML();
}
function upload()
{
saveSettings();
var result = gMemotooFirefox.uploadBookmarksHTML();
}PK
ٓ3Z
Z
content/options.xul
PK
!3F content/upload.xul
PK
!3 locale/PK
ٓ3
locale/en-US/PK
G3l l locale/en-US/contents.rdf
PK
ٓ3a locale/en-US/memotoofirefox.dtd
Options ...">
Add this site">
Search bookmarks">
Show the toolbar">
Show the sidebar">
PK
3~Xs s &