-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.js
34 lines (32 loc) · 906 Bytes
/
functions.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
function test_connection(callback) {
$.ajax({
type: "GET",
url: "https://" + settings.server + "/on/demandware.servlet/webdav/Sites/Logs/",
beforeSend: function (xhr){
xhr.setRequestHeader('Authorization', make_base_auth(settings.username, settings.password));
},
error : function() {
callback('error')
},
success: function (response){
callback('ok');
}
});
}
function make_base_auth(user, password) {
var tok = user + ':' + password;
var hash = btoa(tok);
return "Basic " + hash;
}
function open_link_in_tab() {
var links = document.getElementsByTagName("a");
for (var i = 0; i < links.length; i++) {
(function () {
var ln = links[i];
var location = ln.href;
ln.onclick = function () {
chrome.tabs.create({active: true, url: location});
};
})();
}
}