Skip to content

Instantly share code, notes, and snippets.

@naheed
Created April 9, 2009 18:59
Show Gist options
  • Save naheed/92669 to your computer and use it in GitHub Desktop.
Save naheed/92669 to your computer and use it in GitHub Desktop.
salah for firefox ubiquity
CmdUtils.CreateCommand({
name: "salah",
takes: {"location": noun_arb_text},
icon: "http:/mcabayarea.org/favicon.ico",
description: "Gets 5 prayer times for a given location.",
homepage: "http://www.islamicfinder.org/",
author: {name: "Naheed Vora", email: "naheed@gmail.com"},
help: "List prayer times for zip-codes. It uses islamicfinder as backend. Some of the zip codes do not work, so try nearby areas if it does not update the page with prayer times. This is work in progress and if anybody is interested in updating the look and feel of the output, please do so by grabbing this gist or else send me email.",
execute: function( directObj ) {
var location = directObj.text;
var url = "http://www.islamicfinder.org/prayerDetail.php?country=usa&lang=&zipcode=";
url += escape( location );
Utils.openUrlInBrowser( url );
},
preview: function( pblock, directObj ) {
var location = directObj.text;
if( location.length < 1 ) {
pblock.innerHTML = "Gets the prayertimes for given zip code.";
return;
}
var url = "http://www.islamicfinder.org/prayerPrintable.php?id=&country2=Usa&today_date_flag=2009-4-7&changeTime=16&pmethod=5&HanfiShafi=1&dhuhrInterval=1&maghribInterval=1&dayLight=1&dayl=1&dayLight_self_change=&prayerCustomize=&lang=&fajrTwilight=0&ishaTwilight=0&ishaInterval=0";
var date = new Date();
var d = date.getDay();
var m = date.getMonth() + 1;
var y = date.getFullYear();
var params = {
zipcode: location,
month: m,
year: y
};
jQuery.get( url, params, function(doc) {
pblock.innerHTML = doc;
return;
var h = "<style>img{float: left;} #wrap {} h2{border-top:1px solid #999; margin:0px;padding:2px;background:#999;} .d{float:left; margin-bottom:5px;width:100px;} body {font-family: arial, helvetica; color:white;} </style>" ;
h += ' <div id="wrap"> ';
h += ' <h1></h1><div id="fajr" class="d"/>';
h += ' <div id="sunrise" class="d"/>';
h += ' <div id="duhr" class="d"/>';
h += ' <div id="asr" class="d"/>';
h += ' <div id="maghrib" class="d"/>';
h += ' <div id="isha" class="d"/>';
h += ' </div> ';
// jQuery(pblock).html( h );
var fajr;
var sunrise;
var duhr;
var asr;
var maghrib;
var isha;
var html = CmdUtils.renderTemplate( {file:"prayertimes.html"}, {w:prayertimes});
jQuery(pblock).append(html );
jQuery(doc).("table > tbody > tr").eq(d) (function(index) {
jQuery(pblock).append("blah" + this.innerHTML +"<br>");
});
// daily conditions
}, "html");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment