forked from dgouyette/ci-chrome-notification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.js
46 lines (40 loc) · 1.49 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
function cleanForId(toClean){
return toClean.replace(/[^a-zA-Z0-9]+/g,'');;
}
//find all views and fill each one with corresponding builds
function findAllViews(){
$.getJSON(localStorage["urlCI"]+'/api/json', function(data) {
$.each(data.views, function(key, val) {
var cleanViewID = cleanForId(val.name);
findAllJobsByViewId(val.name);
$("#tabs").tabs("add","#"+cleanViewID, cleanViewID);
});
});
}
//Find all jbos for a given view
function findAllJobsByViewId(viewID){
$.getJSON(localStorage["urlCI"]+'/view/'+viewID+"/api/json/", function(data) {
var cleanViewID=cleanForId(viewID);
$.each(data.jobs, function(key, val) {
var buildID = val.name;
if (localStorage.jobs){
jobs = JSON.parse(localStorage.jobs);
}
if($.inArray(buildID, jobs)!=-1){
$("#"+cleanViewID).append('<span><input class="jobs" id=' + buildID + ' onclick="updateListBuildToNotificate()" checked=checked type="checkbox"/> ' + buildID + '</span><br/>');
}
else{
$("#"+cleanViewID).append('<span><input class=jobs id=' + buildID + ' onclick="updateListBuildToNotificate()" type="checkbox"/> ' + buildID + '</span><br/>');
}
});
});
}
function updateListBuildToNotificate(viewID) {
localStorage.jobs = $(".jobs:checked");
var idOfCheckedInput = [];
$(".jobs:checked").each(function(index, domEle){
idOfCheckedInput[index]=domEle.id;
})
localStorage.jobs=JSON.stringify(idOfCheckedInput);
console.log(localStorage.jobs);
}