Permalink
Browse files

Rough but working

  • Loading branch information...
1 parent ea76a98 commit 95642a2889518523679c3b39de587ea62717279a @paddy2k committed Oct 19, 2011
Showing with 39 additions and 57 deletions.
  1. +2 −2 config.xml
  2. BIN ie.png
  3. +5 −12 index.html
  4. +32 −43 options.html
View
@@ -6,10 +6,10 @@
</feature>
<icon src="ie.png"/>
<access origin="*"/>
- <preference name="feedUrl" value=""/>
+ <preference name="feedUrl" value="http://www.irishrail.ie/realtime/publicinfo.asp?strLocation="/>
<preference name="count" value="5"/>
<preference name="interval" value="7"/>
- <preference name="defaultFeed" value="http://www.irishrail.ie/realtime/publicinfo.asp?strLocation=cnlly"/>
+ <preference name="stationCode" value="cnlly"/>
<author href="http://smallroomstudios.net">Smallroomstudios.net</author>
<description xml:lang="en">Get realtime timetable information for Irish Rail stations. Source: https://github.com/paddy2k/Speeddial-Traein</description>
</widget>
View
BIN ie.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -36,10 +36,10 @@
}
// opera.contexts.speeddial.url = _data.items[ind].href;
- document.getElementById('english').textContext = stations['CNLLY'].en;
- document.getElementById('irish').textContext = stations['CNLLY'].ga;
+ document.getElementById('english').innerHTML = stations[_data.station].en;
+ document.getElementById('irish').innerHTML = stations[_data.station].ga;
- opera.contexts.speeddial.title = stations['CNLLY'].en;
+ opera.contexts.speeddial.title = stations[_data.station].en;
opera.contexts.speeddial.url = "http://www.irishrail.ie";
// switch feeds every X seconds
_data.timer = setTimeout(function(){_updateFeeds(next)}, _data.interval * 1000);
@@ -110,7 +110,7 @@
}
xhr = new XMLHttpRequest();
- xhr.open( 'GET', _data.feed, true );
+ xhr.open( 'GET', _data.feed + _data.station, true );
xhr.onreadystatechange=function()
{
if( this.readyState!==4 ){
@@ -129,6 +129,7 @@
{
clearTimeout(_updateTimer);
_data.feed = _data.prefs.getItem('feedUrl');
+ _data.station = _data.prefs.getItem('stationCode');
_data.count = _data.prefs.getItem('count');
_data.interval = _data.prefs.getItem('interval');
@@ -248,14 +249,6 @@ <h1 id="title"></h1>
<div id="english">Pearse Station</div>
</div>
<div id="arrivals">
- <div class="arrival">
- <div class="to">
- 23:40 Drogheda
- </div>
- <div class="from">
- Arriving from Greystones
- </div>
- </div>
</div>
</div>
</body>
View
@@ -1,7 +1,8 @@
<!doctype html>
<html>
<head>
-<title id="widget-title">Opera Extensions | Name of Extension</title>
+<title id="widget-title">Irish Rail | Iarnród Éireann</title>
+<script src="stations.js"></script>
<style>
html
{
@@ -56,20 +57,20 @@
{
font:normal 18px sans-serif;
text-shadow:0 1px 0 #fff;
-}
-.buttons{
- text-align: center;
-}
-.buttons input{
- font-size: 16px;
+}
+.buttons{
+ text-align: center;
+}
+.buttons input{
+ font-size: 16px;
}
.feed-url{
width:450px;
}
header{
height:64px;
padding-left:72px;
- background:url(64.png) 2px 2px no-repeat;
+ background:url(ie.png) 2px 2px no-repeat;
margin-bottom:32px;
white-space:nowrap;
}
@@ -104,22 +105,11 @@
<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>
- <select name="defaultFeed">
+ <legend>Choose Station:</legend>
+ <select id="stationCode" name="stationCode">
<option value=""></option>
- <option value="http://rss.slashdot.org/Slashdot/slashdot">Slashdot</option>
- <option value="http://feeds.bbci.co.uk/news/rss.xml">BBC News</option>
- <option value="http://feeds.wired.com/wired/index">Wired</option>
- <option value="http://www.engadget.com/rss.xml">Engadget</option>
- <option value="http://feeds.reuters.com/reuters/topNews">Reuters</option>
</select>
</fieldset>
-
- <fieldset>
- <legend>Or add your favourite feed URL:</legend>
- <input class="feed-url" type="url" name="feedUrl" value=""/>
- </fieldset>
-
<fieldset>
<legend>Choose feeds number:</legend>
<input type="number" name="count" min="1" value="1"/>
@@ -128,10 +118,10 @@
<fieldset>
<legend>Set time interval (seconds):</legend>
<input type="number" name="interval" min="1" value="1"/>
- </fieldset>
-
- <div class="buttons view-mode">
- <input type="button" onclick="window.close();" value="Done"/>
+ </fieldset>
+
+ <div class="buttons view-mode">
+ <input type="button" onclick="window.close();" value="Done"/>
</div>
</div>
<script>
@@ -140,14 +130,24 @@
{
var storage = window.widget.preferences;
var formElements = document.querySelectorAll( 'input,select' );
+
+ function addStations(){
+ var list = document.getElementById('stationCode');
+ for(station in stations){
+ var option = document.createElement('option');
+ option.value=station;
+ option.innerHTML=stations[station].en;
+ list.appendChild(option);
+ }
+ }
+ addStations();
+
- function walkElements()
- {
+ function walkElements(){
var type,
value;
- for( var i=0,element=null; element=formElements[i++]; )
- {
+ for( var i=0,element=null; element=formElements[i++]; ){
value = storage.getItem(element.name);
type = element.type.toLowerCase();
if (type == 'number') element.value = value;
@@ -160,15 +160,11 @@
}
}
}
- else if (type == 'url' && (!storage.getItem( 'defaultFeed') || storage.getItem( 'defaultFeed') == '')){
- document.getElementsByName('feedUrl')[0].value = value;
- }
element.addEventListener( 'change', changedElement, true );
}
}
- function changedElement(e)
- {
+ function changedElement(e){
var element = e.currentTarget;
var type = element.type.toLowerCase();
var name = element.name;
@@ -181,20 +177,13 @@
}
else if (type == 'select-one') {
value = element.options[element.selectedIndex].value;
- document.getElementsByName('feedUrl')[0].value = '';
- storage.setItem( 'feedUrl', value );
- }
- else if (type == 'url'){
- document.getElementsByName('defaultFeed')[0].selectedIndex = 0;
- storage.setItem( 'defaultFeed', '' );
}
storage.setItem( name, value );
}
walkElements();
- function $( id, txt, href )
- {
+ function $( id, txt, href ){
var e = document.getElementById(id);
if( e )
{
@@ -215,4 +204,4 @@
</script>
</body>
-</html>
+</html>

0 comments on commit 95642a2

Please sign in to comment.