Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: François de Metz <fdemetz@af83.com>
- Loading branch information
0 parents
commit 7f90f6b
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
(function(win, $) { | ||
// keeping an index for each project. | ||
var nbInstance = 0; | ||
|
||
/** | ||
* Use to watch a project state on jenkins | ||
*/ | ||
win.JenkinsState = function JenkinsState(options) { | ||
|
||
var numInstance = nbInstance++; | ||
|
||
// prepare our html report window. | ||
var content = $('<div style="position:fixed;left:0;bottom:' + 70 * numInstance + 'px;right:0;width:180px;height:55px;background:rgba(255,255,255,0.9);padding:5px;text-align:center;border-radius:5px;border:1px solid #666;"><h1 style="margin:0;font:bold 12px/20px Arial;color:#666;">' + options.project + '</h1><a class="build" target="_blank"><img class="color" style="border:none"/><img class="weather" style="border:none"/></a></div>'); | ||
$('body').append(content); | ||
|
||
var color = content.find('.color'); | ||
var weather = content.find('.weather'); | ||
var build = content.find('.build'); | ||
|
||
// to change current image state from data. | ||
function refresh(data) { | ||
color.attr('src', "http://" + options.host + "/static/8caf2d87/images/32x32/" + data.color + ".gif"); | ||
weather.attr('src', "http://" + options.host + "/static/8caf2d87/images/32x32/" + data.healthReport[0].iconUrl); | ||
build.attr('href', "http://" + options.host + "/job/" + options.project + "/lastBuild"); | ||
} | ||
|
||
// to query the api for state. | ||
function query() { | ||
$.ajax({ | ||
url: "http://" + options.host + "/job/" + options.project + "/api/json", | ||
dataType: "jsonp", | ||
jsonp: 'jsonp', | ||
success: function(data) { | ||
refresh(data) | ||
} | ||
}); | ||
} | ||
|
||
// ask the state to jenkins. | ||
query(); | ||
} | ||
})(window, jQuery); |