/*
GAMETRACKER SERVER NOTIFIER
(c) Anthony Nichols
http://www.onefivedesign.com
v 1.0
VERSION HISTORY:
================
>2009-07-20 :: v1.0
* First release.
*/
jetpack.future.import("storage.simple");
jetpack.statusBar.append({
html: '<span style="font-family: tahoma;margin: 2px 0 0;"><a style="color: #000;" id="GTLink" href="#" target="_blank"><img style="height:12px;width:12px;border:0;margin:0 4px 0;vertical-align:middle;" src="http://www.gameservers.com/favicon.ico" /></a><span style="font-size:12px;"> Players: </span><span id="GTDiv" style="font-size:12px;"></span><span id="GTAdd" style="cursor:pointer; font-size:10px;"> (Add)</span></span>',
width: 160,
onReady: function (doc) {
var myStorage = jetpack.storage.simple;
$(doc).find("#GTAdd").click(function() {
var work = jetpack.tabs.focused.contentWindow.location.href;
if (work.indexOf("gametracker.com/server_info/") == 11) {
myStorage.loc = work;
jetpack.notifications.show({ title: "SUCCESS", body: "Server added!" });
} else {
jetpack.notifications.show({ title: "ERROR", body: "The current tab is not a http://www.gametracker.com/server_info/ page!" });
}
});
function getGTData () {
var players;
var fullurl = myStorage.loc;
$.get(fullurl, function(html) {
players = $("#HTML_num_players", html).text();
$(doc).find("#GTDiv").text(players);
$(doc).find("#GTLink").attr({ href: fullurl });
if ( players > 0 ) {
jetpack.notifications.show({ title: "PLAYERS", body: "There are currently players on your server!" });
}
});
}
jetpack.tabs.onReady(getGTData);
setInterval(getGTData, 60000);
}
});