git-svn-id: file:///tmp/snv/trunk@6 12951d8a-c33d-4b7c-b961-822215c816e1
This commit is contained in:
parent
a72ed0292c
commit
b9d6c2f9a2
@ -1,4 +1,4 @@
|
|||||||
move to JSON data format
|
move to JSON data format -- done
|
||||||
XBL -> Templates
|
XBL -> Templates
|
||||||
format JS/refactor JS/Use FUEL
|
format JS/refactor JS/Use FUEL
|
||||||
caching/db
|
caching/db
|
||||||
|
@ -94,7 +94,7 @@ function populateMenu(e) {
|
|||||||
menupopup = document.createElement('menupopup');
|
menupopup = document.createElement('menupopup');
|
||||||
menupopup.setAttribute('id', topic.short_name + 'Popup');
|
menupopup.setAttribute('id', topic.short_name + 'Popup');
|
||||||
|
|
||||||
['All', 'Popular', 'Upcoming'].forEach(
|
['All', 'Popular', 'Upcoming', 'Hot', 'Top'].forEach(
|
||||||
function (label) {
|
function (label) {
|
||||||
menuitem = document.createElement('menuitem');
|
menuitem = document.createElement('menuitem');
|
||||||
menuitem.setAttribute('label', label);
|
menuitem.setAttribute('label', label);
|
||||||
@ -133,7 +133,7 @@ function populateMenu(e) {
|
|||||||
menupopup = document.createElement('menupopup');
|
menupopup = document.createElement('menupopup');
|
||||||
menupopup.setAttribute('id', filteredContainers.short_name[i] + 'Popup');
|
menupopup.setAttribute('id', filteredContainers.short_name[i] + 'Popup');
|
||||||
|
|
||||||
['All', 'Popular', 'Upcoming'].forEach(
|
['All', 'Popular', 'Upcoming', 'Hot', 'Top'].forEach(
|
||||||
function (label) {
|
function (label) {
|
||||||
menuitem = document.createElement('menuitem');
|
menuitem = document.createElement('menuitem');
|
||||||
menuitem.setAttribute('label', label);
|
menuitem.setAttribute('label', label);
|
||||||
@ -162,7 +162,7 @@ function populateStoryList(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var newStories = new Array();
|
var newStories = new Array();
|
||||||
Application.console.log(stories.length);
|
//Application.console.log(stories.length);
|
||||||
|
|
||||||
for (i=0; i<stories.length; i++) {
|
for (i=0; i<stories.length; i++) {
|
||||||
story = stories[i];
|
story = stories[i];
|
||||||
@ -194,34 +194,41 @@ function populateStoryList(e) {
|
|||||||
|
|
||||||
//Adaptive update interval code START
|
//Adaptive update interval code START
|
||||||
sum = 0;
|
sum = 0;
|
||||||
weights = [0.4, 0.3, 0.2, 0.1]
|
weights = [4, 3, 2, 1]
|
||||||
for (i=0; i<4; i++) {
|
date = (stories[0].promote_date != null) ? 'promote_date' : 'submit_date';
|
||||||
if (stories[0].promote_date != null)
|
stories.sort(function (a, b) {
|
||||||
diff = stories[i].promote_date - stories[i+1].promote_date;
|
if (a[date] > b[date]) return -1;
|
||||||
else
|
else if (a[date] < b[date]) return 1;
|
||||||
diff = stories[i].submit_date - stories[i+1].submit_date;
|
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;
|
sum += weights[i]*diff;
|
||||||
}
|
}
|
||||||
updateInterval = Math.round(sum*1000);
|
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 = Components.classes["@mozilla.org/preferences-service;1"].
|
var prefs = Application.extensions.get("diggsidebar@abhinavsarkar.net").prefs;
|
||||||
getService(Components.interfaces.nsIPrefBranch);
|
|
||||||
|
|
||||||
previousUpdateInterval = prefs.getIntPref("extensions.diggsidebar.updateinterval")
|
if (updateInterval > 0) {
|
||||||
prefs.setIntPref("extensions.diggsidebar.updateinterval", updateInterval);
|
previousUpdateInterval = prefs.get("updateinterval").value;
|
||||||
|
prefs.get("updateinterval").value = updateInterval;
|
||||||
|
|
||||||
updateIntervalDecay = prefs.getIntPref("extensions.diggsidebar.updateintervaldecay");
|
updateIntervalDecay = prefs.get("updateintervaldecay").value;
|
||||||
|
|
||||||
if (previousUpdateInterval == updateInterval)
|
|
||||||
prefs.setIntPref("extensions.diggsidebar.updateintervaldecay", (updateIntervalDecay + 1));
|
|
||||||
else
|
|
||||||
prefs.setIntPref("extensions.diggsidebar.updateintervaldecay", 0);
|
|
||||||
|
|
||||||
|
if (previousUpdateInterval == updateInterval)
|
||||||
|
prefs.get("updateintervaldecay").value = updateIntervalDecay + 1;
|
||||||
|
else
|
||||||
|
prefs.get("updateintervaldecay").value = 0;
|
||||||
|
}
|
||||||
window.clearTimeout(gsti);
|
window.clearTimeout(gsti);
|
||||||
|
|
||||||
updateInterval = prefs.getIntPref("extensions.diggsidebar.updateinterval")
|
updateInterval = prefs.get("updateinterval").value;
|
||||||
updateIntervalDecay = prefs.getIntPref("extensions.diggsidebar.updateintervaldecay");
|
updateIntervalDecay = prefs.get("updateintervaldecay").value;
|
||||||
|
|
||||||
timeout = Math.round(updateInterval*(Math.pow(1.5, updateIntervalDecay)));
|
timeout = Math.round(updateInterval*(Math.pow(1.5, updateIntervalDecay)));
|
||||||
gsti = window.setTimeout(getStories, timeout);
|
gsti = window.setTimeout(getStories, timeout);
|
||||||
@ -317,9 +324,8 @@ function populateDescription(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getStories() {
|
function getStories() {
|
||||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
|
var prefs = Application.extensions.get("diggsidebar@abhinavsarkar.net").prefs;
|
||||||
getService(Components.interfaces.nsIPrefBranch);
|
ep = prefs.get("endpoint").value || '';
|
||||||
ep = prefs.getCharPref("extensions.diggsidebar.endpoint") || '';
|
|
||||||
$ei('diggEndPoint').value = "digg" + ep;
|
$ei('diggEndPoint').value = "digg" + ep;
|
||||||
|
|
||||||
fetchData("http://services.digg.com/stories" + ep.replace(/\/all/g, '') +
|
fetchData("http://services.digg.com/stories" + ep.replace(/\/all/g, '') +
|
||||||
@ -353,9 +359,8 @@ function openInTab(href) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setEndPoint(ep) {
|
function setEndPoint(ep) {
|
||||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
|
var prefs = Application.extensions.get("diggsidebar@abhinavsarkar.net").prefs;
|
||||||
getService(Components.interfaces.nsIPrefBranch);
|
prefs.get("endpoint").value = ep;
|
||||||
prefs.setCharPref("extensions.diggsidebar.endpoint", ep);
|
|
||||||
window.clearTimeout(gsti);
|
window.clearTimeout(gsti);
|
||||||
//window.clearInterval(psi);
|
//window.clearInterval(psi);
|
||||||
getStories();
|
getStories();
|
||||||
@ -369,10 +374,9 @@ function togglePlayPause() {
|
|||||||
$ei('diggPlayPause').setAttribute("tooltiptext", "Click to Start autoupdate");
|
$ei('diggPlayPause').setAttribute("tooltiptext", "Click to Start autoupdate");
|
||||||
playing = false;
|
playing = false;
|
||||||
} else {
|
} else {
|
||||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
|
var prefs = Application.extensions.get("diggsidebar@abhinavsarkar.net").prefs;
|
||||||
getService(Components.interfaces.nsIPrefBranch);
|
updateInterval = prefs.get("extensions.diggsidebar.updateinterval").value;
|
||||||
updateInterval = prefs.getIntPref("extensions.diggsidebar.updateinterval")
|
updateIntervalDecay = prefs.get("extensions.diggsidebar.updateintervaldecay").value;
|
||||||
updateIntervalDecay = prefs.getIntPref("extensions.diggsidebar.updateintervaldecay");
|
|
||||||
|
|
||||||
timeout = Math.round(updateInterval*(Math.pow(1.5, updateIntervalDecay)));
|
timeout = Math.round(updateInterval*(Math.pow(1.5, updateIntervalDecay)));
|
||||||
//newTimeout = Math.round(timeout*parseInt($ei("diggIndicator").getAttribute('value'))/100);
|
//newTimeout = Math.round(timeout*parseInt($ei("diggIndicator").getAttribute('value'))/100);
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
<menuitem label="All" value="/all" oncommand="setEndPoint(this.value)" accesskey="A" />
|
<menuitem label="All" value="/all" oncommand="setEndPoint(this.value)" accesskey="A" />
|
||||||
<menuitem label="Popular" value="/popular" oncommand="setEndPoint(this.value)" accesskey="P" />
|
<menuitem label="Popular" value="/popular" oncommand="setEndPoint(this.value)" accesskey="P" />
|
||||||
<menuitem label="Upcoming" value="/upcoming" oncommand="setEndPoint(this.value)" accesskey="U" />
|
<menuitem label="Upcoming" value="/upcoming" oncommand="setEndPoint(this.value)" accesskey="U" />
|
||||||
|
<menuitem label="Hot" value="/hot" oncommand="setEndPoint(this.value)" accesskey="H" />
|
||||||
|
<menuitem label="Top" value="/top" oncommand="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">
|
||||||
@ -38,8 +40,8 @@
|
|||||||
<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="getDescription(this.selectedItem.id.substr(6))"></richlistbox>
|
||||||
@ -52,32 +54,34 @@
|
|||||||
</html:span>
|
</html:span>
|
||||||
</html:div>
|
</html:div>
|
||||||
<html:div id="storyDetailsFormat" style="display:none">
|
<html:div id="storyDetailsFormat" style="display:none">
|
||||||
<html:div class="storyDetails">
|
<html:div class="storyDetails">
|
||||||
<html:div>
|
<html:div>
|
||||||
<html:span class="storyDate"></html:span>
|
<html:span class="storyContainer"></html:span> >
|
||||||
<html:span class="storyStatus"></html:span>
|
<html:span class="storyTopic"></html:span> /
|
||||||
</html:div>
|
<html:span class="storyStatus"></html:span>
|
||||||
<html:div>
|
</html:div>
|
||||||
<html:span class="storyContainer"></html:span> > <html:span class="storyTopic"></html:span>
|
<html:div>
|
||||||
</html:div>
|
<html:span class="storyDesc"></html:span>
|
||||||
<html:div>
|
<html:a class="storyLink" onclick="openInTab(this.href); return false">
|
||||||
<html:span class="storyPopularity">
|
<html:img src="chrome://diggsidebar/content/image/external.png" />
|
||||||
<html:img src="chrome://diggsidebar/content/image/digg.png" width="15px" />
|
</html:a>
|
||||||
<html:span class="storyDiggs"></html:span>
|
</html:div>
|
||||||
<html:img src="chrome://diggsidebar/content/image/comments.png" width="15px" />
|
<html:div style="text-align:center;">
|
||||||
<html:span class="storyComments"></html:span>
|
<html:a class="storyHref" onclick="openInTab(this.href); return false">Digg This</html:a>
|
||||||
</html:span>
|
</html:div>
|
||||||
|
<html:div>
|
||||||
|
<html:span class="storyPopularity">
|
||||||
|
<html:img src="chrome://diggsidebar/content/image/digg.png" width="15px" />
|
||||||
|
<html:span class="storyDiggs"></html:span>
|
||||||
|
<html:img src="chrome://diggsidebar/content/image/comments.png" width="15px" />
|
||||||
|
<html:span class="storyComments"></html:span>
|
||||||
|
</html:span>
|
||||||
|
by
|
||||||
<html:span class="storyUserLink">
|
<html:span class="storyUserLink">
|
||||||
submitted by: <html:a class="storyUserName" onclick="openInTab(this.href); return false"></html:a>
|
<html:a class="storyUserName" onclick="openInTab(this.href); return false"></html:a>
|
||||||
</html:span>
|
</html:span>
|
||||||
</html:div>
|
<html:span class="storyDate"></html:span>
|
||||||
<html:div class="storyDesc"></html:div>
|
</html:div>
|
||||||
<html:div>
|
</html:div>
|
||||||
<html:img src="chrome://diggsidebar/content/image/external.png" style="float: left" />
|
|
||||||
<html:a class="storyLink" onclick="openInTab(this.href); return false">Link to Article</html:a>
|
|
||||||
<html:a class="storyHref" onclick="openInTab(this.href); return false">Digg This</html:a>
|
|
||||||
<html:img src="chrome://diggsidebar/content/image/digg_this.png" width="15px" style="float: right" />
|
|
||||||
</html:div>
|
|
||||||
</html:div>
|
|
||||||
</html:div>
|
</html:div>
|
||||||
</page>
|
</page>
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@ -1,3 +1,11 @@
|
|||||||
|
a {
|
||||||
|
color: blue;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 1px;
|
||||||
|
}
|
||||||
|
a img {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
.storyList {
|
.storyList {
|
||||||
margin: 1px;
|
margin: 1px;
|
||||||
border-style: solid !important;
|
border-style: solid !important;
|
||||||
@ -17,7 +25,6 @@
|
|||||||
}
|
}
|
||||||
.storyDetails > div {
|
.storyDetails > div {
|
||||||
clear: both;
|
clear: both;
|
||||||
height: 15px;
|
|
||||||
padding: 1px 0px;
|
padding: 1px 0px;
|
||||||
font-size: x-small;
|
font-size: x-small;
|
||||||
}
|
}
|
||||||
@ -26,31 +33,24 @@
|
|||||||
font-size: x-small;
|
font-size: x-small;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
.storyDate, .storyDate, .storyLink {
|
.storyNew, .storyRead, .storyPopularity {
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.storyStatus, .storyNew, .storyRead, .storyPopularity, .storyHref {
|
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.storyNew, .storyRead {
|
.storyNew, .storyRead {
|
||||||
padding: 0px 2px;
|
padding: 0px 2px;
|
||||||
}
|
}
|
||||||
|
.storyHref {
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 2px 3px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
.storyDesc {
|
.storyDesc {
|
||||||
height: auto!important;
|
height: auto!important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.storyHeader {
|
.storyHeader {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
a {
|
.storyHref:hover, .storyUserName:hover {
|
||||||
color: blue;
|
|
||||||
cursor: pointer;
|
|
||||||
padding: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover {
|
|
||||||
color: white;
|
color: white;
|
||||||
background-color: blue;
|
background-color: blue;
|
||||||
}
|
}
|
||||||
@ -60,7 +60,6 @@ richlistitem {
|
|||||||
padding-bottom: 3px;
|
padding-bottom: 3px;
|
||||||
color: #000000!important;
|
color: #000000!important;
|
||||||
}
|
}
|
||||||
|
|
||||||
richlistitem > div{
|
richlistitem > div{
|
||||||
width: 250px;
|
width: 250px;
|
||||||
}
|
}
|
||||||
@ -72,8 +71,8 @@ richlistitem[selected="true"] .storyDetails {
|
|||||||
border-top: 1px dashed black;
|
border-top: 1px dashed black;
|
||||||
background-color: #FFFBF0;
|
background-color: #FFFBF0;
|
||||||
}
|
}
|
||||||
|
|
||||||
richlistitem .storyTitle:hover {
|
richlistitem .storyTitle:hover {
|
||||||
background-color: green;
|
background-color: green;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
pref("extensions.diggsidebar.endpoint", "");
|
pref("extensions.diggsidebar@abhinavsarkar.net.endpoint", "");
|
||||||
pref("extensions.diggsidebar.updateinterval", 30000);
|
pref("extensions.diggsidebar@abhinavsarkar.net.updateinterval", 30000);
|
||||||
pref("extensions.diggsidebar.updateintervaldecay", 0);
|
pref("extensions.diggsidebar@abhinavsarkar.net.updateintervaldecay", 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user