mirror of
https://github.com/Oreolek/TrackMeNot-Chrome.git
synced 2024-05-11 13:38:19 +03:00
jshint fixes
This commit is contained in:
parent
b03e76e328
commit
fe7dd63229
720
editor.js
720
editor.js
|
@ -1,361 +1,359 @@
|
||||||
|
if(!TRACKMENOT) var TRACKMENOT = {};
|
||||||
|
|
||||||
|
TRACKMENOT.editor = function () {
|
||||||
if(!TRACKMENOT) var TRACKMENOT = {};
|
|
||||||
|
var rss_file = null;
|
||||||
TRACKMENOT.editor = function () {
|
var rss_seed = null;
|
||||||
|
var rss_obj = null;
|
||||||
var rss_file = null;
|
var tree_state = '';
|
||||||
var rss_seed = null;
|
var tree_item = '';
|
||||||
var rss_obj = null;
|
var new_feed_uri = '';
|
||||||
var tree_state = '';
|
|
||||||
var tree_item = '';
|
function appendCellToTree(tr,label) {
|
||||||
var new_feed_uri = '';
|
var treeCellName = document.createElement("treecell");
|
||||||
|
treeCellName.setAttribute("label",label.toString());
|
||||||
function appendCellToTree(tr,label) {
|
tr.appendChild(treeCellName);
|
||||||
var treeCellName = document.createElement("treecell");
|
}
|
||||||
treeCellName.setAttribute("label",label.toString());
|
|
||||||
tr.appendChild(treeCellName);
|
function getRunningWindow() {
|
||||||
}
|
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
|
||||||
|
getService(Components.interfaces.nsIWindowMediator);
|
||||||
function getRunningWindow() {
|
var en = wm.getEnumerator("navigator:browser");
|
||||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
|
while (en.hasMoreElements()) {
|
||||||
getService(Components.interfaces.nsIWindowMediator);
|
var win = en.getNext();
|
||||||
var en = wm.getEnumerator("navigator:browser");
|
if (win.TRACKMENOT && win.TRACKMENOT.gTrackMeNot)
|
||||||
while (en.hasMoreElements()) {
|
return win;
|
||||||
var win = en.getNext();
|
}
|
||||||
if (win.TRACKMENOT && win.TRACKMENOT.gTrackMeNot)
|
return null;
|
||||||
return win;
|
}
|
||||||
}
|
|
||||||
return null
|
function cout(msg) {
|
||||||
}
|
var win = getRunningWindow();
|
||||||
|
win.TRACKMENOT.utils.cout(msg);
|
||||||
function cout(msg) {
|
}
|
||||||
var win = getRunningWindow();
|
|
||||||
win.TRACKMENOT.utils.cout(msg);
|
function appendCatToTree( cat, tr) {
|
||||||
}
|
if(cat.id)
|
||||||
|
appendCellToTree(tr,cat.id);
|
||||||
function appendCatToTree( cat, tr) {
|
if(cat.type)
|
||||||
if(cat.id)
|
appendCellToTree(tr,cat.type);
|
||||||
appendCellToTree(tr,cat.id);
|
}
|
||||||
if(cat.type)
|
|
||||||
appendCellToTree(tr,cat.type);
|
|
||||||
}
|
|
||||||
|
function createCellElement(fatherElement, elt, id, _window, isRoot, type ) {
|
||||||
|
try {
|
||||||
|
var ti = _window.document.createElement("treeitem");
|
||||||
function createCellElement(fatherElement, elt, id, _window, isRoot, type ) {
|
if (elt.children && elt.children.length > 0)
|
||||||
try {
|
ti.setAttribute("container", true);
|
||||||
var ti = _window.document.createElement("treeitem");
|
if (!isRoot && type && elt.type != type)
|
||||||
if (elt.children && elt.children.length > 0)
|
ti.setAttribute("hidden", true);
|
||||||
ti.setAttribute("container", true);
|
//ti.setAttribute("id", id++);
|
||||||
if (!isRoot && type && elt.type != type)
|
var tr = _window.document.createElement("treerow");
|
||||||
ti.setAttribute("hidden", true);
|
appendCatToTree(elt, tr);
|
||||||
//ti.setAttribute("id", id++);
|
ti.setAttribute("open", isRoot);
|
||||||
var tr = _window.document.createElement("treerow");
|
ti.appendChild(tr);
|
||||||
appendCatToTree(elt, tr)
|
if (elt.children) {
|
||||||
ti.setAttribute("open", isRoot);
|
var pch = _window.document.createElement("treechildren");
|
||||||
ti.appendChild(tr);
|
for (var k = 0; k < elt.children.length; k++) {
|
||||||
if (elt.children) {
|
createCellElement(pch, elt.children[k], id, _window, false, type);
|
||||||
var pch = _window.document.createElement("treechildren");
|
}
|
||||||
for (var k = 0; k < elt.children.length; k++) {
|
ti.appendChild(pch);
|
||||||
createCellElement(pch, elt.children[k], id, _window, false, type)
|
}
|
||||||
}
|
fatherElement.appendChild(ti);
|
||||||
ti.appendChild(pch);
|
} catch (ex) {
|
||||||
}
|
cout("Can't create cell element: " + ex);
|
||||||
fatherElement.appendChild(ti);
|
return;
|
||||||
} catch (ex) {
|
}
|
||||||
cout("Can't create cell element: " + ex)
|
}
|
||||||
return;
|
|
||||||
}
|
function resetTree (id,_window) {
|
||||||
}
|
var tree = _window.document.getElementById(id);
|
||||||
|
var removeList = _window.document.getElementsByTagName("treechildren");
|
||||||
function resetTree (id,_window) {
|
while( removeList.length !== 0) {
|
||||||
var tree = _window.document.getElementById(id);
|
removeList = _window.document.getElementsByTagName("treechildren");
|
||||||
var removeList = _window.document.getElementsByTagName("treechildren");
|
for (var i=0; i< removeList.length; i++)
|
||||||
while( removeList.length!= 0) {
|
tree.removeChild(removeList[i]);
|
||||||
removeList = _window.document.getElementsByTagName("treechildren");
|
}
|
||||||
for (var i=0; i< removeList.length; i++)
|
}
|
||||||
tree.removeChild(removeList[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
function treeLoad (treeName,_window,type) {
|
||||||
|
var win = getRunningWindow();
|
||||||
|
var tree = _window.document.getElementById(treeName);
|
||||||
function treeLoad (treeName,_window,type) {
|
if ( !tree ) {
|
||||||
var win = getRunningWindow();
|
cout('Can not find tree');
|
||||||
var tree = _window.document.getElementById(treeName);
|
return;
|
||||||
if ( !tree ) {
|
}
|
||||||
cout('Can not find tree');
|
resetTree(treeName,_window);
|
||||||
return;
|
var root = _window.document.createElement("treechildren");
|
||||||
}
|
createCellElement(root, rss_obj, 0, _window, true,type );
|
||||||
resetTree(treeName,_window);
|
tree.appendChild(root);
|
||||||
var root = _window.document.createElement("treechildren");
|
}
|
||||||
createCellElement(root, rss_obj, 0, _window, true,type );
|
|
||||||
tree.appendChild(root);
|
function getRSSFile() {
|
||||||
}
|
if (rss_file !== null)
|
||||||
|
return rss_file;
|
||||||
function getRSSFile() {
|
rss_file = TRACKMENOT.utils.getProfileDir().clone();
|
||||||
if (rss_file!= null) return rss_file;
|
rss_file.append("TRACKMENOT");
|
||||||
rss_file = TRACKMENOT.utils.getProfileDir().clone();
|
if( !rss_file.exists() || !rss_file.isDirectory() )
|
||||||
rss_file.append("TRACKMENOT");
|
rss_file.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
|
||||||
if( !rss_file.exists() || !rss_file.isDirectory() )
|
rss_file.append('TMNRss');
|
||||||
rss_file.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
|
return rss_file;
|
||||||
rss_file.append('TMNRss');
|
}
|
||||||
return rss_file;
|
|
||||||
}
|
function getRSSJsonString() {
|
||||||
|
var data = "";
|
||||||
function getRSSJsonString() {
|
try {
|
||||||
try {
|
var file = getRSSFile();
|
||||||
var file = getRSSFile();
|
var fstream = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
||||||
var data = "";
|
.createInstance(Components.interfaces.nsIFileInputStream);
|
||||||
var fstream = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
var sstream = Components.classes["@mozilla.org/scriptableinputstream;1"]
|
||||||
.createInstance(Components.interfaces.nsIFileInputStream);
|
.createInstance(Components.interfaces.nsIScriptableInputStream);
|
||||||
var sstream = Components.classes["@mozilla.org/scriptableinputstream;1"]
|
fstream.init(file, -1, 0, 0);
|
||||||
.createInstance(Components.interfaces.nsIScriptableInputStream);
|
sstream.init(fstream);
|
||||||
fstream.init(file, -1, 0, 0);
|
|
||||||
sstream.init(fstream);
|
var str = sstream.read(4096);
|
||||||
|
while (str.length > 0) {
|
||||||
var str = sstream.read(4096);
|
data += str;
|
||||||
while (str.length > 0) {
|
str = sstream.read(4096);
|
||||||
data += str;
|
}
|
||||||
str = sstream.read(4096);
|
|
||||||
}
|
sstream.close();
|
||||||
|
fstream.close();
|
||||||
sstream.close();
|
} catch (ex) {
|
||||||
fstream.close();
|
data = '{"id":"TMN RSS","type":"root","children":[{"id":"Sport","type":"category","children":[{"id":"http://sports-ak.espn.go.com/espn/rss/news","type":"RSS"}]},{"id":"News","type":"category","children":[{"id":"http://rss.cnn.com/rss/cnn_latest.rss","type":"RSS"}]},{"id":"IT","type":"category","children":[{"id":"http://rss.slashdot.org/Slashdot/slashdot","type":"RSS"}]},{"id":"Entertainment","type":"category","children":[{"id":"http://rss.imdb.com/news/","type":"RSS"}]}]}';
|
||||||
} catch (ex) {
|
}
|
||||||
data = '{"id":"TMN RSS","type":"root","children":[{"id":"Sport","type":"category","children":[{"id":"http://sports-ak.espn.go.com/espn/rss/news","type":"RSS"}]},{"id":"News","type":"category","children":[{"id":"http://rss.cnn.com/rss/cnn_latest.rss","type":"RSS"}]},{"id":"IT","type":"category","children":[{"id":"http://rss.slashdot.org/Slashdot/slashdot","type":"RSS"}]},{"id":"Entertainment","type":"category","children":[{"id":"http://rss.imdb.com/news/","type":"RSS"}]}]}';
|
if ( data.length < 10 || data =='null' )
|
||||||
}
|
data = '{"id":"TMN RSS","type":"root","children":[{"id":"Sport","type":"category","children":[{"id":"http://sports-ak.espn.go.com/espn/rss/news","type":"RSS"}]},{"id":"News","type":"category","children":[{"id":"http://rss.cnn.com/rss/cnn_latest.rss","type":"RSS"}]},{"id":"IT","type":"category","children":[{"id":"http://rss.slashdot.org/Slashdot/slashdot","type":"RSS"}]},{"id":"Entertainment","type":"category","children":[{"id":"http://rss.imdb.com/news/","type":"RSS"}]}]}';
|
||||||
if ( data.length < 10 || data =='null' )
|
return data;
|
||||||
data = '{"id":"TMN RSS","type":"root","children":[{"id":"Sport","type":"category","children":[{"id":"http://sports-ak.espn.go.com/espn/rss/news","type":"RSS"}]},{"id":"News","type":"category","children":[{"id":"http://rss.cnn.com/rss/cnn_latest.rss","type":"RSS"}]},{"id":"IT","type":"category","children":[{"id":"http://rss.slashdot.org/Slashdot/slashdot","type":"RSS"}]},{"id":"Entertainment","type":"category","children":[{"id":"http://rss.imdb.com/news/","type":"RSS"}]}]}';
|
}
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
function setIntPreference(prefName,prefValue) {
|
||||||
|
if ( document.getElementById(prefValue) && document.getElementById(prefValue).value !== "" )
|
||||||
function setIntPreference(prefName,prefValue) {
|
this.prefs.setIntPref(prefName,document.getElementById(prefValue).value);
|
||||||
if ( document.getElementById(prefValue) && document.getElementById(prefValue).value!= "" )
|
}
|
||||||
this.prefs.setIntPref(prefName,document.getElementById(prefValue).value);
|
|
||||||
}
|
function getObjectByID( id, father ) {
|
||||||
|
var result = null;
|
||||||
function getObjectByID( id, father ) {
|
for each(var elt in father.children ) {
|
||||||
var result = null;
|
if (elt.id == id) result = elt;
|
||||||
for each(var elt in father.children ) {
|
else result = getObjectByID( id,elt);
|
||||||
if (elt.id == id) result = elt;
|
if( result !== null) return result;
|
||||||
else result = getObjectByID( id,elt);
|
}
|
||||||
if( result != null) return result;
|
return result;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
function getFatherByID( id, father ) {
|
||||||
|
var result = null;
|
||||||
function getFatherByID( id, father ) {
|
for each(var elt in father.children ) {
|
||||||
var result = null;
|
if (elt.id === id) result = father;
|
||||||
for each(var elt in father.children ) {
|
else result = getFatherByID( id,elt);
|
||||||
if (elt.id == id) result = father;
|
if( result !== null) return result;
|
||||||
else result = getFatherByID( id,elt);
|
}
|
||||||
if( result != null) return result;
|
return result;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
function newCategory ( val, type) {
|
||||||
|
var entr = {};
|
||||||
function newCategory ( val, type) {
|
entr.id = val;
|
||||||
var entr = {};
|
entr.type = type;
|
||||||
entr.id = val;
|
entr.children = [];
|
||||||
entr.type = type;
|
return entr;
|
||||||
entr.children = new Array();
|
}
|
||||||
return entr;
|
|
||||||
}
|
function newRSS(url,parent) {
|
||||||
|
var entr = {};
|
||||||
function newRSS(url,parent) {
|
entr.id = url;
|
||||||
var entr = {};
|
entr.type = "RSS";
|
||||||
entr.id = url;
|
return entr;
|
||||||
entr.type = "RSS";
|
}
|
||||||
return entr;
|
|
||||||
}
|
function getFeedURL() {
|
||||||
|
var searched = document.location.search.substr(1);
|
||||||
function getFeedURL() {
|
var uriArray = searched.split("tmn_feed=");
|
||||||
var searched = document.location.search.substr(1);
|
return decodeURIComponent(uriArray[1]);
|
||||||
var uriArray = searched.split("tmn_feed=");
|
}
|
||||||
return decodeURIComponent(uriArray[1]);
|
|
||||||
}
|
|
||||||
|
return {
|
||||||
|
_loadTree : function(reload) {
|
||||||
return {
|
if (!rss_obj || reload) TRACKMENOT.editor._loadRSS();
|
||||||
_loadTree : function(reload) {
|
treeLoad('tree-rss',window);
|
||||||
if (!rss_obj || reload) TRACKMENOT.editor._loadRSS();
|
},
|
||||||
treeLoad('tree-rss',window);
|
|
||||||
},
|
_loadCategoryTree : function(reload) {
|
||||||
|
if (!rss_obj || reload) TRACKMENOT.editor._loadRSS();
|
||||||
_loadCategoryTree : function(reload) {
|
treeLoad('tree-rss',window,'category');
|
||||||
if (!rss_obj || reload) TRACKMENOT.editor._loadRSS();
|
},
|
||||||
treeLoad('tree-rss',window,'category');
|
|
||||||
},
|
_loadRSS : function () {
|
||||||
|
var rss = getRSSJsonString();
|
||||||
_loadRSS : function () {
|
rss_obj = JSON.parse(rss);
|
||||||
var rss = getRSSJsonString();
|
},
|
||||||
rss_obj = JSON.parse(rss);
|
|
||||||
},
|
|
||||||
|
_addRSS : function () {
|
||||||
|
var rss = getRSSJsonString();
|
||||||
_addRSS : function () {
|
rss_obj = JSON.parse(rss);
|
||||||
var rss = getRSSJsonString();
|
},
|
||||||
rss_obj = JSON.parse(rss);
|
|
||||||
},
|
_addCategory : function () {
|
||||||
|
var rss = getRSSJsonString();
|
||||||
_addCategory : function () {
|
var rss_obj = JSON.parse(rss);
|
||||||
var rss = getRSSJsonString();
|
},
|
||||||
var rss_obj = JSON.parse(rss);
|
|
||||||
},
|
_deleteRSS : function () {
|
||||||
|
var rss = getObjectByID(tree_item,rss_obj);
|
||||||
_deleteRSS : function () {
|
rss_obj.delete(rss);
|
||||||
var rss = getObjectByID(tree_item,rss_obj);
|
},
|
||||||
rss_obj.delete(rss);
|
|
||||||
},
|
_deleteItem: function () {
|
||||||
|
var tree = document.getElementById('tree-rss');
|
||||||
_deleteItem: function () {
|
var entry = tree.view.getCellText(tree.currentIndex,tree.columns.getColumnAt(0));
|
||||||
var tree = document.getElementById('tree-rss');
|
var cat = getObjectByID(entry,rss_obj);
|
||||||
var entry = tree.view.getCellText(tree.currentIndex,tree.columns.getColumnAt(0));
|
var father = getFatherByID(entry,rss_obj);
|
||||||
var cat = getObjectByID(entry,rss_obj);
|
var catIndex = father.children.indexOf(cat);
|
||||||
var father = getFatherByID(entry,rss_obj);
|
father.children.splice(catIndex,1);
|
||||||
var catIndex = father.children.indexOf(cat);
|
TRACKMENOT.editor._saveRSS();
|
||||||
father.children.splice(catIndex,1);
|
TRACKMENOT.editor._loadTree();
|
||||||
TRACKMENOT.editor._saveRSS();
|
},
|
||||||
TRACKMENOT.editor._loadTree();
|
|
||||||
},
|
_getRSS : function () {
|
||||||
|
var rss = getRSSJsonString();
|
||||||
_getRSS : function () {
|
rss_obj = JSON.parse(rss);
|
||||||
var rss = getRSSJsonString();
|
},
|
||||||
rss_obj = JSON.parse(rss);
|
|
||||||
},
|
_addEntry : function () {
|
||||||
|
var entry = document.getElementById('text-entry').value;
|
||||||
_addEntry : function () {
|
switch (tree_state) {
|
||||||
var entry = document.getElementById('text-entry').value;
|
case 'root' :
|
||||||
switch (tree_state) {
|
rss_obj.children.push(newCategory(entry,'category'));
|
||||||
case 'root' :
|
break;
|
||||||
rss_obj.children.push(newCategory(entry,'category'));
|
case 'category':
|
||||||
break;
|
var cat = getObjectByID(tree_item,rss_obj);
|
||||||
case 'category':
|
cat.children.push(newRSS(entry));
|
||||||
var cat = getObjectByID(tree_item,rss_obj);
|
break;
|
||||||
cat.children.push(newRSS(entry))
|
case 'rss':
|
||||||
break;
|
var cat = getObjectByID(tree_item,rss_obj);
|
||||||
case 'rss':
|
cat.children.push(newRSS(entry));
|
||||||
var cat = getObjectByID(tree_item,rss_obj);
|
break;
|
||||||
cat.children.push(newRSS(entry))
|
default :
|
||||||
break;
|
rss_obj.children.push(newCategory(entry,'category'));
|
||||||
default :
|
break;
|
||||||
rss_obj.children.push(newCategory(entry,'category'));
|
}
|
||||||
break;
|
TRACKMENOT.editor._saveRSS();
|
||||||
}
|
TRACKMENOT.editor._loadTree();
|
||||||
TRACKMENOT.editor._saveRSS();
|
},
|
||||||
TRACKMENOT.editor._loadTree();
|
|
||||||
},
|
_getObjByType: function( obj, type, result) {
|
||||||
|
for each(var elt in obj.children ) {
|
||||||
_getObjByType: function( obj, type, result) {
|
if (elt.type == type) result.push(elt);
|
||||||
for each(var elt in obj.children ) {
|
TRACKMENOT.editor._getObjByType( elt, type, result);
|
||||||
if (elt.type == type) result.push(elt);
|
}
|
||||||
TRACKMENOT.editor._getObjByType( elt, type, result);
|
return result;
|
||||||
}
|
},
|
||||||
return result;
|
|
||||||
},
|
_getRSSObj: function () {
|
||||||
|
if (!rss_obj) TRACKMENOT.editor._loadRSS();
|
||||||
_getRSSObj: function () {
|
return rss_obj;
|
||||||
if (!rss_obj) TRACKMENOT.editor._loadRSS();
|
},
|
||||||
return rss_obj;
|
|
||||||
},
|
_setRSSObj: function (str) {
|
||||||
|
rss_obj = str ;
|
||||||
_setRSSObj: function (str) {
|
TRACKMENOT.editor._saveRSS();
|
||||||
rss_obj = str ;
|
} ,
|
||||||
TRACKMENOT.editor._saveRSS();
|
|
||||||
} ,
|
_edit : function() {
|
||||||
|
var tree = document.getElementById('tree-rss');
|
||||||
_edit : function() {
|
var id = tree.view.getCellText(tree.currentIndex,tree.columns.getColumnAt(0));
|
||||||
var tree = document.getElementById('tree-rss');
|
window.openDialog("chrome://trackmenot/content/editeentry.xul", "trackmenotEditeEntry", "chrome,dialog,centerscreen,alwaysRaised",id);
|
||||||
var id = tree.view.getCellText(tree.currentIndex,tree.columns.getColumnAt(0));
|
},
|
||||||
window.openDialog("chrome://trackmenot/content/editeentry.xul", "trackmenotEditeEntry", "chrome,dialog,centerscreen,alwaysRaised",id);
|
|
||||||
},
|
_loadEntryWindow : function(id) {
|
||||||
|
window.document.getElementById('entry-text').value = id;
|
||||||
_loadEntryWindow : function(id) {
|
rss_obj = window.opener.TRACKMENOT.editor._getRSSObj();
|
||||||
window.document.getElementById('entry-text').value = id;
|
},
|
||||||
rss_obj = window.opener.TRACKMENOT.editor._getRSSObj();
|
|
||||||
},
|
_saveEntryChange: function(old_id) {
|
||||||
|
var obj = getObjectByID(old_id,rss_obj);
|
||||||
_saveEntryChange: function(old_id) {
|
obj.id = window.document.getElementById('entry-text').value;
|
||||||
var obj = getObjectByID(old_id,rss_obj);
|
window.opener.TRACKMENOT.editor._setRSSObj(rss_obj);
|
||||||
obj.id = window.document.getElementById('entry-text').value;
|
window.opener.TRACKMENOT.editor._loadTree();
|
||||||
window.opener.TRACKMENOT.editor._setRSSObj(rss_obj)
|
return;
|
||||||
window.opener.TRACKMENOT.editor._loadTree();
|
},
|
||||||
return;
|
|
||||||
},
|
_updateTextLabel : function () {
|
||||||
|
var win = getRunningWindow();
|
||||||
_updateTextLabel : function () {
|
if (!win ) return;
|
||||||
var win = getRunningWindow();
|
var tree = document.getElementById('tree-rss');
|
||||||
if (!win ) return;
|
var sel = tree.view.selection.currentIndex; //returns -1 if the tree is not focused
|
||||||
var tree = document.getElementById('tree-rss');
|
var treeItem = tree.view.getItemAtIndex(sel);
|
||||||
var sel = tree.view.selection.currentIndex; //returns -1 if the tree is not focused
|
var eltType = treeItem.childNodes[0].childNodes[1].getAttribute('label');
|
||||||
var treeItem = tree.view.getItemAtIndex(sel);
|
tree_state = eltType;
|
||||||
var eltType = treeItem.childNodes[0].childNodes[1].getAttribute('label');
|
tree_item = treeItem.childNodes[0].childNodes[0].getAttribute('label') ;
|
||||||
tree_state = eltType;
|
switch (eltType) {
|
||||||
tree_item = treeItem.childNodes[0].childNodes[0].getAttribute('label') ;
|
case 'root' :
|
||||||
switch (eltType) {
|
document.getElementById('entry-label').value = 'Category';
|
||||||
case 'root' :
|
document.getElementById("add-entry").label = 'Add Category';
|
||||||
document.getElementById('entry-label').value = 'Category';
|
break;
|
||||||
document.getElementById("add-entry").label = 'Add Category';
|
case 'category':
|
||||||
break;
|
document.getElementById('entry-label').value = 'RSS';
|
||||||
case 'category':
|
document.getElementById("add-entry").label = 'Add RSS';
|
||||||
document.getElementById('entry-label').value = 'RSS';
|
break;
|
||||||
document.getElementById("add-entry").label = 'Add RSS';
|
case 'rss':
|
||||||
break;
|
document.getElementById('entry-label').value = 'RSS';
|
||||||
case 'rss':
|
document.getElementById("add-entry").label = 'Add RSS';
|
||||||
document.getElementById('entry-label').value = 'RSS';
|
break;
|
||||||
document.getElementById("add-entry").label = 'Add RSS';
|
}
|
||||||
break;
|
},
|
||||||
}
|
|
||||||
},
|
|
||||||
|
_onFeedPageLoad :function() {
|
||||||
|
new_feed_uri = getFeedURL();
|
||||||
_onFeedPageLoad :function() {
|
if (new_feed_uri !== "") {
|
||||||
new_feed_uri = getFeedURL();
|
cout("Adding new feed: "+ new_feed_uri);
|
||||||
if (new_feed_uri != "") {
|
openDialog("chrome://trackmenot/content/selectcat.xul", "TrackMeNot RSS Handler","chrome,centerscreen,resizable=yes,width=230,height=250",new_feed_uri);
|
||||||
cout("Adding new feed: "+ new_feed_uri);
|
}
|
||||||
openDialog("chrome://trackmenot/content/selectcat.xul", "TrackMeNot RSS Handler","chrome,centerscreen,resizable=yes,width=230,height=250",new_feed_uri)
|
return;
|
||||||
}
|
},
|
||||||
return;
|
|
||||||
},
|
_onSelectTopicLoad: function(e) {
|
||||||
|
TRACKMENOT.editor._loadCategoryTree();
|
||||||
_onSelectTopicLoad: function(e) {
|
var attributes = new Array ('text');
|
||||||
TRACKMENOT.editor._loadCategoryTree();
|
if("arguments" in window && window.arguments.length > 0) {
|
||||||
var attributes = new Array ('text')
|
new_feed_uri = window.arguments[0];
|
||||||
if("arguments" in window && window.arguments.length > 0) {
|
cout("Selecting a topic for feed: "+ new_feed_uri);
|
||||||
new_feed_uri = window.arguments[0];
|
}
|
||||||
cout("Selecting a topic for feed: "+ new_feed_uri);
|
return;
|
||||||
}
|
},
|
||||||
return;
|
|
||||||
},
|
_addFlowToTopic: function() {
|
||||||
|
var win = getRunningWindow();
|
||||||
_addFlowToTopic: function() {
|
var tree = document.getElementById("tree-rss");
|
||||||
var win = getRunningWindow();
|
var sel = tree.view.selection.currentIndex; //returns -1 if the tree is not focused
|
||||||
var tree = document.getElementById("tree-rss");
|
var treeItem = tree.view.getItemAtIndex(sel);
|
||||||
var sel = tree.view.selection.currentIndex; //returns -1 if the tree is not focused
|
var cat_text = treeItem.childNodes[0].childNodes[0].getAttribute('label') ;
|
||||||
var treeItem = tree.view.getItemAtIndex(sel);
|
cout("Feed " + new_feed_uri + "\n is going to be added to category: "+cat_text);
|
||||||
var cat_text = treeItem.childNodes[0].childNodes[0].getAttribute('label') ;
|
if (!rss_obj) TRACKMENOT.editor._loadRSS();
|
||||||
cout("Feed " + new_feed_uri + "\n is going to be added to category: "+cat_text);
|
var cat = getObjectByID(cat_text,rss_obj);
|
||||||
if (!rss_obj) TRACKMENOT.editor._loadRSS();
|
cat.children.push(newRSS(new_feed_uri));
|
||||||
var cat = getObjectByID(cat_text,rss_obj);
|
TRACKMENOT.editor._saveRSS();
|
||||||
cat.children.push(newRSS(new_feed_uri));
|
},
|
||||||
TRACKMENOT.editor._saveRSS();
|
|
||||||
},
|
_saveRSS : function () {
|
||||||
|
var file = getRSSFile();
|
||||||
_saveRSS : function () {
|
var foStream = TRACKMENOT.utils.getFoStream();
|
||||||
var file = getRSSFile();
|
foStream.init(file, 0x02 | 0x08 | 0x20, 0664, 0);
|
||||||
var foStream = TRACKMENOT.utils.getFoStream();
|
var jsonString = JSON.stringify(rss_obj);
|
||||||
foStream.init(file, 0x02 | 0x08 | 0x20, 0664, 0);
|
cout(jsonString);
|
||||||
var jsonString = JSON.stringify(rss_obj);
|
foStream.write(jsonString, jsonString.length,'','iso-8859-1');
|
||||||
cout(jsonString)
|
foStream.close();
|
||||||
foStream.write(jsonString, jsonString.length,'','iso-8859-1');
|
},
|
||||||
foStream.close();
|
|
||||||
},
|
|
||||||
|
};
|
||||||
|
|
||||||
};
|
}();
|
||||||
|
|
||||||
}();
|
|
||||||
|
|
Loading…
Reference in a new issue