-
Notifications
You must be signed in to change notification settings - Fork 1
/
bar.html
102 lines (94 loc) · 3.68 KB
/
bar.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE html>
<html>
<head>
<title>WootChecker</title>
<link rel="stylesheet" href="styles/main.css" type="text/css"/>
<script type="text/javascript">
const myGlobal = safari.extension.globalPage.contentWindow;
const STORAGE_KEY = "_wootToolBar";
var mData = undefined;
var mAudio = undefined;
var audioAlert = undefined;
function onLoad(){
if(typeof myGlobal.getFeed != "function")
return false;
myGlobal.getFeed(localStorage.getItem(STORAGE_KEY));
showLoader(true);
//mAudio = document.getElementById("audioObj");
//mAudio.src = safari.extension.baseURI + "alert.wav";
//mAudio.src = "http://clmov.de/tool/cs/login.wav";
//audioAlert = new Audio("http://clmov.de/tool/cs/login.wav");
//audioAlert = new Audio(safari.extension.baseURI + "login.wav");
//alert("audio loc: " + safari.extension.baseURI + "login.wav")
//document.getElementById("tempAudio").play();
}
function updateContent(data){
//alert("data: " + data.itemPrice + " // " + data.itemName);
mData = data;
showLoader(false);
if(mData.isWootOff == "True"){
//do woot off stuff???
}
(mData.isSoldOut == "True") ? document.getElementById("soldOut").style.display = "block" : document.getElementById("soldOut").style.display = "none";
document.getElementById("price").innerHTML = '<a href="javascript:void(0)">'+mData.itemPrice+'</a>';
document.getElementById("name").innerHTML = '<a href="javascript:void(0)">'+mData.itemName+'</a>';
document.getElementById("chatB").innerHTML = "Discussion(" + mData.comments + ")";
document.getElementById("name").title = mData.teaser;
//Play audio tone
//audioAlert.play();
//set correct index (maybe move???)
var dd = document.getElementById("dropdown");
(localStorage.getItem(STORAGE_KEY) == null) ? dd.selectedIndex = 0 : dd.selectedIndex = parseInt(localStorage.getItem(STORAGE_KEY),10);
}
function linkBuy(){
var newTab = safari.self.browserWindow.openTab();
newTab.url = mData.buyLink;
}
function linkChat(){
var newTab = safari.self.browserWindow.openTab();
newTab.url = mData.chatLink;
}
function openWoot(){
var newTab = safari.self.browserWindow.openTab();
newTab.url = mData.homeLink;
}
function updateWootSelection(id){
showLoader(true);
myGlobal.getFeed(parseInt(id, 10));
}
function showLoader(show){
if(show){
document.getElementById('loadIcon').src = "img/ajax-loader.gif";
}else{
document.getElementById('loadIcon').src = "img/favicon.png";
}
}
</script>
</head>
<body onload="onLoad();">
<div id="content">
<!-- Left Text -->
<div id="icon" class="lItem"><img id="loadIcon" src="img/ajax-loader.gif" onclick="openWoot();"/></div>
<div id="selector" class="lItem">
<select id="dropdown" onchange="updateWootSelection(this.options[this.selectedIndex].value);">
<option value="0">Woot.Woot!</option>
<option value="1">Shirt.Woot!</option>
<option value="2">Kids.Woot!</option>
<option value="3">Wine.Woot!</option>
</select>
</div>
<div class="lItem divider"></div>
<div id="soldOut" class="lItem" onclick="openWoot();">Sold Out!</div>
<div id="price" class="lItem" onclick="openWoot();">Loading...</div>
<div id="name" class="lItem" onclick="openWoot();"></div>
<!-- Right Buttons -->
<div id="chat" class="rItem"><a id="chatB" class="buttonClass" href="javascript:linkChat();">Discussion</a></div>
<div class="rItem divider"></div>
<div id="buy" class="rItem"><a id="buyB" class="buttonClass" href="javascript:linkBuy();">I want one!</a></div>
<!--
<div id="chat" class="rItem"><input id="chatB" type="button" value="Discussion" onclick="linkChat();"></div>
<div id="buy" class="rItem"><input id="buyB" type="button" value="I want one!" onclick="linkBuy();"></div>
-->
</div>
</body>
</html>