Browse Source

checked in version 0.5.1

git-svn-id: file:///tmp/snv/trunk@2 12951d8a-c33d-4b7c-b961-822215c816
Abhinav Sarkar 13 years ago
parent
commit
f3fb4ab6f5

+ 4
- 0
chrome.manifest View File

@@ -0,0 +1,4 @@
1
+content diggsidebar jar:chrome/diggsidebar.jar!/chrome/content/
2
+locale diggsidebar en-US jar:chrome/diggsidebar.jar!/chrome/locale/en-US/
3
+skin diggsidebar classic/1.0 jar:chrome/diggsidebar.jar!/chrome/skin/
4
+overlay	chrome://browser/content/browser.xul	chrome://diggsidebar/content/firefoxOverlay.xul

+ 446
- 0
chrome/content/diggsidebar.js View File

@@ -0,0 +1,446 @@
1
+var gsti;
2
+var currentStories = new Array();
3
+var playing = true;
4
+
5
+//getElementById
6
+function $ei(id, parentNode) {
7
+	parentNode = parentNode || document;
8
+	return parentNode.getElementById(id);
9
+}
10
+
11
+//getAttribute
12
+function $a(parentNode, att) {
13
+	return parentNode.getAttribute(att);
14
+}
15
+
16
+//getElementByTagName
17
+function $et(tagName, parentNode) {
18
+	parentNode = parentNode || document;
19
+	return parentNode.getElementsByTagName(tagName)[0];
20
+}
21
+
22
+//getElementByClassName
23
+function $ec(className, parentNode) {
24
+        parentNode = parentNode || document;
25
+        elements = parentNode.getElementsByTagName("*");
26
+        for (i=0; i<elements.length; i++) {
27
+                if (elements[i].hasAttribute('class') && elements[i].getAttribute('class') == className) {
28
+                        return elements[i];
29
+                }
30
+        }
31
+        
32
+}
33
+//Xpath
34
+function $xp(aNode, aExpr) {
35
+	var xpe = new XPathEvaluator();
36
+	var nsResolver = xpe.createNSResolver(aNode.ownerDocument == null ?
37
+	aNode.documentElement : aNode.ownerDocument.documentElement);
38
+	var result = xpe.evaluate(aExpr, aNode, nsResolver, 0, null);
39
+	var found = [];
40
+	var res;
41
+	while (res = result.iterateNext())
42
+		found.push(res);
43
+	return found;
44
+}
45
+String.prototype.escapeEntities = function() {
46
+	return this.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
47
+}
48
+
49
+function fetchData(url, handler) {
50
+	//alert("inside fetchData");
51
+        $ei('diggIndicator').style.display = '';
52
+        $ei("diggIndicator").setAttribute('mode', 'undetermined');
53
+	var request = Components.
54
+              classes["@mozilla.org/xmlextras/xmlhttprequest;1"].
55
+              createInstance();
56
+
57
+	// QI the object to nsIDOMEventTarget to set event handlers on it:
58
+
59
+	request.QueryInterface(Components.interfaces.nsIDOMEventTarget);
60
+	request.addEventListener("load", handler, false);
61
+        request.addEventListener("error", handleError, false);
62
+
63
+	// QI it to nsIXMLHttpRequest to open and send the request:
64
+
65
+	request.QueryInterface(Components.interfaces.nsIXMLHttpRequest);
66
+	request.open("GET", url, true);
67
+	request.send(null);
68
+        //$ei('diggIndicator').style.display = '';
69
+        
70
+}
71
+
72
+function handleError(e) {
73
+        $ei('storyList').appendItem("!! Error accessing Digg !!");
74
+        //$ei('diggIndicator').style.display = 'none';
75
+}
76
+
77
+function populateMenu(e) {
78
+        XHR = e.target;
79
+	//myDump(XHR.responseText);
80
+	data = XHR.responseXML;
81
+        topics = $xp(data, "/topics/topic");
82
+        while ($ei('topicPopup').firstChild) {
83
+                $ei('topicPopup').removeChild($ei('topicPopup').firstChild);
84
+        }
85
+        
86
+        for (i=0; i<topics.length; i++) {
87
+                menu = document.createElement('menu');
88
+                menu.setAttribute('id', $a(topics[i], 'short_name') + 'Menu');
89
+                menu.setAttribute('label', $a(topics[i], 'name'));
90
+                menu.setAttribute('accesskey', $a(topics[i], 'name').substring(0, 1));
91
+                
92
+                menupopup = document.createElement('menupopup');
93
+                menupopup.setAttribute('id', $a(topics[i], 'short_name') + 'Popup');
94
+                
95
+                menuitem = document.createElement('menuitem');
96
+                menuitem.setAttribute('label', 'All');
97
+                menuitem.setAttribute('value', '/topic/' + $a(topics[i], 'short_name') + '/all');
98
+                menuitem.setAttribute('accesskey', 'A');
99
+                menuitem.setAttribute('oncommand', "setEndPoint(this.value)");
100
+                menupopup.appendChild(menuitem);
101
+                
102
+                menuitem = document.createElement('menuitem');
103
+                menuitem.setAttribute('label', 'Popular');
104
+                menuitem.setAttribute('value', '/topic/' + $a(topics[i], 'short_name') + '/popular');
105
+                menuitem.setAttribute('accesskey', 'P');
106
+                menuitem.setAttribute('oncommand', "setEndPoint(this.value)");
107
+                menupopup.appendChild(menuitem);
108
+                
109
+                menuitem = document.createElement('menuitem');
110
+                menuitem.setAttribute('label', 'Upcoming');
111
+                menuitem.setAttribute('value', '/topic/' + $a(topics[i], 'short_name') + '/upcoming');
112
+                menuitem.setAttribute('accesskey', 'U');
113
+                menuitem.setAttribute('oncommand', "setEndPoint(this.value)");
114
+                menupopup.appendChild(menuitem);
115
+                
116
+                menu.appendChild(menupopup);
117
+                
118
+                //alert($a(topics[i], 'name'));
119
+                $ei('topicPopup').appendChild(menu);
120
+        }
121
+        
122
+        containers = $xp(data, "/topics/topic/container");
123
+        while ($ei('containerPopup').firstChild) {
124
+                $ei('containerPopup').removeChild($ei('containerPopup').firstChild);
125
+        }
126
+        
127
+        filteredContainers = {name: [], short_name: []};
128
+        for (i=0; i<containers.length; i++) {
129
+                name = $a(containers[i], 'name');
130
+                short_name = $a(containers[i], 'short_name');
131
+                if (filteredContainers.name.indexOf(name) == -1) {
132
+                        filteredContainers.name.push(name);
133
+                        filteredContainers.short_name.push(short_name);
134
+                }
135
+        }
136
+        //myDump(uneval(filteredContainers));
137
+        
138
+        for (i=0; i<filteredContainers.name.length; i++) {
139
+                menu = document.createElement('menu');
140
+                menu.setAttribute('id', filteredContainers.short_name[i] + 'Menu');
141
+                menu.setAttribute('label', filteredContainers.name[i]);
142
+                menu.setAttribute('accesskey', filteredContainers.name[i].substring(0, 1));
143
+                
144
+                menupopup = document.createElement('menupopup');
145
+                menupopup.setAttribute('id', filteredContainers.short_name[i] + 'Popup');
146
+                
147
+                menuitem = document.createElement('menuitem');
148
+                menuitem.setAttribute('label', 'All');
149
+                menuitem.setAttribute('value', '/container/' + filteredContainers.short_name[i] + '/all');
150
+                menuitem.setAttribute('accesskey', 'A');
151
+                menuitem.setAttribute('oncommand', "setEndPoint(this.value)");
152
+                menupopup.appendChild(menuitem);
153
+                
154
+                menuitem = document.createElement('menuitem');
155
+                menuitem.setAttribute('label', 'Popular');
156
+                menuitem.setAttribute('value', '/container/' + filteredContainers.short_name[i] + '/popular');
157
+                menuitem.setAttribute('accesskey', 'P');
158
+                menuitem.setAttribute('oncommand', "setEndPoint(this.value)");
159
+                menupopup.appendChild(menuitem);
160
+                
161
+                menuitem = document.createElement('menuitem');
162
+                menuitem.setAttribute('label', 'Upcoming');
163
+                menuitem.setAttribute('value', '/container/' + filteredContainers.short_name[i] + '/upcoming');
164
+                menuitem.setAttribute('accesskey', 'U');
165
+                menuitem.setAttribute('oncommand', "setEndPoint(this.value)");
166
+                menupopup.appendChild(menuitem);
167
+                
168
+                menu.appendChild(menupopup);
169
+                
170
+                //alert($a(topics[i], 'name'));
171
+                $ei('containerPopup').appendChild(menu);
172
+        }
173
+        $ei('diggIndicator').style.display = 'none';
174
+}
175
+
176
+function populateStoryList(e) {
177
+	//alert("inside populateStoryList");
178
+	XHR = e.target;
179
+	//alert(XHR.responseText);
180
+	data = XHR.responseXML;
181
+	stories = $xp(data, "/stories/story");
182
+	//alert(stories.length);
183
+	//dumpProperties(titles[0]);
184
+        
185
+        //selectedItem = $ei('storyList').selectedItem;
186
+        
187
+        while ($ei('storyList').firstChild) {
188
+                $ei('storyList').removeChild($ei('storyList').firstChild);
189
+        }
190
+                
191
+        
192
+        var newStories = new Array();
193
+	for (i=0; i<stories.length; i++) {
194
+		//alert(stories[i]);
195
+		title = $et('title', stories[i]).textContent;
196
+		id = $a(stories[i], 'id');
197
+                newStories.push(id);
198
+		//alert(title + " " + id);
199
+		listitem = $ei('storyList').appendChild(document.createElement('richlistitem'));
200
+                listitem.id = "story_" + id;
201
+                htmllistitem = listitem.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml","html:div"));
202
+                htmllistitem.innerHTML = $ei('storyTitleFormat').innerHTML;
203
+                storyTitle = listitem.getElementsByAttribute('class', 'storyTitle')[0];
204
+                storyTitle.appendChild(document.createTextNode(title));
205
+                
206
+                htmllistitem.innerHTML += $ei('storyDetailsFormat').innerHTML;
207
+                
208
+                storyNew= listitem.getElementsByAttribute('class', 'storyNew')[0];
209
+                
210
+                if (currentStories.indexOf(id) != -1) {
211
+                        storyNew.style.textDecoration = "line-through";
212
+                        storyNew.style.backgroundColor = "black";
213
+                        storyNew.style.color = "white";
214
+                        storyNew.title = "Old";
215
+                }
216
+        }
217
+        currentStories = newStories;
218
+        //$ei('diggIndicator').style.display = 'none';
219
+        
220
+        //Adaptive update interval code START
221
+        sum = 0;
222
+        weights = [0.4, 0.3, 0.2, 0.1]
223
+        for (i=0; i<4; i++) {
224
+                if ($a(stories[0], 'promote_date') != null)
225
+                        diff = parseInt($a(stories[i], 'promote_date')) - parseInt($a(stories[i+1], 'promote_date'));
226
+                else
227
+                        diff = parseInt($a(stories[i], 'submit_date')) - parseInt($a(stories[i+1], 'submit_date'));
228
+                
229
+                sum += weights[i]*diff;
230
+        }
231
+        updateInterval = Math.round(sum*1000);
232
+        
233
+        var prefs = Components.classes["@mozilla.org/preferences-service;1"].
234
+                getService(Components.interfaces.nsIPrefBranch);
235
+                
236
+        previousUpdateInterval = prefs.getIntPref("extensions.diggsidebar.updateinterval")
237
+        prefs.setIntPref("extensions.diggsidebar.updateinterval", updateInterval);
238
+        
239
+        updateIntervalDecay = prefs.getIntPref("extensions.diggsidebar.updateintervaldecay");
240
+
241
+        if (previousUpdateInterval == updateInterval)
242
+                prefs.setIntPref("extensions.diggsidebar.updateintervaldecay", (updateIntervalDecay + 1));
243
+        else
244
+                prefs.setIntPref("extensions.diggsidebar.updateintervaldecay", 0);
245
+        
246
+        window.clearTimeout(gsti);
247
+        
248
+        updateInterval = prefs.getIntPref("extensions.diggsidebar.updateinterval")
249
+        updateIntervalDecay = prefs.getIntPref("extensions.diggsidebar.updateintervaldecay");
250
+        
251
+        timeout = Math.round(updateInterval*(Math.pow(1.5, updateIntervalDecay)));
252
+        gsti = window.setTimeout(getStories, timeout);
253
+        //Adaptive update interval code END
254
+        
255
+        $ei('diggIndicator').style.display = 'none';
256
+        
257
+        //prefs.setIntPref("extensions.diggsidebar.progress", 100);
258
+        //$ei("diggIndicator").setAttribute('mode', 'determined');
259
+        //$ei("diggIndicator").setAttribute('value', 100);
260
+        //psi = window.setInterval(showProgress, Math.round(timeout/100));
261
+        //window.setTimeout("window.clearInterval(psi)", timeout);
262
+        
263
+}
264
+
265
+//function showProgress() {
266
+//        var prefs = Components.classes["@mozilla.org/preferences-service;1"].
267
+//                getService(Components.interfaces.nsIPrefBranch);
268
+//        progress = prefs.getIntPref("extensions.diggsidebar.progress");
269
+//        prefs.setIntPref("extensions.diggsidebar.progress", (progress - 1));
270
+//        
271
+//        $ei("diggIndicator").setAttribute('value', (parseInt($ei("diggIndicator").getAttribute('value')) - 1));
272
+//}
273
+        
274
+function populateDescription(e) {
275
+	XHR = e.target;
276
+	myDump(XHR.responseText);
277
+	data = XHR.responseXML;
278
+	story = $xp(data, "/stories/story")[0];
279
+	//alert(story);
280
+        now = new Date();
281
+        if ($a(story, 'promote_date') != null)
282
+                then = new Date(parseInt($a(story, 'promote_date').escapeEntities())*1000);
283
+        else
284
+                then = new Date(parseInt($a(story, 'submit_date').escapeEntities())*1000);
285
+        diff = now - then;
286
+        if (diff < 0) diff = 0;
287
+               
288
+        hr = Math.floor(diff/(1000*3600));
289
+        min = Math.floor(diff/(1000*60)) - 60*hr;
290
+        
291
+        listitems = document.getElementsByTagName('richlistitem');
292
+        for (i=0; i<listitems.length; i++) {
293
+                listitems[i].getElementsByAttribute('class', 'storyDetails')[0].style.display = 'none';
294
+                listitems[i].getElementsByAttribute('class', 'storyCEIcon')[0].src = "chrome://diggsidebar/content/image/up.jpg";
295
+        }
296
+        
297
+        storyListItem = $ei('story_'+ $a(story, 'id'))
298
+        storyDetails = storyListItem.getElementsByAttribute('class', 'storyDetails')[0];
299
+        storyDate = storyListItem.getElementsByAttribute('class', 'storyDate')[0];
300
+        storyStatus = storyListItem.getElementsByAttribute('class', 'storyStatus')[0];
301
+        storyContainer = storyListItem.getElementsByAttribute('class', 'storyContainer')[0];
302
+        storyTopic = storyListItem.getElementsByAttribute('class', 'storyTopic')[0];
303
+        storyUserName = storyListItem.getElementsByAttribute('class', 'storyUserName')[0];
304
+        storyDiggs = storyListItem.getElementsByAttribute('class', 'storyDiggs')[0];
305
+        storyComments = storyListItem.getElementsByAttribute('class', 'storyComments')[0];
306
+        storyDesc = storyListItem.getElementsByAttribute('class', 'storyDesc')[0];
307
+        storyLink = storyListItem.getElementsByAttribute('class', 'storyLink')[0];
308
+        storyHref = storyListItem.getElementsByAttribute('class', 'storyHref')[0];
309
+        
310
+        storyCEIcon = storyListItem.getElementsByAttribute('class', 'storyCEIcon')[0];
311
+        storyRead = storyListItem.getElementsByAttribute('class', 'storyRead')[0];
312
+                
313
+	storyDate.innerHTML = ((hr > 0) && (min > 0)) ?
314
+                                                (hr + " hr " + min + " mins ago") :
315
+                                                ((hr == 0) && (min > 0)) ?
316
+                                                (min + " mins ago") :
317
+                                                ((hr == 0) && (min == 0)) ?
318
+                                                "just now" : "";
319
+	storyStatus.innerHTML = $a(story, 'status').escapeEntities();
320
+	//alert($a($et('container', story), 'name').escapeEntities());
321
+	storyContainer.innerHTML = $a($et('container', story), 'name').escapeEntities();
322
+	storyTopic.innerHTML = $a($et('topic', story), 'name').escapeEntities();
323
+	storyUserName.href = "http://digg.com/users/" + $a($et('user', story), 'name').escapeEntities();
324
+	storyUserName.innerHTML = $a($et('user', story), 'name').escapeEntities();
325
+	storyDiggs.innerHTML = $a(story, 'diggs').escapeEntities();
326
+	storyComments.innerHTML = $a(story, 'comments').escapeEntities();
327
+	storyDesc.innerHTML = $et('description', story).textContent.escapeEntities();
328
+	storyLink.href = $a(story, 'link');
329
+	storyHref.href = $a(story, 'href');
330
+        
331
+        storyCEIcon.src = "chrome://diggsidebar/content/image/down.jpg";
332
+        storyRead.style.textDecoration = "line-through";
333
+        storyRead.style.backgroundColor = "black";
334
+        storyRead.style.color = "white";
335
+        storyRead.title = "Read";
336
+        storyNew.style.textDecoration = "line-through";
337
+        storyNew.style.backgroundColor = "black";
338
+        storyNew.style.color = "white";
339
+        storyNew.title = "Old";
340
+        
341
+	storyDetails.style.display = 'block';
342
+        
343
+        $ei('diggIndicator').style.display = 'none';
344
+}
345
+
346
+function getStories() {
347
+	//alert("inside getStories");
348
+        var prefs = Components.classes["@mozilla.org/preferences-service;1"].
349
+                getService(Components.interfaces.nsIPrefBranch);
350
+        ep = prefs.getCharPref("extensions.diggsidebar.endpoint") || '';
351
+        //alert(ep);
352
+        $ei('diggEndPoint').value = "digg" + ep;
353
+        
354
+        //ep ='';
355
+	fetchData("http://services.digg.com/stories" + ep.replace(/\/all/g, '') + "?count=30" +
356
+		"&appkey=" + encodeURIComponent("http://diggsidebar.googlepages.com"),
357
+		populateStoryList);
358
+        //gsti = window.setTimeout(getStories, prefs.getIntPref("extensions.diggsidebar.updateinterval"));
359
+}
360
+
361
+function getDescription(storyId) {
362
+        myDump(storyId);
363
+        if (storyId == null) return;
364
+	fetchData("http://services.digg.com/story/" + storyId +
365
+		"?appkey=" + encodeURIComponent("http://diggsidebar.googlepages.com"),
366
+		populateDescription);
367
+}
368
+
369
+function createMenu() {
370
+        fetchData("http://services.digg.com/topics" +
371
+		"?appkey=" + encodeURIComponent("http://diggsidebar.googlepages.com"),
372
+                populateMenu);
373
+}
374
+
375
+function openInTab(href) {
376
+        var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
377
+                   .getInterface(Components.interfaces.nsIWebNavigation)
378
+                   .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
379
+                   .rootTreeItem
380
+                   .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
381
+                   .getInterface(Components.interfaces.nsIDOMWindow);
382
+        mainWindow.getBrowser().selectedTab = mainWindow.getBrowser().addTab(href);
383
+}
384
+
385
+function setEndPoint(ep) {
386
+        var prefs = Components.classes["@mozilla.org/preferences-service;1"].
387
+                getService(Components.interfaces.nsIPrefBranch);
388
+        prefs.setCharPref("extensions.diggsidebar.endpoint", ep);
389
+        window.clearTimeout(gsti);
390
+        //window.clearInterval(psi);
391
+        getStories();
392
+}
393
+
394
+function togglePlayPause() {
395
+        if (playing) {
396
+               window.clearTimeout(gsti);
397
+               //window.clearInterval(psi);
398
+               $ei('diggPlayPause').image = "chrome://diggsidebar/content/image/Play.png";
399
+               $ei('diggPlayPause').setAttribute("tooltiptext", "Click to Start autoupdate");
400
+               playing = false;
401
+        } else {
402
+                var prefs = Components.classes["@mozilla.org/preferences-service;1"].
403
+                        getService(Components.interfaces.nsIPrefBranch);
404
+                updateInterval = prefs.getIntPref("extensions.diggsidebar.updateinterval")
405
+                updateIntervalDecay = prefs.getIntPref("extensions.diggsidebar.updateintervaldecay");
406
+        
407
+                timeout = Math.round(updateInterval*(Math.pow(1.5, updateIntervalDecay)));
408
+                //newTimeout = Math.round(timeout*parseInt($ei("diggIndicator").getAttribute('value'))/100);
409
+                gsti = window.setTimeout(getStories, timeout);
410
+                //psi = window.setInterval(showProgress, Math.round(timeout/100));
411
+                //window.setTimeout("window.clearInterval(psi)", newTimeout);
412
+                $ei('diggPlayPause').image = "chrome://diggsidebar/content/image/Pause.png";
413
+                $ei('diggPlayPause').setAttribute("tooltiptext", "Click to Pause autoupdate");
414
+                playing = true;
415
+        }
416
+}
417
+
418
+
419
+function myDump(aMessage) {
420
+  var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
421
+                                 .getService(Components.interfaces.nsIConsoleService);
422
+  consoleService.logStringMessage("Diggsidebar: " + aMessage);
423
+}
424
+
425
+
426
+/*TODO
427
+ preferences
428
+ toolbar button
429
+ refresh button
430
+ */
431
+/*DONE
432
+ v0.2
433
+ added kdb navigation
434
+ Added progressmeter
435
+ added error notification
436
+ added accesskeys
437
+ added new story notification
438
+ 
439
+ v0.2.1
440
+ adaptive polling interval
441
+ promote_date
442
+ pause/play
443
+ 
444
+ v0.5
445
+ new ui
446
+*/

+ 83
- 0
chrome/content/diggsidebar.xul View File

@@ -0,0 +1,83 @@
1
+<?xml version="1.0"?>
2
+<?xml-stylesheet href="chrome://global/skin/" type="text/css" ?>
3
+<?xml-stylesheet href="chrome://browser/skin/browser.css" type="text/css" ?>
4
+<?xml-stylesheet href="chrome://diggsidebar/skin/diggsidebar.css" type="text/css" ?>
5
+<!DOCTYPE page SYSTEM "chrome://diggsidebar/locale/diggsidebar.dtd">
6
+
7
+<page id="sbDiggSidebar" title="&diggsidebar.title;"
8
+    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
9
+    xmlns:html="http://www.w3.org/1999/xhtml"
10
+    onload="createMenu();getStories()">
11
+    <script src="chrome://diggsidebar/content/diggsidebar.js" type="application/x-javascript" />
12
+    <hbox>
13
+        <toolbar flex="1">
14
+            <toolbaritem>
15
+                <menubar id="diggsidebarMenubar" flex="1" style="width: 100%">
16
+                    <menu id="storiesMenu" label="Stories" accesskey="S">
17
+                        <menupopup id="storiesPopup">
18
+                            <menuitem label="All" value="/all" oncommand="setEndPoint(this.value)" accesskey="A" />
19
+                            <menuitem label="Popular" value="/popular" oncommand="setEndPoint(this.value)" accesskey="P" />
20
+                            <menuitem label="Upcoming" value="/upcoming" oncommand="setEndPoint(this.value)" accesskey="U" />
21
+                            <menuseparator />
22
+                            <menu id="containerMenu" label="Containers" accesskey="C">
23
+                                <menupopup id="containerPopup">
24
+                                    <menuitem label="Populating..." />
25
+                                </menupopup>
26
+                            </menu>
27
+                            <menu id="topicMenu" label="Topics" accesskey="T">
28
+                                <menupopup id="topicPopup">
29
+                                    <menuitem label="Populating..." />
30
+                                </menupopup>
31
+                            </menu>
32
+                        </menupopup>
33
+                    </menu>
34
+                </menubar>
35
+            </toolbaritem>
36
+            <toolbarbutton id="diggPlayPause" image="chrome://diggsidebar/content/image/Pause.png" tooltiptext="Click to Pause autoupdate" oncommand="togglePlayPause()" />
37
+            <toolbarspacer flex="5" />
38
+            <toolbaritem>
39
+                <progressmeter flex="1" width="5" mode="undetermined" id="diggIndicator" style="height: 85% !important; width: 30% !important" />
40
+            </toolbaritem>
41
+            
42
+        </toolbar>        
43
+    </hbox>
44
+    <description id="diggEndPoint">digg</description>
45
+    <richlistbox flex="1" id="storyList" onselect="getDescription(this.selectedItem.id.substr(6))"></richlistbox>
46
+    <html:div id="storyTitleFormat" style="display:none">
47
+        <html:span class="storyHeader">
48
+            <html:span class="storyRead" title="Unread">R</html:span>
49
+            <html:span class="storyNew" title="New">N</html:span>
50
+            <html:img src="chrome://diggsidebar/content/image/up.jpg" class="storyCEIcon" />
51
+            <html:span class="storyTitle"></html:span>
52
+        </html:span>
53
+    </html:div>
54
+    <html:div id="storyDetailsFormat" style="display:none">
55
+	<html:div class="storyDetails">
56
+	    <html:div>
57
+		<html:span class="storyDate"></html:span>
58
+		<html:span class="storyStatus"></html:span>
59
+	    </html:div>
60
+	    <html:div>
61
+		<html:span class="storyContainer"></html:span> &gt; <html:span class="storyTopic"></html:span>
62
+	    </html:div>
63
+	    <html:div>
64
+		<html:span class="storyPopularity">
65
+		    <html:img src="chrome://diggsidebar/content/image/digg.png" width="15px" />
66
+		    <html:span class="storyDiggs"></html:span>
67
+		    <html:img src="chrome://diggsidebar/content/image/comments.png" width="15px" />
68
+		    <html:span class="storyComments"></html:span>
69
+		</html:span>
70
+                <html:span class="storyUserLink">
71
+		    submitted by: <html:a class="storyUserName" onclick="openInTab(this.href); return false"></html:a>
72
+		</html:span>
73
+	    </html:div>
74
+	    <html:div class="storyDesc"></html:div>
75
+	    <html:div>
76
+                <html:img src="chrome://diggsidebar/content/image/external.png"  style="float: left" />
77
+		<html:a class="storyLink" onclick="openInTab(this.href); return false">Link to Article</html:a>
78
+		<html:a class="storyHref" onclick="openInTab(this.href); return false">Digg This</html:a>
79
+                <html:img src="chrome://diggsidebar/content/image/digg_this.png" width="15px" style="float: right" />
80
+	    </html:div>
81
+	</html:div>
82
+    </html:div>
83
+</page>

+ 28
- 0
chrome/content/firefoxOverlay.xul View File

@@ -0,0 +1,28 @@
1
+<?xml version="1.0"?>
2
+
3
+<!DOCTYPE overlay SYSTEM "chrome://diggsidebar/locale/diggsidebar.dtd">
4
+<overlay id="diggSidebarOverlay"
5
+         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
6
+  
7
+  <menupopup id="viewSidebarMenu">
8
+    <menuitem key="key_openDiggSidebar" observes="viewDiggSidebar"  />
9
+  </menupopup>
10
+  
11
+  <keyset id="mainKeyset">
12
+    <key id="key_openDiggSidebar" command="viewDiggSidebar"
13
+         key="&openDiggSidebar.commandkey;" 
14
+         modifiers="&openDiggSidebar.modifierskey;" />
15
+  </keyset>
16
+  
17
+  <broadcasterset id="mainBroadcasterSet"> 
18
+    <broadcaster id="viewDiggSidebar" 
19
+                 label="&diggsidebar.title;"
20
+                 autoCheck="false"
21
+                 type="checkbox"
22
+                 group="sidebar"
23
+                 sidebarurl="chrome://diggsidebar/content/diggsidebar.xul"
24
+                 sidebartitle="&diggsidebar.title;"
25
+                 oncommand="toggleSidebar('viewDiggSidebar');" />
26
+  </broadcasterset>
27
+</overlay>
28
+

BIN
chrome/content/image/Pause.png View File


BIN
chrome/content/image/Play.png View File


BIN
chrome/content/image/comments.png View File


BIN
chrome/content/image/digg.png View File


BIN
chrome/content/image/digg_this.png View File


BIN
chrome/content/image/down.jpg View File


BIN
chrome/content/image/external.png View File


BIN
chrome/content/image/up.jpg View File


+ 3
- 0
chrome/locale/en-US/diggsidebar.dtd View File

@@ -0,0 +1,3 @@
1
+<!ENTITY diggsidebar.title "Digg Sidebar">
2
+<!ENTITY openDiggSidebar.commandkey "D">
3
+<!ENTITY openDiggSidebar.modifierskey "accel shift">

+ 79
- 0
chrome/skin/diggsidebar.css View File

@@ -0,0 +1,79 @@
1
+.storyList {
2
+    margin: 1px;
3
+    border-style: solid !important;
4
+    border-color: #000;
5
+    border-width: 1px;
6
+    -moz-border-bottom-colors: #000 !important;
7
+    -moz-border-top-colors: #000 !important;
8
+    -moz-border-left-colors: #000 !important;
9
+    -moz-border-right-colors: #000 !important;
10
+}
11
+
12
+.storyDetails {
13
+    padding: 3px;
14
+    display: none;
15
+    background-color: #ffffff;
16
+    clear: both;
17
+}
18
+.storyDetails > div {
19
+    clear: both;
20
+    height: 15px;
21
+    padding: 1px 0px;
22
+    font-size: x-small;
23
+}
24
+.storyTitle {
25
+    padding: 0px 5px;
26
+    font-size: x-small;
27
+    font-weight: bold;
28
+}
29
+.storyDate, .storyDate, .storyLink {
30
+    float: left;
31
+}
32
+
33
+.storyStatus, .storyNew, .storyRead, .storyPopularity, .storyHref {
34
+    float: right;
35
+}
36
+
37
+.storyNew, .storyRead {
38
+    padding: 0px 2px;
39
+}
40
+.storyDesc {
41
+    height: auto!important;
42
+}
43
+
44
+.storyHeader {
45
+    cursor: pointer;
46
+}
47
+a {
48
+    color: blue;
49
+    cursor: pointer;
50
+    padding: 1px;
51
+}
52
+
53
+a:hover {
54
+    color: white;
55
+    background-color: blue;
56
+}
57
+
58
+richlistitem {
59
+    border-bottom: 1px solid black;
60
+    padding-bottom: 3px;
61
+    color: #000000!important;
62
+}
63
+
64
+richlistitem > div{
65
+    width: 250px;
66
+}
67
+richlistitem[selected="true"] {
68
+    background-color: #FFFBF0;
69
+    color: inherit;
70
+}
71
+richlistitem[selected="true"] .storyDetails {
72
+    border-top: 1px dashed black;
73
+    background-color: #FFFBF0;
74
+}
75
+    
76
+richlistitem .storyTitle:hover {
77
+    background-color: green;
78
+    color: white;
79
+}

+ 3
- 0
defaults/preferences/defaults.js View File

@@ -0,0 +1,3 @@
1
+pref("extensions.diggsidebar.endpoint", "");
2
+pref("extensions.diggsidebar.updateinterval", 30000);
3
+pref("extensions.diggsidebar.updateintervaldecay", 0);

+ 19
- 0
install.rdf View File

@@ -0,0 +1,19 @@
1
+<?xml version="1.0"?>
2
+<RDF:RDF xmlns:em="http://www.mozilla.org/2004/em-rdf#"
3
+         xmlns:NC="http://home.netscape.com/NC-rdf#"
4
+         xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
5
+  <RDF:Description RDF:about="rdf:#$55wJ23"
6
+                   em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
7
+                   em:minVersion="1.5"
8
+                   em:maxVersion="3.0.*" />
9
+  <RDF:Description RDF:about="urn:mozilla:install-manifest"
10
+                   em:id="diggsidebar@abhinavsarkar.net"
11
+                   em:name="Digg Sidebar"
12
+                   em:version="0.5.1"
13
+                   em:creator="Abhinav Sarkar"
14
+                   em:description="Shows Digg stories in real time in firefox sidebar."
15
+                   em:homepageURL="http://code.google.com/p/digg-sidebar/"
16
+                   em:iconURL="chrome://diggsidebar/content/image/digg_this.png">
17
+    <em:targetApplication RDF:resource="rdf:#$55wJ23"/>
18
+  </RDF:Description>
19
+</RDF:RDF>

Loading…
Cancel
Save