diff --git a/chrome/content/diggsidebar.js b/chrome/content/diggsidebar.js index b82a277..744be75 100644 --- a/chrome/content/diggsidebar.js +++ b/chrome/content/diggsidebar.js @@ -25,17 +25,19 @@ var DiggSidebar = { topic: null, category: "all" }, - updateInterval: 10, + updateInterval: 1000, updateIntervalDecay: 0, + lastUpdateAt: new Date().getTime(), shownStoriesCount: 30, categories: ['All', 'Popular', 'Upcoming', 'Hot', 'Top'], timerId: null, storyIds: [], - playing: true, + refreshing: false, stories: [], + expandedStory: null, fetchData: function(url, handler) { - DiggSidebar.UI.indicator.style.display = ''; + DiggSidebar.indicateActivity(); var request = new XMLHttpRequest(); request.onerror = DiggSidebar.errorHandler; @@ -45,7 +47,17 @@ var DiggSidebar = { }, errorHandler: function(e) { - window.alert("Error in accessing data from Digg"); + /*if (DiggSidebar.UI.notificationBox.allNotifications.length > 0) + DiggSidebar.UI.notificationBox.removeAllNotifications(true);*/ + DiggSidebar.UI.notificationBox.appendNotification( + "Unable to access Digg", + "dsAccessFailNotification", + null, + "PRIORITY_CRITICAL_HIGH", + [{callback:DiggSidebar.getStories, label: "Retry", accessKey: "R"}] + ); + DiggSidebar.refreshing = false; + DiggSidebar.indicateInactivity(); }, populateMenu: function(e) { @@ -117,11 +129,10 @@ var DiggSidebar = { menu.appendChild(menupopup); DiggSidebar.UI.containerPopup.appendChild(menu); } - DiggSidebar.UI.indicator.style.display = 'none'; + //DiggSidebar.indicateInactivity(); }, populateStoryList: function() { - DiggSidebar.Utils.removeAllChildren(DiggSidebar.UI.storyListBox); var newStoryIds = new Array(); var jp = new JPath(DiggSidebar.stories); @@ -138,6 +149,9 @@ var DiggSidebar = { return story.$("container/short_name").json == DiggSidebar.endpoint.container; }).json; + if (filteredStories.length > 0) + DiggSidebar.Utils.removeAllChildren(DiggSidebar.UI.storyListBox); + filteredStories.forEach(function (story, index) { if (index < DiggSidebar.shownStoriesCount) { var now = new Date(); @@ -173,27 +187,23 @@ var DiggSidebar = { link: story.link, href: story.href } - for (attr in attributes) + for (var attr in attributes) li.setAttribute(attr, attributes[attr]); li.read = story.read; + if (story.id == DiggSidebar.expandedStory) + li.showDescription(); } if (DiggSidebar.storyIds.indexOf(story.id) == -1) newStoryIds.push(story.id); }); DiggSidebar.storyIds = DiggSidebar.storyIds.concat(newStoryIds); - DiggSidebar.setUpdateInterval(DiggSidebar.stories.slice(0,5)); - - window.clearTimeout(DiggSidebar.timerId); - var timeout = Math.round(DiggSidebar.updateInterval*(Math.pow(1.5, DiggSidebar.updateIntervalDecay))); - DiggSidebar.timerId = window.setTimeout(DiggSidebar.getStories, timeout); - - DiggSidebar.UI.indicator.style.display = 'none'; }, showDescription: function(storyId) { var jp = new JPath(DiggSidebar.stories); var story = jp.query('//[id == ' + storyId + ']')[0]; story.read = true; + DiggSidebar.expandedStory = parseInt(storyId); var listitems = DiggSidebar.UI.storyListBox.children; for (var i=0; i 3600) ? + Math.round(autoRefreshTime/3600) + " hours": + (autoRefreshTime > 60) ? + Math.round(autoRefreshTime/60) + " minutes": + autoRefreshTime + " seconds"; + setAttribute('tooltiptext', "Click to refresh now.\n" + + "Autorefreshing in " + autoRefreshTime); + } + } + DiggSidebar.lastUpdateAt = new Date().getTime(); + }, + initialize: function(){ DiggSidebar.endpoint = DiggSidebar.getEndpointParts(DiggSidebar.prefs.get("endpoint").value); var $ = function(id) {return document.getElementById(id)}; DiggSidebar.UI = {}; + DiggSidebar.UI.notificationBox = $('dsNotificationBox'); DiggSidebar.UI.indicator = $('dsBusyIndicator'); DiggSidebar.UI.topicPopup = $('dsTopicPopup'); DiggSidebar.UI.containerPopup = $('dsContainerPopup'); DiggSidebar.UI.storyListBox = $('dsStoryListBox'); DiggSidebar.UI.endPointDesc = $('dsEndPointDesc'); - DiggSidebar.UI.playPauseButton = $('dsPlayPauseButton'); DiggSidebar.storyListObserver = new DiggSidebar.StoryListObserver(); DiggSidebar.createMenu(); diff --git a/chrome/content/diggsidebar.xul b/chrome/content/diggsidebar.xul index e905fb4..51adea6 100644 --- a/chrome/content/diggsidebar.xul +++ b/chrome/content/diggsidebar.xul @@ -41,22 +41,19 @@ - - + + + - digg - + digg + + diff --git a/chrome/content/diggstory.xml b/chrome/content/diggstory.xml index 0ce1cb2..947db4c 100644 --- a/chrome/content/diggstory.xml +++ b/chrome/content/diggstory.xml @@ -11,7 +11,7 @@ - + - + @@ -53,15 +53,11 @@ - @@ -84,7 +80,7 @@ diff --git a/chrome/content/image/Pause.png b/chrome/content/image/Pause.png deleted file mode 100644 index 271e378..0000000 Binary files a/chrome/content/image/Pause.png and /dev/null differ diff --git a/chrome/content/image/Play.png b/chrome/content/image/Play.png deleted file mode 100644 index 6094a9c..0000000 Binary files a/chrome/content/image/Play.png and /dev/null differ diff --git a/chrome/content/image/digg.gif b/chrome/content/image/digg.gif new file mode 100644 index 0000000..f2bcb30 Binary files /dev/null and b/chrome/content/image/digg.gif differ diff --git a/chrome/content/image/digg.png b/chrome/content/image/digg.png deleted file mode 100644 index 5db8fc0..0000000 Binary files a/chrome/content/image/digg.png and /dev/null differ diff --git a/chrome/skin/diggsidebar.css b/chrome/skin/diggsidebar.css index 773f826..aec8c8f 100644 --- a/chrome/skin/diggsidebar.css +++ b/chrome/skin/diggsidebar.css @@ -47,7 +47,9 @@ a img { color: white; background-color: blue; } - +.storyDiggs, .storyComments { + font-size: xx-small; +} #dsStoryListBox richlistitem{ border: 2px solid #E5ECF3; border-top: none;