-
Notifications
You must be signed in to change notification settings - Fork 1
/
d2n.js
43 lines (33 loc) · 1.29 KB
/
d2n.js
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
var skey;
var inUpdate = false;
function updateHeroPanel() {
inUpdate = true;
var hero = $('#heroPanel');
$('<div class="separator"/>').appendTo(hero.parent());
var div = $('<div/>');
var img = '<img src="'+ chrome.extension.getURL('16x16.png') +'">';
var mouse = "onmouseover=\"js.HordeTip.showSpecialTip(this, 'simpleTip', '', 'Update external map');\" onmouseout=\"js.HordeTip.hide()\"";
var a = $('<a class="button" id="updateMapButton" '+ mouse +'>'+ img +'Update map</a>');
a.appendTo(hero.parent());
a.click(function() {
div.html('Updating...');
chrome.extension.sendRequest({method: 'postUpdate', key: skey}, function(response) {
div.html(response.text);
window.setTimeout(function() { div.html('') }, 2500);
});
});
div.appendTo(hero.parent());
inUpdate = false;
}
$(window).load(function(){
chrome.extension.sendRequest({method: "getKey"}, function(response) {
skey = response.key;
if(typeof skey != 'undefined') {
$('#generic_section').bind('DOMSubtreeModified', function() {
if ($('#heroPanel').length > 0 && $('#updateMapButton').length == 0 && !inUpdate) {
updateHeroPanel();
}
});
}
});
});