forked from s12v/hasher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
108 lines (97 loc) · 2.21 KB
/
popup.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
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
103
104
105
106
107
108
$(document).ready(function() {
/*
* I decided to leave popout button on the popout page
*
if (typeof chrome.extension != "undefined") {
if (chrome.extension.getBackgroundPage().separatePopup == true) {
$("#popup").hide();
} else {
$("#popup").show();
}
}
*/
/*
* Events registration
*/
$("#input").keyup(function () {
hasher.update();
});
$("#input").change(function () {
hasher.update();
});
// Open separate window (pop-out)
$("#button-popout").click(function () {
if (typeof chrome.extension != "undefined") {
//chrome.extension.getBackgroundPage().separatePopup = true;
/*
chrome.windows.create({
url: 'popup.html',
type: 'popup',
width: 700,
height: 800
});
*/
chrome.tabs.create({
url: 'popup.html'
});
}
});
// Click on tab (Hash/HMAC/...)
$("#tabs li").click(function () {
// highlight active tab, remove highlight on everything else
$("#tabs li").removeClass("on");
$(this).addClass("on");
// show/hide optional fields
if (tabs[this.id] == tabs.hmac || tabs[this.id] == tabs.cipher) {
$("#input-password-wrapper").show();
} else {
$("#input-password-wrapper").hide();
}
hasher.tab = tabs[this.id];
hasher.init();
hasher.update();
$("#input-value").focus();
});
/*
* Animations
*/
$(".buttons-2").mouseenter(function(){
$(this).animate(
{
opacity: 0.8
},
150
);
});
$(".buttons-2").mouseleave(function(){
$(this).animate(
{
opacity: 0.4
},
300
);
});
/*
* Hash navigation
*/
onHashChange = function () {
var hash = window.location.hash.slice(1)
$(".screens").hide();
if (hash == "info") {
$("#screen-2").show().scrollTop();
} else {
$("#screen-1").show().scrollTop();
}
}
$(window).bind('hashchange', onHashChange);
/*
* Init
*/
onHashChange();
hasher.init();
hasher.update();
// Focus hack, see http://stackoverflow.com/a/11400653/1295557
if (location.search != "?focusHack") location.search = "?focusHack";
//$("#input-value").focus();
window.scrollTo(0, 0);
});