diff --git a/chrome/content/TODO.txt b/chrome/content/TODO.txt index 3d91716..ef42423 100644 --- a/chrome/content/TODO.txt +++ b/chrome/content/TODO.txt @@ -1,7 +1,7 @@ move to JSON data format -- done XBL -- done format JS/refactor JS/Use FUEL -- done -caching/db, notifier-observer -- done -search +caching, notifier-observer -- done +search? new UI, icons, thumbnails put license diff --git a/chrome/content/diggsidebar.js b/chrome/content/diggsidebar.js index bf18736..1b48df8 100644 --- a/chrome/content/diggsidebar.js +++ b/chrome/content/diggsidebar.js @@ -35,7 +35,7 @@ var DiggSidebar = { stories: [], fetchData: function(url, handler) { - DiggSidebar.diggIndicator.style.display = ''; + DiggSidebar.UI.indicator.style.display = ''; var request = new XMLHttpRequest(); request.onerror = DiggSidebar.errorHandler; @@ -54,9 +54,7 @@ var DiggSidebar = { var topics = data.topics; var containers = new Array(); - while (DiggSidebar.topicPopup.firstChild) { - DiggSidebar.topicPopup.removeChild(DiggSidebar.topicPopup.firstChild); - } + DiggSidebar.Utils.removeAllChildren(DiggSidebar.UI.topicPopup); topics.forEach(function (topic) { var menu = document.createElement('menu'); @@ -78,14 +76,12 @@ var DiggSidebar = { } ); menu.appendChild(menupopup); - DiggSidebar.topicPopup.appendChild(menu); + DiggSidebar.UI.topicPopup.appendChild(menu); containers.push(topic.container); }); - while (DiggSidebar.containerPopup.firstChild) { - DiggSidebar.containerPopup.removeChild(DiggSidebar.containerPopup.firstChild); - } + DiggSidebar.Utils.removeAllChildren(DiggSidebar.UI.containerPopup); var filteredContainers = {name: [], short_name: []}; containers.forEach(function (container) { @@ -119,18 +115,14 @@ var DiggSidebar = { ); menu.appendChild(menupopup); - DiggSidebar.containerPopup.appendChild(menu); + DiggSidebar.UI.containerPopup.appendChild(menu); } - DiggSidebar.diggIndicator.style.display = 'none'; + DiggSidebar.UI.indicator.style.display = 'none'; }, populateStoryList: function() { - while (DiggSidebar.storyList.firstChild) { - DiggSidebar.storyList.removeChild(DiggSidebar.storyList.firstChild); - } - + DiggSidebar.Utils.removeAllChildren(DiggSidebar.UI.storyListBox); var newStoryIds = new Array(); - Application.console.log("DiggSidebar.stories.length = " + DiggSidebar.stories.length); var jp = new JPath(DiggSidebar.stories); var filteredStories = jp.$(function(story){ @@ -165,20 +157,24 @@ var DiggSidebar = { ((hr == 0) && (min == 0)) ? "just now" : ""; - var li = DiggSidebar.storyList.appendChild(document.createElement('richlistitem')); + var li = DiggSidebar.UI.storyListBox.appendChild(document.createElement('richlistitem')); li.id = "story_" + story.id; - li.setAttribute('title', story.title); - 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); + var attributes = { + title: story.title, + date: relativeTime, + status: story.status, + container: story.container.name, + topic: story.topic.name, + username: story.user.name, + userlink: "http://digg.com/users/" + story.user.name, + diggs: story.diggs, + comments: story.comments, + desc: story.description, + link: story.link, + href: story.href + } + for (attr in attributes) + li.setAttribute(attr, attributes[attr]); if (DiggSidebar.storyIds.indexOf(story.id) != -1) li.new = false; li.read = story.read; @@ -192,7 +188,7 @@ var DiggSidebar = { var timeout = Math.round(DiggSidebar.updateInterval*(Math.pow(1.5, DiggSidebar.updateIntervalDecay))); DiggSidebar.timerId = window.setTimeout(DiggSidebar.getStories, timeout); - DiggSidebar.diggIndicator.style.display = 'none'; + DiggSidebar.UI.indicator.style.display = 'none'; }, showDescription: function(storyId) { @@ -200,18 +196,16 @@ var DiggSidebar = { var story = jp.query('//[id == ' + storyId + ']')[0]; story.read = true; - var listitems = document.getElementsByTagName('richlistitem'); + var listitems = DiggSidebar.UI.storyListBox.children; for (var i=0; i - - - + + + - - + + - - + + @@ -41,7 +41,7 @@ - @@ -50,13 +50,13 @@ - digg + digg diff --git a/chrome/content/diggstory.xml b/chrome/content/diggstory.xml index 979bf23..6d26762 100644 --- a/chrome/content/diggstory.xml +++ b/chrome/content/diggstory.xml @@ -11,8 +11,8 @@ - R - N + New + Unread @@ -57,6 +57,7 @@ this.d = {}; this.d.read = false; this.d.new = true; + this.d.collapsed = true; ]]> + @@ -94,6 +100,7 @@ "chrome://diggsidebar/content/image/down.jpg"; document.getAnonymousElementByAttribute(this, "class", "storyDetails").style.display = 'block'; this.read = true; + this.collapsed = false; ]]> @@ -103,6 +110,7 @@ document.getAnonymousElementByAttribute(this, "class", "storyCEIcon").src = "chrome://diggsidebar/content/image/up.jpg"; document.getAnonymousElementByAttribute(this, "class", "storyDetails").style.display = 'none'; + this.collapsed = true; ]]> diff --git a/chrome/locale/en-US/diggsidebar.dtd b/chrome/locale/en-US/diggsidebar.dtd index ebd41f3..ef68d25 100644 --- a/chrome/locale/en-US/diggsidebar.dtd +++ b/chrome/locale/en-US/diggsidebar.dtd @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/chrome/skin/diggsidebar.css b/chrome/skin/diggsidebar.css index 70479d6..ad27ac1 100644 --- a/chrome/skin/diggsidebar.css +++ b/chrome/skin/diggsidebar.css @@ -6,7 +6,7 @@ a { a img { border: none; } -#storyList { +#dsStoryListBox { margin: 1px; border-style: solid !important; border-color: #000; @@ -37,6 +37,8 @@ a img { } .storyNew, .storyRead { padding: 0px 2px; + font-size: xx-small; + font-family: monospace; } .storyHref { font-weight: bold; @@ -56,7 +58,7 @@ a img { background-color: blue; } -#storyList richlistitem{ +#dsStoryListBox richlistitem{ border-bottom: 1px solid black; color: #000000!important; -moz-binding: url("chrome://diggsidebar/content/diggstory.xml#diggstoryitem");