refactored Javascript and make related changes in other files

git-svn-id: file:///tmp/snv/trunk@8 12951d8a-c33d-4b7c-b961-822215c816e1
master
Abhinav Sarkar 2008-12-02 17:41:31 +00:00
parent 5b4693e621
commit 3d33406796
5 changed files with 300 additions and 295 deletions

View File

@ -1,7 +1,6 @@
move to JSON data format -- done move to JSON data format -- done
XBL -- done XBL -- done
externalize strings format JS/refactor JS/Use FUEL -- done
format JS/refactor JS/Use FUEL
put license put license
caching/db, threading, XUL templates caching/db, threading, XUL templates
new UI new UI

View File

@ -1,307 +1,295 @@
var gsti; var DiggSidebar = {
var currentStories = new Array(); prefs: Application.extensions.get("diggsidebar@abhinavsarkar.net").prefs,
var playing = true; categories: ['All', 'Popular', 'Upcoming', 'Hot', 'Top'],
timerId : null,
currentStories : new Array(),
playing : true,
//getElementById fetchData: function(url, handler) {
function $ei(id, parentNode) { DiggSidebar.diggIndicator.style.display = '';
parentNode = parentNode || document;
return parentNode.getElementById(id);
}
function fetchData(url, handler) { var request = new XMLHttpRequest();
//alert("inside fetchData"); request.onerror = DiggSidebar.errorHandler;
$ei('diggIndicator').style.display = ''; request.onload = handler;
$ei("diggIndicator").setAttribute('mode', 'undetermined'); request.open("GET", url, true);
var request = Components. request.send(null);
classes["@mozilla.org/xmlextras/xmlhttprequest;1"]. },
createInstance();
// QI the object to nsIDOMEventTarget to set event handlers on it: errorHandler: function(e) {
window.alert("Error in accessing data from Digg");
},
request.QueryInterface(Components.interfaces.nsIDOMEventTarget); populateMenu: function(e) {
request.addEventListener("load", handler, false); var XHR = e.target;
request.addEventListener("error", handleError, false); var data = DiggSidebar.Utils.decodeJson(XHR.responseText);
var topics = data.topics;
var containers = new Array();
// QI it to nsIXMLHttpRequest to open and send the request: while (DiggSidebar.topicPopup.firstChild) {
DiggSidebar.topicPopup.removeChild(DiggSidebar.topicPopup.firstChild);
request.QueryInterface(Components.interfaces.nsIXMLHttpRequest);
request.open("GET", url, true);
request.send(null);
//$ei('diggIndicator').style.display = '';
}
function handleError(e) {
$ei('storyList').appendItem("!! Error accessing Digg !!");
//$ei('diggIndicator').style.display = 'none';
}
function populateMenu(e) {
XHR = e.target;
data = decodeJson(XHR.responseText);
topics = data.topics;
containers = new Array();
while ($ei('topicPopup').firstChild) {
$ei('topicPopup').removeChild($ei('topicPopup').firstChild);
}
topics.forEach(function (topic) {
menu = document.createElement('menu');
menu.setAttribute('id', topic.short_name + 'Menu');
menu.setAttribute('label', topic.name);
menu.setAttribute('accesskey', topic.name.charAt(0));
menupopup = document.createElement('menupopup');
menupopup.setAttribute('id', topic.short_name + 'Popup');
['All', 'Popular', 'Upcoming', 'Hot', 'Top'].forEach(
function (label) {
menuitem = document.createElement('menuitem');
menuitem.setAttribute('label', label);
menuitem.setAttribute('value', '/topic/' + topic.short_name + '/' + label.toLowerCase());
menuitem.setAttribute('accesskey', label.charAt(0));
menuitem.setAttribute('oncommand', "setEndPoint(this.value)");
menupopup.appendChild(menuitem);
}
);
menu.appendChild(menupopup);
$ei('topicPopup').appendChild(menu);
containers.push(topic.container);
});
while ($ei('containerPopup').firstChild) {
$ei('containerPopup').removeChild($ei('containerPopup').firstChild);
}
filteredContainers = {name: [], short_name: []};
containers.forEach(function (container) {
name = container.name;
short_name = container.short_name;
if (filteredContainers.name.indexOf(name) == -1) {
filteredContainers.name.push(name);
filteredContainers.short_name.push(short_name);
} }
});
for (i=0; i<filteredContainers.name.length; i++) { topics.forEach(function (topic) {
menu = document.createElement('menu'); var menu = document.createElement('menu');
menu.setAttribute('id', filteredContainers.short_name[i] + 'Menu'); menu.setAttribute('id', topic.short_name + 'Menu');
menu.setAttribute('label', filteredContainers.name[i]); menu.setAttribute('label', topic.name);
menu.setAttribute('accesskey', filteredContainers.name[i].charAt(0)); menu.setAttribute('accesskey', topic.name.charAt(0));
menupopup = document.createElement('menupopup'); var menupopup = document.createElement('menupopup');
menupopup.setAttribute('id', filteredContainers.short_name[i] + 'Popup'); menupopup.setAttribute('id', topic.short_name + 'Popup');
['All', 'Popular', 'Upcoming', 'Hot', 'Top'].forEach( DiggSidebar.categories.forEach(
function (label) { function (label) {
menuitem = document.createElement('menuitem'); var menuitem = document.createElement('menuitem');
menuitem.setAttribute('label', label); menuitem.setAttribute('label', label);
menuitem.setAttribute('value', '/container/' + menuitem.setAttribute('value', '/topic/' + topic.short_name + '/' + label.toLowerCase());
filteredContainers.short_name[i] + '/' + label.toLowerCase()); menuitem.setAttribute('accesskey', label.charAt(0));
menuitem.setAttribute('accesskey', label.charAt(0)); menuitem.setAttribute('oncommand', "DiggSidebar.setEndPoint(this.value)");
menuitem.setAttribute('oncommand', "setEndPoint(this.value)"); menupopup.appendChild(menuitem);
menupopup.appendChild(menuitem); }
);
menu.appendChild(menupopup);
DiggSidebar.topicPopup.appendChild(menu);
containers.push(topic.container);
});
while (DiggSidebar.containerPopup.firstChild) {
DiggSidebar.containerPopup.removeChild(DiggSidebar.containerPopup.firstChild);
}
var filteredContainers = {name: [], short_name: []};
containers.forEach(function (container) {
var name = container.name;
var short_name = container.short_name;
if (filteredContainers.name.indexOf(name) == -1) {
filteredContainers.name.push(name);
filteredContainers.short_name.push(short_name);
} }
); });
menu.appendChild(menupopup); for (var i=0; i<filteredContainers.name.length; i++) {
$ei('containerPopup').appendChild(menu); var menu = document.createElement('menu');
} menu.setAttribute('id', filteredContainers.short_name[i] + 'Menu');
$ei('diggIndicator').style.display = 'none'; menu.setAttribute('label', filteredContainers.name[i]);
} menu.setAttribute('accesskey', filteredContainers.name[i].charAt(0));
function populateStoryList(e) { var menupopup = document.createElement('menupopup');
XHR = e.target; menupopup.setAttribute('id', filteredContainers.short_name[i] + 'Popup');
//Application.console.log(XHR.responseText);
data = decodeJson(XHR.responseText);
stories = data.stories;
while ($ei('storyList').firstChild) { DiggSidebar.categories.forEach(
$ei('storyList').removeChild($ei('storyList').firstChild); function (label) {
} var menuitem = document.createElement('menuitem');
menuitem.setAttribute('label', label);
menuitem.setAttribute('value', '/container/' +
filteredContainers.short_name[i] + '/' + label.toLowerCase());
menuitem.setAttribute('accesskey', label.charAt(0));
menuitem.setAttribute('oncommand', "DiggSidebar.setEndPoint(this.value)");
menupopup.appendChild(menuitem);
}
);
var newStories = new Array(); menu.appendChild(menupopup);
//Application.console.log(stories.length); DiggSidebar.containerPopup.appendChild(menu);
}
DiggSidebar.diggIndicator.style.display = 'none';
},
stories.forEach(function (story) { populateStoryList: function(e) {
newStories.push(story.id); var XHR = e.target;
//Application.console.log(i + " " + story.title + " " + story.id); //Application.console.log(XHR.responseText);
var data = DiggSidebar.Utils.decodeJson(XHR.responseText);
var stories = data.stories;
listitem = $ei('storyList').appendChild(document.createElement('richlistitem')); while (DiggSidebar.storyList.firstChild) {
listitem.id = "story_" + story.id; DiggSidebar.storyList.removeChild(DiggSidebar.storyList.firstChild);
listitem.setAttribute('title', story.title); }
if (currentStories.indexOf(story.id) != -1) listitem.new = false; var newStories = new Array();
}); //Application.console.log(stories.length);
currentStories = newStories;
//Adaptive update interval code START stories.forEach(function (story) {
sum = 0; newStories.push(story.id);
weights = [4, 3, 2, 1] //Application.console.log(i + " " + story.title + " " + story.id);
date = (stories[0].promote_date != null) ? 'promote_date' : 'submit_date';
stories.sort(function (a, b) {
if (a[date] > b[date]) return -1;
else if (a[date] < b[date]) return 1;
return 0;
});
for (i=0; i<Math.min(4, stories.length-1); i++) {
diff = stories[i][date] - stories[i+1][date];
sum += weights[i]*diff;
}
updateInterval = Math.round(
sum*1000/weights
.splice(0,Math.min(4, stories.length-1))
.reduce(function(a, b){return a + b;})
);
//Application.console.log(updateInterval);
var prefs = Application.extensions.get("diggsidebar@abhinavsarkar.net").prefs; var listitem = DiggSidebar.storyList.appendChild(document.createElement('richlistitem'));
listitem.id = "story_" + story.id;
listitem.setAttribute('title', story.title);
if (updateInterval > 0) { if (DiggSidebar.currentStories.indexOf(story.id) != -1) listitem.new = false;
previousUpdateInterval = prefs.get("updateinterval").value; });
prefs.get("updateinterval").value = updateInterval; DiggSidebar.currentStories = newStories;
DiggSidebar.setUpdateInterval(stories);
DiggSidebar.diggIndicator.style.display = 'none';
},
updateIntervalDecay = prefs.get("updateintervaldecay").value; populateDescription: function(e) {
var XHR = e.target;
//Application.console.log(XHR.responseText);
var data = DiggSidebar.Utils.decodeJson(XHR.responseText);
var story = data.stories[0];
if (previousUpdateInterval == updateInterval) var now = new Date();
prefs.get("updateintervaldecay").value = updateIntervalDecay + 1; if (story.promote_date != null)
var then = new Date(story.promote_date*1000);
else else
prefs.get("updateintervaldecay").value = 0; var then = new Date(story.submit_date*1000);
} var diff = Math.max(now - then, 0)
window.clearTimeout(gsti);
updateInterval = prefs.get("updateinterval").value; var hr = Math.floor(diff/(1000*3600));
updateIntervalDecay = prefs.get("updateintervaldecay").value; var min = Math.floor(diff/(1000*60)) - 60*hr;
timeout = Math.round(updateInterval*(Math.pow(1.5, updateIntervalDecay))); var listitems = document.getElementsByTagName('richlistitem');
gsti = window.setTimeout(getStories, timeout); for (var i=0; i<listitems.length; i++) {
//Adaptive update interval code END listitems[i].hideDesc();
$ei('diggIndicator').style.display = 'none';
}
function populateDescription(e) {
XHR = e.target;
//Application.console.log(XHR.responseText);
data = decodeJson(XHR.responseText);
story = data.stories[0];
now = new Date();
if (story.promote_date != null)
then = new Date(story.promote_date*1000);
else
then = new Date(story.submit_date*1000);
diff = Math.max(now - then, 0)
hr = Math.floor(diff/(1000*3600));
min = Math.floor(diff/(1000*60)) - 60*hr;
listitems = document.getElementsByTagName('richlistitem');
for (i=0; i<listitems.length; i++) {
listitems[i].hideDesc();
}
li = $ei('story_'+ story.id)
storyDate = ((hr > 0) && (min > 0)) ?
(hr + " hr " + min + " mins ago") :
((hr == 0) && (min > 0)) ?
(min + " mins ago") :
((hr == 0) && (min == 0)) ?
"just now" : "";
li.setAttribute('date', storyDate);
li.setAttribute('status', story.status);
li.setAttribute('container', story.container.name);
li.setAttribute('topic', story.topic.name);
li.setAttribute('username', story.user.name);
li.setAttribute('userlink', "http://digg.com/users/" + story.user.name);
li.setAttribute('diggs', story.diggs);
li.setAttribute('comments', story.comments);
li.setAttribute('desc', story.description);
li.setAttribute('link', story.link);
li.setAttribute('href', story.href);
li.read = true;
li.new = false;
li.showDesc()
$ei('diggIndicator').style.display = 'none';
}
function getStories() {
var prefs = Application.extensions.get("diggsidebar@abhinavsarkar.net").prefs;
ep = prefs.get("endpoint").value || '';
$ei('diggEndPoint').value = "digg" + ep;
fetchData("http://services.digg.com/stories" + ep.replace(/\/all/g, '') +
"?count=30" + "&type=json" +
"&appkey=" + encodeURIComponent("http://diggsidebar.googlepages.com"),
populateStoryList);
//gsti = window.setTimeout(getStories, prefs.getIntPref("extensions.diggsidebar.updateinterval"));
}
function getDescription(storyId) {
if (storyId == null) return;
fetchData("http://services.digg.com/story/" + storyId + "?type=json" +
"&appkey=" + encodeURIComponent("http://diggsidebar.googlepages.com"),
populateDescription);
}
function createMenu() {
fetchData("http://services.digg.com/topics" + "?type=json" +
"&appkey=" + encodeURIComponent("http://diggsidebar.googlepages.com"),
populateMenu);
}
function openInTab(href) {
var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindow);
mainWindow.getBrowser().selectedTab = mainWindow.getBrowser().addTab(href);
}
function setEndPoint(ep) {
var prefs = Application.extensions.get("diggsidebar@abhinavsarkar.net").prefs;
prefs.get("endpoint").value = ep;
window.clearTimeout(gsti);
//window.clearInterval(psi);
getStories();
}
function togglePlayPause() {
if (playing) {
window.clearTimeout(gsti);
//window.clearInterval(psi);
$ei('diggPlayPause').image = "chrome://diggsidebar/content/image/Play.png";
$ei('diggPlayPause').setAttribute("tooltiptext", "Click to Start autoupdate");
playing = false;
} else {
var prefs = Application.extensions.get("diggsidebar@abhinavsarkar.net").prefs;
updateInterval = prefs.get("extensions.diggsidebar.updateinterval").value;
updateIntervalDecay = prefs.get("extensions.diggsidebar.updateintervaldecay").value;
timeout = Math.round(updateInterval*(Math.pow(1.5, updateIntervalDecay)));
//newTimeout = Math.round(timeout*parseInt($ei("diggIndicator").getAttribute('value'))/100);
gsti = window.setTimeout(getStories, timeout);
//psi = window.setInterval(showProgress, Math.round(timeout/100));
//window.setTimeout("window.clearInterval(psi)", newTimeout);
$ei('diggPlayPause').image = "chrome://diggsidebar/content/image/Pause.png";
$ei('diggPlayPause').setAttribute("tooltiptext", "Click to Pause autoupdate");
playing = true;
} }
}
function decodeJson(string) { var li = document.getElementById('story_'+ story.id)
var json = Components.classes["@mozilla.org/dom/json;1"]
.createInstance(Components.interfaces.nsIJSON); var relativeTime = ((hr > 0) && (min > 0)) ?
return json.decode(string); (hr + " hr " + min + " mins ago") :
((hr == 0) && (min > 0)) ?
(min + " mins ago") :
((hr == 0) && (min == 0)) ?
"just now" : "";
li.setAttribute('date', relativeTime);
li.setAttribute('status', story.status);
li.setAttribute('container', story.container.name);
li.setAttribute('topic', story.topic.name);
li.setAttribute('username', story.user.name);
li.setAttribute('userlink', "http://digg.com/users/" + story.user.name);
li.setAttribute('diggs', story.diggs);
li.setAttribute('comments', story.comments);
li.setAttribute('desc', story.description);
li.setAttribute('link', story.link);
li.setAttribute('href', story.href);
li.read = true;
li.new = false;
li.showDesc()
DiggSidebar.diggIndicator.style.display = 'none';
},
getStories: function() {
var ep = DiggSidebar.prefs.get("endpoint").value || '';
DiggSidebar.diggEndPoint.value = "digg" + ep;
DiggSidebar.fetchData("http://services.digg.com/stories" + ep.replace(/\/all/g, '') +
"?count=30" + "&type=json" +
"&appkey=" + encodeURIComponent("http://diggsidebar.googlepages.com"),
DiggSidebar.populateStoryList);
},
getDescription: function(storyId) {
if (storyId == null) return;
DiggSidebar.fetchData("http://services.digg.com/story/" + storyId + "?type=json" +
"&appkey=" + encodeURIComponent("http://diggsidebar.googlepages.com"),
DiggSidebar.populateDescription);
},
createMenu: function() {
DiggSidebar.fetchData("http://services.digg.com/topics" + "?type=json" +
"&appkey=" + encodeURIComponent("http://diggsidebar.googlepages.com"),
DiggSidebar.populateMenu);
},
setUpdateInterval: function(stories) {
//Adaptive update interval code START
var sum = 0;
var weights = [4, 3, 2, 1]
var date = (stories[0].promote_date != null) ? 'promote_date' : 'submit_date';
stories.sort(function (a, b) {
if (a[date] > b[date]) return -1;
else if (a[date] < b[date]) return 1;
return 0;
});
for (var i=0; i<Math.min(4, stories.length-1); i++) {
var diff = stories[i][date] - stories[i+1][date];
sum += weights[i]*diff;
}
var updateInterval = Math.round(
sum*1000/weights
.splice(0,Math.min(4, stories.length-1))
.reduce(function(a, b){return a + b;})
);
//Application.console.log(updateInterval);
if (updateInterval > 0) {
var previousUpdateInterval = DiggSidebar.prefs.get("updateinterval").value;
DiggSidebar.prefs.get("updateinterval").value = updateInterval;
var updateIntervalDecay = DiggSidebar.prefs.get("updateintervaldecay").value;
if (previousUpdateInterval == updateInterval)
DiggSidebar.prefs.get("updateintervaldecay").value = updateIntervalDecay + 1;
else
DiggSidebar.prefs.get("updateintervaldecay").value = 0;
}
window.clearTimeout(DiggSidebar.timerId);
var updateInterval = DiggSidebar.prefs.get("updateinterval").value;
var updateIntervalDecay = DiggSidebar.prefs.get("updateintervaldecay").value;
var timeout = Math.round(updateInterval*(Math.pow(1.5, updateIntervalDecay)));
DiggSidebar.timerId = window.setTimeout(DiggSidebar.getStories, timeout);
//Adaptive update interval code END
},
setEndPoint: function(ep) {
DiggSidebar.prefs.get("endpoint").value = ep;
window.clearTimeout(DiggSidebar.timerId);
DiggSidebar.getStories();
},
togglePlayPause: function() {
if (DiggSidebar.playing) {
window.clearTimeout(DiggSidebar.timerId);
DiggSidebar.diggPlayPause.image = "chrome://diggsidebar/content/image/Play.png";
DiggSidebar.diggPlayPause.setAttribute("tooltiptext", "Click to Start autoupdate");
DiggSidebar.playing = false;
} else {
var updateInterval = DiggSidebar.prefs.get("updateinterval").value;
var updateIntervalDecay = DiggSidebar.prefs.get("updateintervaldecay").value;
var timeout = Math.round(updateInterval*(Math.pow(1.5, updateIntervalDecay)));
DiggSidebar.timerId = window.setTimeout(DiggSidebar.getStories, timeout);
DiggSidebar.diggPlayPause.image = "chrome://diggsidebar/content/image/Pause.png";
DiggSidebar.diggPlayPause.setAttribute("tooltiptext", "Click to Pause autoupdate");
DiggSidebar.playing = true;
}
},
initialize: function(){
var $ = function(id) {return document.getElementById(id)};
DiggSidebar.diggIndicator = $('diggIndicator');
DiggSidebar.topicPopup = $('topicPopup');
DiggSidebar.containerPopup = $('containerPopup');
DiggSidebar.storyList = $('storyList');
DiggSidebar.diggEndPoint = $('diggEndPoint');
DiggSidebar.diggPlayPause = $('diggPlayPause');
DiggSidebar.createMenu();
DiggSidebar.getStories();
}
}; };
DiggSidebar.Utils = {
url: function(spec) {
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
return ios.newURI(spec, null, null);
},
openUrlInTab: function(url) {
Application.activeWindow.open(DiggSidebar.Utils.url(url));
},
decodeJson: function(string) {
var json = Components.classes["@mozilla.org/dom/json;1"]
.createInstance(Components.interfaces.nsIJSON);
return json.decode(string);
}
}
/*TODO /*TODO
preferences preferences
toolbar button toolbar button

View File

@ -6,7 +6,7 @@
<page id="sbDiggSidebar" title="&diggsidebar.title;" <page id="sbDiggSidebar" title="&diggsidebar.title;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="createMenu();getStories()"> onload="DiggSidebar.initialize()">
<script src="chrome://diggsidebar/content/diggsidebar.js" type="application/x-javascript" /> <script src="chrome://diggsidebar/content/diggsidebar.js" type="application/x-javascript" />
<hbox> <hbox>
<toolbar flex="1"> <toolbar flex="1">
@ -14,11 +14,16 @@
<menubar id="diggsidebarMenubar" flex="1" style="width: 100%"> <menubar id="diggsidebarMenubar" flex="1" style="width: 100%">
<menu id="storiesMenu" label="Stories" accesskey="S"> <menu id="storiesMenu" label="Stories" accesskey="S">
<menupopup id="storiesPopup"> <menupopup id="storiesPopup">
<menuitem label="All" value="/all" oncommand="setEndPoint(this.value)" accesskey="A" /> <menuitem label="All" value="/all"
<menuitem label="Popular" value="/popular" oncommand="setEndPoint(this.value)" accesskey="P" /> oncommand="DiggSidebar.setEndPoint(this.value)" accesskey="A" />
<menuitem label="Upcoming" value="/upcoming" oncommand="setEndPoint(this.value)" accesskey="U" /> <menuitem label="Popular" value="/popular"
<menuitem label="Hot" value="/hot" oncommand="setEndPoint(this.value)" accesskey="H" /> oncommand="DiggSidebar.setEndPoint(this.value)" accesskey="P" />
<menuitem label="Top" value="/top" oncommand="setEndPoint(this.value)" accesskey="T" /> <menuitem label="Upcoming" value="/upcoming"
oncommand="DiggSidebar.setEndPoint(this.value)" accesskey="U" />
<menuitem label="Hot" value="/hot"
oncommand="DiggSidebar.setEndPoint(this.value)" accesskey="H" />
<menuitem label="Top" value="/top"
oncommand="DiggSidebar.setEndPoint(this.value)" accesskey="T" />
<menuseparator /> <menuseparator />
<menu id="containerMenu" label="Containers" accesskey="C"> <menu id="containerMenu" label="Containers" accesskey="C">
<menupopup id="containerPopup"> <menupopup id="containerPopup">
@ -34,13 +39,22 @@
</menu> </menu>
</menubar> </menubar>
</toolbaritem> </toolbaritem>
<toolbarbutton id="diggPlayPause" image="chrome://diggsidebar/content/image/Pause.png" tooltiptext="Click to Pause autoupdate" oncommand="togglePlayPause()" /> <toolbarbutton id="diggPlayPause"
image="chrome://diggsidebar/content/image/Pause.png"
tooltiptext="Click to Pause autoupdate"
oncommand="DiggSidebar.togglePlayPause()" />
<toolbarspacer flex="5" /> <toolbarspacer flex="5" />
<toolbaritem> <toolbaritem>
<progressmeter flex="1" width="5" mode="undetermined" id="diggIndicator" style="height: 85% !important; width: 30% !important" /> <progressmeter flex="1"
width="5"
mode="undetermined"
id="diggIndicator"
style="height: 85% !important; width: 30% !important" />
</toolbaritem> </toolbaritem>
</toolbar> </toolbar>
</hbox> </hbox>
<description id="diggEndPoint">digg</description> <description id="diggEndPoint">digg</description>
<richlistbox flex="1" id="storyList" onselect="getDescription(this.selectedItem.id.substr(6))"></richlistbox> <richlistbox flex="1"
id="storyList"
onselect="DiggSidebar.getDescription(this.selectedItem.id.substr(6))" />
</page> </page>

View File

@ -24,12 +24,14 @@
</html:div> </html:div>
<html:div> <html:div>
<html:span xbl:inherits="xbl:text=desc" class="storyDesc"></html:span> <html:span xbl:inherits="xbl:text=desc" class="storyDesc"></html:span>
<html:a xbl:inherits="href=link" class="storyLink" onclick="openInTab(this.href); return false"> <html:a xbl:inherits="href=link" class="storyLink"
onclick="DiggSidebar.Utils.openUrlInTab(this.href); return false">
<html:img src="chrome://diggsidebar/content/image/external.png" /> <html:img src="chrome://diggsidebar/content/image/external.png" />
</html:a> </html:a>
</html:div> </html:div>
<html:div style="text-align:center;"> <html:div style="text-align:center;">
<html:a xbl:inherits="href=href" class="storyHref" onclick="openInTab(this.href); return false"> <html:a xbl:inherits="href=href" class="storyHref"
onclick="DiggSidebar.Utils.openUrlInTab(this.href); return false">
Digg This Digg This
</html:a> </html:a>
</html:div> </html:div>
@ -41,7 +43,9 @@
<html:span xbl:inherits="xbl:text=comments" class="storyComments"></html:span> <html:span xbl:inherits="xbl:text=comments" class="storyComments"></html:span>
</html:span> </html:span>
by by
<html:a xbl:inherits="href=userlink,xbl:text=username" class="storyUserLink" onclick="openInTab(this.href); return false"></html:a> <html:a xbl:inherits="href=userlink,xbl:text=username"
class="storyUserLink"
onclick="DiggSidebar.Utils.openUrlInTab(this.href); return false"></html:a>
<html:span xbl:inherits="xbl:text=date" class="storyDate"></html:span> <html:span xbl:inherits="xbl:text=date" class="storyDate"></html:span>
</html:div> </html:div>
</html:div> </html:div>

View File

@ -17,7 +17,9 @@ a img {
display: none; display: none;
background-color: #ffffff; background-color: #ffffff;
clear: both; clear: both;
border-top: 1px dashed black; border: 1px dashed black;
margin: 0px 8px 8px 8px;
width: 230px;
} }
.storyDetails > div { .storyDetails > div {
clear: both; clear: both;
@ -46,22 +48,20 @@ a img {
} }
.storyHeader { .storyHeader {
cursor: pointer; cursor: pointer;
padding: 2px;
width: 250px;
} }
.storyHref:hover, .storyUserName:hover { .storyHref:hover, .storyUserLink:hover {
color: white; color: white;
background-color: blue; background-color: blue;
} }
#storyList richlistitem{ #storyList richlistitem{
border-bottom: 1px solid black; border-bottom: 1px solid black;
padding-bottom: 3px;
color: #000000!important; color: #000000!important;
-moz-binding: url("chrome://diggsidebar/content/diggstory.xml#diggstoryitem"); -moz-binding: url("chrome://diggsidebar/content/diggstory.xml#diggstoryitem");
} }
richlistitem > vbox > div{
width: 250px;
}
richlistitem[selected="true"] { richlistitem[selected="true"] {
background-color: #FFEBF0; background-color: #FFEBF0;
color: inherit; color: inherit;