Commit 8d5b1ffc authored by yangxiaodong's avatar yangxiaodong

add jsonview resource files.

parent bc1c6ca3
@charset "UTF-8";.jsonview{font-family:monospace;font-size:1.1em;white-space:pre-wrap}.jsonview .prop{font-weight:700;text-decoration:none;color:#000}.jsonview .null,.jsonview .undefined{color:red}.jsonview .bool,.jsonview .num{color:#00f}.jsonview .string{color:green;white-space:pre-wrap}.jsonview .string.multiline{display:inline-block;vertical-align:text-top}.jsonview .collapser{position:absolute;left:-1em;cursor:pointer}.jsonview .collapsible{transition:height 1.2s;transition:width 1.2s}.jsonview .collapsible.collapsed{height:.8em;width:1em;display:inline-block;overflow:hidden;margin:0}.jsonview .collapsible.collapsed:before{content:"…";width:1em;margin-left:.2em}.jsonview .collapser.collapsed{transform:rotate(0)}.jsonview .q{display:inline-block;width:0;color:transparent}.jsonview li{position:relative}.jsonview ul{list-style:none;margin:0 0 0 2em;padding:0}.jsonview h1{font-size:1.2em}
\ No newline at end of file
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
locale: document.documentElement.lang locale: document.documentElement.lang
}; };
cap.Metrics = (function() { cap.Metrics = (function () {
function Metrics() { function Metrics() {
this._metrics = {}; this._metrics = {};
} }
Metrics.prototype.addElement = function(name, element) { Metrics.prototype.addElement = function (name, element) {
if (!(name in this._metrics)) { if (!(name in this._metrics)) {
this._metrics[name] = []; this._metrics[name] = [];
} }
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
this._metrics[name].push(element); this._metrics[name].push(element);
}; };
Metrics.prototype.getElements = function(name) { Metrics.prototype.getElements = function (name) {
if (!(name in this._metrics)) { if (!(name in this._metrics)) {
return []; return [];
} }
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
return this._metrics[name]; return this._metrics[name];
}; };
Metrics.prototype.getNames = function() { Metrics.prototype.getNames = function () {
var result = []; var result = [];
var metrics = this._metrics; var metrics = this._metrics;
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
graph.render(); graph.render();
} }
cap.RealtimeGraph = (function() { cap.RealtimeGraph = (function () {
function RealtimeGraph(element, succeeded, failed, succeededStr, failedStr) { function RealtimeGraph(element, succeeded, failed, succeededStr, failedStr) {
this._succeeded = succeeded; this._succeeded = succeeded;
this._failed = failed; this._failed = failed;
...@@ -100,8 +100,16 @@ ...@@ -100,8 +100,16 @@
this._initGraph(element, { this._initGraph(element, {
renderer: 'bar', renderer: 'bar',
series: new Rickshaw.Series.FixedDuration([ series: new Rickshaw.Series.FixedDuration([
{ name: failedStr, color: '#d9534f' }, {
{ name: succeededStr, color: '#5cb85c' } name: failedStr,
//color: '#d9534f'
color: 'red'
},
{
name: succeededStr,
//color: '#5cb85c'
color: '#cb513a'
}
], ],
undefined, undefined,
{ timeInterval: 2000, maxDataPoints: 100 } { timeInterval: 2000, maxDataPoints: 100 }
...@@ -130,17 +138,19 @@ ...@@ -130,17 +138,19 @@
return RealtimeGraph; return RealtimeGraph;
})(); })();
cap.HistoryGraph = (function() { cap.HistoryGraph = (function () {
function HistoryGraph(element, succeeded, failed, succeededStr, failedStr) { function HistoryGraph(element, succeeded, failed, succeededStr, failedStr) {
this._initGraph(element, { this._initGraph(element, {
renderer: 'area', renderer: 'area',
series: [ series: [
{ {
color: '#d9534f', color: '#d9534f',
//color: 'red',
data: failed, data: failed,
name: failedStr name: failedStr
}, { }, {
color: '#6ACD65', color: '#6ACD65',
//color: 'blue',
data: succeeded, data: succeeded,
name: succeededStr name: succeededStr
} }
...@@ -153,7 +163,7 @@ ...@@ -153,7 +163,7 @@
return HistoryGraph; return HistoryGraph;
})(); })();
cap.StatisticsPoller = (function() { cap.StatisticsPoller = (function () {
function StatisticsPoller(metricsCallback, statisticsUrl, pollInterval) { function StatisticsPoller(metricsCallback, statisticsUrl, pollInterval) {
this._metricsCallback = metricsCallback; this._metricsCallback = metricsCallback;
this._listeners = []; this._listeners = [];
...@@ -165,9 +175,9 @@ ...@@ -165,9 +175,9 @@
StatisticsPoller.prototype.start = function () { StatisticsPoller.prototype.start = function () {
var self = this; var self = this;
var intervalFunc = function() { var intervalFunc = function () {
try { try {
$.post(self._statisticsUrl, { metrics: self._metricsCallback() }, function(data) { $.post(self._statisticsUrl, { metrics: self._metricsCallback() }, function (data) {
self._notifyListeners(data); self._notifyListeners(data);
}); });
} catch (e) { } catch (e) {
...@@ -178,18 +188,18 @@ ...@@ -178,18 +188,18 @@
this._intervalId = setInterval(intervalFunc, this._pollInterval); this._intervalId = setInterval(intervalFunc, this._pollInterval);
}; };
StatisticsPoller.prototype.stop = function() { StatisticsPoller.prototype.stop = function () {
if (this._intervalId !== null) { if (this._intervalId !== null) {
clearInterval(this._intervalId); clearInterval(this._intervalId);
this._intervalId = null; this._intervalId = null;
} }
}; };
StatisticsPoller.prototype.addListener = function(listener) { StatisticsPoller.prototype.addListener = function (listener) {
this._listeners.push(listener); this._listeners.push(listener);
}; };
StatisticsPoller.prototype._notifyListeners = function(statistics) { StatisticsPoller.prototype._notifyListeners = function (statistics) {
var length = this._listeners.length; var length = this._listeners.length;
var i; var i;
...@@ -201,7 +211,7 @@ ...@@ -201,7 +211,7 @@
return StatisticsPoller; return StatisticsPoller;
})(); })();
cap.Page = (function() { cap.Page = (function () {
function Page(config) { function Page(config) {
this._metrics = new cap.Metrics(); this._metrics = new cap.Metrics();
...@@ -219,7 +229,7 @@ ...@@ -219,7 +229,7 @@
this._poller.start(); this._poller.start();
}; };
Page.prototype._createRealtimeGraph = function(elementId) { Page.prototype._createRealtimeGraph = function (elementId) {
var realtimeElement = document.getElementById(elementId); var realtimeElement = document.getElementById(elementId);
if (realtimeElement) { if (realtimeElement) {
var succeeded = parseInt($(realtimeElement).data('succeeded')); var succeeded = parseInt($(realtimeElement).data('succeeded'));
...@@ -233,7 +243,7 @@ ...@@ -233,7 +243,7 @@
realtimeGraph.appendHistory(data); realtimeGraph.appendHistory(data);
}); });
$(window).resize(function() { $(window).resize(function () {
realtimeGraph.update(); realtimeGraph.update();
}); });
...@@ -243,7 +253,7 @@ ...@@ -243,7 +253,7 @@
return null; return null;
}; };
Page.prototype._createHistoryGraph = function(elementId) { Page.prototype._createHistoryGraph = function (elementId) {
var historyElement = document.getElementById(elementId); var historyElement = document.getElementById(elementId);
if (historyElement) { if (historyElement) {
var createSeries = function (obj) { var createSeries = function (obj) {
...@@ -348,11 +358,11 @@ ...@@ -348,11 +358,11 @@
if (!confirmText || confirm(confirmText)) { if (!confirmText || confirm(confirmText)) {
$this.prop('disabled'); $this.prop('disabled');
var loadingDelay = setTimeout(function() { var loadingDelay = setTimeout(function () {
$this.button('loading'); $this.button('loading');
}, 100); }, 100);
$.post($this.data('ajax'), function() { $.post($this.data('ajax'), function () {
clearTimeout(loadingDelay); clearTimeout(loadingDelay);
window.location.reload(); window.location.reload();
}); });
...@@ -371,7 +381,7 @@ ...@@ -371,7 +381,7 @@
$expandable.slideToggle( $expandable.slideToggle(
150, 150,
function() { function () {
if (!$expandable.is(':visible')) { if (!$expandable.is(':visible')) {
$expander.text('More details...'); $expander.text('More details...');
} }
...@@ -382,7 +392,7 @@ ...@@ -382,7 +392,7 @@
$('.js-jobs-list').each(function () { $('.js-jobs-list').each(function () {
var container = this; var container = this;
var selectRow = function(row, isSelected) { var selectRow = function (row, isSelected) {
var $checkbox = $('.js-jobs-list-checkbox', row); var $checkbox = $('.js-jobs-list-checkbox', row);
if ($checkbox.length > 0) { if ($checkbox.length > 0) {
$checkbox.prop('checked', isSelected); $checkbox.prop('checked', isSelected);
...@@ -390,7 +400,7 @@ ...@@ -390,7 +400,7 @@
} }
}; };
var toggleRowSelection = function(row) { var toggleRowSelection = function (row) {
var $checkbox = $('.js-jobs-list-checkbox', row); var $checkbox = $('.js-jobs-list-checkbox', row);
if ($checkbox.length > 0) { if ($checkbox.length > 0) {
var isSelected = $checkbox.is(':checked'); var isSelected = $checkbox.is(':checked');
...@@ -407,8 +417,8 @@ ...@@ -407,8 +417,8 @@
.prop('disabled', state === 'none-selected'); .prop('disabled', state === 'none-selected');
}; };
var updateListState = function() { var updateListState = function () {
var selectedRows = $('.js-jobs-list-checkbox', container).map(function() { var selectedRows = $('.js-jobs-list-checkbox', container).map(function () {
return $(this).prop('checked'); return $(this).prop('checked');
}).get(); }).get();
...@@ -427,7 +437,7 @@ ...@@ -427,7 +437,7 @@
setListState(state); setListState(state);
}; };
$(this).on('click', '.js-jobs-list-checkbox', function(e) { $(this).on('click', '.js-jobs-list-checkbox', function (e) {
selectRow( selectRow(
$(this).closest('.js-jobs-list-row').first(), $(this).closest('.js-jobs-list-row').first(),
$(this).is(':checked')); $(this).is(':checked'));
...@@ -444,21 +454,21 @@ ...@@ -444,21 +454,21 @@
updateListState(); updateListState();
}); });
$(this).on('click', '.js-jobs-list-select-all', function() { $(this).on('click', '.js-jobs-list-select-all', function () {
var selectRows = $(this).is(':checked'); var selectRows = $(this).is(':checked');
$('.js-jobs-list-row', container).each(function() { $('.js-jobs-list-row', container).each(function () {
selectRow(this, selectRows); selectRow(this, selectRows);
}); });
updateListState(); updateListState();
}); });
$(this).on('click', '.js-jobs-list-command', function(e) { $(this).on('click', '.js-jobs-list-command', function (e) {
var $this = $(this); var $this = $(this);
var confirmText = $this.data('confirm'); var confirmText = $this.data('confirm');
var jobs = $("input[name='jobs[]']:checked", container).map(function() { var jobs = $("input[name='jobs[]']:checked", container).map(function () {
return $(this).val(); return $(this).val();
}).get(); }).get();
......
!function(e){var t,n,r,l,o;return o=["object","array","number","string","boolean","null"],r=function(){function t(e){null==e&&(e={}),this.options=e}return t.prototype.htmlEncode=function(e){return null!==e?e.toString().replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):""},t.prototype.jsString=function(e){return e=JSON.stringify(e).slice(1,-1),this.htmlEncode(e)},t.prototype.decorateWithSpan=function(e,t){return'<span class="'+t+'">'+this.htmlEncode(e)+"</span>"},t.prototype.valueToHTML=function(t,n){var r;if(null==n&&(n=0),r=Object.prototype.toString.call(t).match(/\s(.+)]/)[1].toLowerCase(),this.options.strict&&!e.inArray(r,o))throw new Error(""+r+" is not a valid JSON value type");return this[""+r+"ToHTML"].call(this,t,n)},t.prototype.nullToHTML=function(e){return this.decorateWithSpan("null","null")},t.prototype.undefinedToHTML=function(){return this.decorateWithSpan("undefined","undefined")},t.prototype.numberToHTML=function(e){return this.decorateWithSpan(e,"num")},t.prototype.stringToHTML=function(e){var t,n;return/^(http|https|file):\/\/[^\s]+$/i.test(e)?'<a href="'+this.htmlEncode(e)+'"><span class="q">"</span>'+this.jsString(e)+'<span class="q">"</span></a>':(t="",e=this.jsString(e),this.options.nl2br&&(n=/([^>\\r\\n]?)(\\r\\n|\\n\\r|\\r|\\n)/g,n.test(e)&&(t=" multiline",e=(e+"").replace(n,"$1<br />"))),'<span class="string'+t+'">"'+e+'"</span>')},t.prototype.booleanToHTML=function(e){return this.decorateWithSpan(e,"bool")},t.prototype.arrayToHTML=function(e,t){var n,r,l,o,i,s,a,p;for(null==t&&(t=0),r=!1,i="",o=e.length,l=a=0,p=e.length;p>a;l=++a)s=e[l],r=!0,i+="<li>"+this.valueToHTML(s,t+1),o>1&&(i+=","),i+="</li>",o--;return r?(n=0===t?"":" collapsible",'[<ul class="array level'+t+n+'">'+i+"</ul>]"):"[ ]"},t.prototype.objectToHTML=function(e,t){var n,r,l,o,i,s,a;null==t&&(t=0),r=!1,i="",o=0;for(s in e)o++;for(s in e)a=e[s],r=!0,l=this.options.escape?this.jsString(s):s,i+='<li><a class="prop" href="javascript:;"><span class="q">"</span>'+l+'<span class="q">"</span></a>: '+this.valueToHTML(a,t+1),o>1&&(i+=","),i+="</li>",o--;return r?(n=0===t?"":" collapsible",'{<ul class="obj level'+t+n+'">'+i+"</ul>}"):"{ }"},t.prototype.jsonToHTML=function(e){return'<div class="jsonview">'+this.valueToHTML(e)+"</div>"},t}(),"undefined"!=typeof module&&null!==module&&(module.exports=r),n=function(){function e(){}return e.bindEvent=function(e,t){var n;return e.firstChild.addEventListener("click",function(e){return function(n){return e.toggle(n.target.parentNode.firstChild,t)}}(this)),n=document.createElement("div"),n.className="collapser",n.innerHTML=t.collapsed?"+":"-",n.addEventListener("click",function(e){return function(n){return e.toggle(n.target,t)}}(this)),e.insertBefore(n,e.firstChild),t.collapsed?this.collapse(n):void 0},e.expand=function(e){var t,n;return n=this.collapseTarget(e),""!==n.style.display?(t=n.parentNode.getElementsByClassName("ellipsis")[0],n.parentNode.removeChild(t),n.style.display="",e.innerHTML="-"):void 0},e.collapse=function(e){var t,n;return n=this.collapseTarget(e),"none"!==n.style.display?(n.style.display="none",t=document.createElement("span"),t.className="ellipsis",t.innerHTML=" &hellip; ",n.parentNode.insertBefore(t,n),e.innerHTML="+"):void 0},e.toggle=function(e,t){var n,r,l,o,i,s;if(null==t&&(t={}),l=this.collapseTarget(e),n="none"===l.style.display?"expand":"collapse",t.recursive_collapser){for(r=e.parentNode.getElementsByClassName("collapser"),s=[],o=0,i=r.length;i>o;o++)e=r[o],s.push(this[n](e));return s}return this[n](e)},e.collapseTarget=function(e){var t,n;return n=e.parentNode.getElementsByClassName("collapsible"),n.length?t=n[0]:void 0},e}(),t=e,l={collapse:function(e){return"-"===e.innerHTML?n.collapse(e):void 0},expand:function(e){return"+"===e.innerHTML?n.expand(e):void 0},toggle:function(e){return n.toggle(e)}},t.fn.JSONView=function(){var e,o,i,s,a,p,c;return e=arguments,null!=l[e[0]]?(a=e[0],this.each(function(){var n,r;return n=t(this),null!=e[1]?(r=e[1],n.find(".jsonview .collapsible.level"+r).siblings(".collapser").each(function(){return l[a](this)})):n.find(".jsonview > ul > li .collapsible").siblings(".collapser").each(function(){return l[a](this)})})):(s=e[0],p=e[1]||{},o={collapsed:!1,nl2br:!1,recursive_collapser:!1,escape:!0,strict:!1},p=t.extend(o,p),i=new r(p),"[object String]"===Object.prototype.toString.call(s)&&(s=JSON.parse(s)),c=i.jsonToHTML(s),this.each(function(){var e,r,l,o,i,s;for(e=t(this),e.html(c),l=e[0].getElementsByClassName("collapsible"),s=[],o=0,i=l.length;i>o;o++)r=l[o],"LI"===r.parentNode.nodeName?s.push(n.bindEvent(r.parentNode,p)):s.push(void 0);return s}))}}(jQuery);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment