Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support editable extension title

  • Loading branch information...
commit ed7a8116d7fbed7175d430f610cddfd101918574 1 parent 4626074
Per Øyvind Øygard authored
Showing with 56 additions and 9 deletions.
  1. +2 −1  config.xml
  2. +12 −1 index.html
  3. +42 −7 options.html
View
3  config.xml
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
-<widget xmlns="http://www.w3.org/ns/widgets" id="https://addons.opera.com/addons/extensions/details/live-news-feed/" version="1.11" viewmodes="minimized">
+<widget xmlns="http://www.w3.org/ns/widgets" id="https://addons.opera.com/addons/extensions/details/live-news-feed/" version="1.12" viewmodes="minimized">
<name>Live news feed</name>
<feature name="opera:speeddial">
<param name="url" value="http://opera.com"/>
@@ -10,6 +10,7 @@
<preference name="count" value="5"/>
<preference name="interval" value="7"/>
<preference name="defaultFeed" value=""/>
+ <preference name="nameChecked" value="true"/>
<update-description href="https://extension-updates.opera.com/api/w3c-wd1/update/1b364c5a-f02e-4164-bbb5-14e014048672/"/>
<license>Copyright 2011 Opera Software. All rights reserved.</license>
<author href="https://addons.opera.com">Opera Software</author>
View
13 index.html
@@ -13,6 +13,7 @@
prefs : widget.preferences,
items : [],
timer : null,
+ title : '',
}
// update feeds in the speed-dial
@@ -26,13 +27,20 @@
document.getElementById('desc').textContent = _data.items[ind].desc;
document.getElementById('date').textContent = '(' + _data.items[ind].date + ')';
+
+ var name = _data.prefs.getItem('nameCheckbox') === "true"
+ ? _data.title
+ : _data.prefs.getItem('nameInput');
opera.contexts.speeddial.url = _data.items[ind].href;
+ opera.contexts.speeddial.title = name;
+ _data.feed = _data.prefs.getItem('feedUrl');
// switch feeds every X seconds
_data.timer = setTimeout(function(){_updateFeeds(next)}, _data.interval * 1000);
}
function _clearData(message){
+ opera.extension.title = "Live news feed";
document.getElementById('title').textContent = '';
document.getElementById('desc').textContent = '';
document.getElementById('date').textContent = '';
@@ -51,7 +59,10 @@
// process the data received from the XHR
function _processData(xmlDoc)
{
- var items = xmlDoc.getElementsByTagName('item');
+ var title = xmlDoc.querySelector('title');
+ _data.title = title.textContent || "No title";
+
+ var items = xmlDoc.querySelectorAll('item, entry');
var len = items.length;
if (_data.count > len) _data.count = len;
View
49 options.html
@@ -64,7 +64,14 @@
font-size: 16px;
}
.feed-url{
- width:450px;
+ width:50%;
+}
+label {
+ display: inline-block;
+ width: 45%;
+}
+fieldset div {
+ margin-bottom: 0.5em;
}
header{
height:64px;
@@ -89,7 +96,7 @@
font:normal normal 20px/20px sans-serif;
text-shadow:0 1px 0 #fff;
}
- .feed-url{width:100%;}
+ .feed-url {width:50%;}
legend
{
font:normal 14px sans-serif;
@@ -104,7 +111,9 @@
<header class="view-mode"><h1><span id="widget-name">Extension name</span></h1><h2>by <a href="#" id="widget-author">Developer</a></h2></header>
<div>
<fieldset>
- <legend>Choose feed from the list:</legend>
+ <legend>Feed source</legend>
+ <div>
+ <label for=defaultFeed>Choose feed from the list:</label>
<select name="defaultFeed">
<option value=""></option>
<option value="http://rss.slashdot.org/Slashdot/slashdot">Slashdot</option>
@@ -113,11 +122,22 @@
<option value="http://www.engadget.com/rss.xml">Engadget</option>
<option value="http://feeds.reuters.com/reuters/topNews">Reuters</option>
</select>
+ </div>
+ <div>
+ <label for=feedUrl>Or add your favourite feed URL:</label>
+ <input class="feed-url" type="url" name="feedUrl" value=""/>
+ </div>
</fieldset>
-
+
<fieldset>
- <legend>Or add your favourite feed URL:</legend>
- <input class="feed-url" type="url" name="feedUrl" value=""/>
+ <legend>Feed name:</legend>
+ <div>
+ <label for=nameCheckbox>Use name from feed:</label>
+ <input type=checkbox id=name_checkbox name=nameCheckbox />
+ </div>
+ <div>
+ <label for=nameInput>Or assign name</label>
+ <input type=text id=name_input name=nameInput />
</fieldset>
<fieldset>
@@ -163,6 +183,18 @@
else if (type == 'url' && (!storage.getItem( 'defaultFeed') || storage.getItem( 'defaultFeed') == '')){
document.getElementsByName('feedUrl')[0].value = value;
}
+ else if(element.name == "nameCheckbox") {
+ element.checked = storage.getItem(element.name) === "true";
+ element.addEventListener('change', function(e) {
+ document.getElementById('name_input').disabled = e.target.checked;
+ }, false);
+ if(element.checked) {
+ document.getElementById('name_input').disabled = true;
+ }
+ }
+ else if(element.name == "nameInput") {
+ element.value = storage.getItem(element.name);
+ }
element.addEventListener( 'change', changedElement, true );
}
}
@@ -188,6 +220,9 @@
document.getElementsByName('defaultFeed')[0].selectedIndex = 0;
storage.setItem( 'defaultFeed', '' );
}
+ else if(name === "nameCheckbox") {
+ value = !!element.checked;
+ }
storage.setItem( name, value );
}
@@ -205,7 +240,7 @@
}
}
}
-
+
$( 'widget-title', widget.name );
$( 'widget-name', widget.name );
$( 'widget-author', widget.author, widget.authorHref );
Please sign in to comment.
Something went wrong with that request. Please try again.