-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstadress.js
39 lines (36 loc) · 989 Bytes
/
instadress.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
function createInstadress() {
$('body').append('<input type="text" id="instadress" />');
$instadress = $('#instadress');
$instadress.css({
'padding': '3px',
'font-size': '14px',
'border': 'solid 1px #878787',
'position': 'fixed',
'top': '0',
'right': '0',
'z-index': '100000'
});
$instadress.hide();
}
function toggleInstadress() {
$(document).keypress(function(e) {
if (!($('textarea').is(':focus') || $('input').is(':focus'))) {
$instadress.fadeIn('fast');
$instadress.focus();
}
});
$(document).keyup(function(e) {
if (e.keyCode === 8 && $instadress.val().length === 0 ) {
$instadress.fadeOut();
}
else if (e.keyCode === 13 && $instadress.val().length > 0) {
goToInstadress();
}
});
}
function goToInstadress() {
$url = $instadress.val();
window.location.assign(($url.indexOf('.') === -1 ? "http://google.com/search?q=" : "http://" ) + $url);
}
createInstadress();
toggleInstadress();