Commit f47965c1 by Kálmán Viktor

dashboard: fix jshint warnings

parent ebdf3b7e
...@@ -137,16 +137,16 @@ $(function() { ...@@ -137,16 +137,16 @@ $(function() {
} }
var vm_state = $("#vm-details-state"); var vm_state = $("#vm-details-state");
if (vm_state.length) { if (vm_state.length) {
vm_state.data("status", data['status']); vm_state.data("status", data['status']); // jshint ignore:line
$("#vm-details-state span").html(data['human_readable_status'].toUpperCase()); $("#vm-details-state span").html(data.human_readable_status.toUpperCase());
} }
if(data['status'] == "RUNNING") { if(data['status'] == "RUNNING") { // jshint ignore:line
if(data['connect_uri']) { if(data.connect_uri) {
$("#dashboard-vm-details-connect-button").removeClass('disabled'); $("#dashboard-vm-details-connect-button").removeClass('disabled');
} }
$("[data-target=#_console]").attr("data-toggle", "pill").attr("href", "#console").parent("li").removeClass("disabled"); $("[data-target=#_console]").attr("data-toggle", "pill").attr("href", "#console").parent("li").removeClass("disabled");
} else { } else {
if(data['connect_uri']) { if(data.connect_uri) {
$("#dashboard-vm-details-connect-button").addClass('disabled'); $("#dashboard-vm-details-connect-button").addClass('disabled');
} }
$("[data-target=#_console]").attr("data-toggle", "_pill").attr("href", "#").parent("li").addClass("disabled"); $("[data-target=#_console]").attr("data-toggle", "_pill").attr("href", "#").parent("li").addClass("disabled");
...@@ -181,7 +181,7 @@ $(function() { ...@@ -181,7 +181,7 @@ $(function() {
String.prototype.hashCode = function() { String.prototype.hashCode = function() {
var hash = 0, i, chr, len; var hash = 0, i, chr, len;
if (this.length == 0) return hash; if (this.length === 0) return hash;
for (i = 0, len = this.length; i < len; i++) { for (i = 0, len = this.length; i < len; i++) {
chr = this.charCodeAt(i); chr = this.charCodeAt(i);
hash = ((hash << 5) - hash) + chr; hash = ((hash << 5) - hash) + chr;
......
...@@ -44,7 +44,7 @@ $(function () { ...@@ -44,7 +44,7 @@ $(function () {
if(xhr.status === 403) { if(xhr.status === 403) {
addMessage(gettext("Only the owners can delete the selected object."), "warning"); addMessage(gettext("Only the owners can delete the selected object."), "warning");
} else { } else {
addMessage(gettext("An error occurred. (") + xhr.status + ")", 'danger') addMessage(gettext("An error occurred. (") + xhr.status + ")", 'danger');
} }
} }
}); });
...@@ -189,8 +189,8 @@ $(function () { ...@@ -189,8 +189,8 @@ $(function () {
} }
} }
search_result.sort(compareVmByFav); search_result.sort(compareVmByFav);
for(var i=0; i<5 && i<search_result.length; i++) for(i=0; i<5 && i<search_result.length; i++)
html += generateVmHTML(search_result[i].pk, search_result[i].name, html += generateVmHTML(search_result[i].pk, search_result[i].name,
search_result[i].owner ? search_result[i].owner : search_result[i].host, search_result[i].icon, search_result[i].owner ? search_result[i].owner : search_result[i].host, search_result[i].icon,
search_result[i].status, search_result[i].fav, search_result[i].status, search_result[i].fav,
(search_result.length < 5)); (search_result.length < 5));
...@@ -513,19 +513,19 @@ function addModalConfirmation(func, data) { ...@@ -513,19 +513,19 @@ function addModalConfirmation(func, data) {
}); });
} }
function clientInstalledAction(location) { function clientInstalledAction(location) {
setCookie('downloaded_client', true, 365 * 24 * 60 * 60 * 1000, "/"); setCookie('downloaded_client', true, 365 * 24 * 60 * 60 * 1000, "/");
window.location.href = location; window.location.href = location;
$('#confirmation-modal').modal("hide"); $('#confirmation-modal').modal("hide");
} }
function setCookie(name, value, seconds, path) { function setCookie(name, value, seconds, path) {
if (seconds!=null) { if (seconds !== null) {
var today = new Date(); var today = new Date();
var expire = new Date(); var expire = new Date();
expire.setTime(today.getTime() + seconds); expire.setTime(today.getTime() + seconds);
document.cookie = name+"="+escape(value)+"; expires="+expire.toUTCString()+"; path="+path;
} }
document.cookie = name+"="+escape(value)+"; expires="+expire.toUTCString()+"; path="+path;
} }
/* no js compatibility */ /* no js compatibility */
...@@ -539,7 +539,7 @@ function getParameterByName(name) { ...@@ -539,7 +539,7 @@ function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search); results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
} }
// for AJAX calls // for AJAX calls
...@@ -581,7 +581,7 @@ $.ajaxSetup({ ...@@ -581,7 +581,7 @@ $.ajaxSetup({
$(function() { $(function() {
yourlabs.TextWidget.prototype.getValue = function(choice) { yourlabs.TextWidget.prototype.getValue = function(choice) {
return choice.children().html(); return choice.children().html();
} };
}); });
var tagsToReplace = { var tagsToReplace = {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
data: {'new_name': name}, data: {'new_name': name},
headers: {"X-CSRFToken": getCookie('csrftoken')}, headers: {"X-CSRFToken": getCookie('csrftoken')},
success: function(data, textStatus, xhr) { success: function(data, textStatus, xhr) {
$("#group-details-h1-name").text(data['new_name']).show(); $("#group-details-h1-name").text(data.new_name).show();
$('#group-details-rename').hide(); $('#group-details-rename').hide();
// addMessage(data['message'], "success"); // addMessage(data['message'], "success");
}, },
......
...@@ -15,7 +15,7 @@ $(function() { ...@@ -15,7 +15,7 @@ $(function() {
data: {'new_name': name}, data: {'new_name': name},
headers: {"X-CSRFToken": getCookie('csrftoken')}, headers: {"X-CSRFToken": getCookie('csrftoken')},
success: function(data, textStatus, xhr) { success: function(data, textStatus, xhr) {
$("#node-details-h1-name").text(data['new_name']).show(); $("#node-details-h1-name").text(data.new_name).show();
$('#node-details-rename').hide(); $('#node-details-rename').hide();
// addMessage(data.message, "success"); // addMessage(data.message, "success");
}, },
......
...@@ -70,8 +70,8 @@ $(function() { ...@@ -70,8 +70,8 @@ $(function() {
var input = $(this).parent("div").children("input"); var input = $(this).parent("div").children("input");
var eye = $(this).children("#vm-details-pw-eye"); var eye = $(this).children("#vm-details-pw-eye");
var span = $(this); var span = $(this);
span.tooltip("destroy") span.tooltip("destroy");
if(eye.hasClass("fa-eye")) { if(eye.hasClass("fa-eye")) {
eye.removeClass("fa-eye").addClass("fa-eye-slash"); eye.removeClass("fa-eye").addClass("fa-eye-slash");
input.prop("type", "text"); input.prop("type", "text");
...@@ -132,7 +132,7 @@ $(function() { ...@@ -132,7 +132,7 @@ $(function() {
var tmp = ta.val(); var tmp = ta.val();
ta.val(""); ta.val("");
ta.focus(); ta.focus();
ta.val(tmp) ta.val(tmp);
e.preventDefault(); e.preventDefault();
}); });
...@@ -207,7 +207,7 @@ $(function() { ...@@ -207,7 +207,7 @@ $(function() {
$("#dashboard-tutorial-toggle").click(function() { $("#dashboard-tutorial-toggle").click(function() {
var box = $("#alert-new-template"); var box = $("#alert-new-template");
var list = box.find("ol") var list = box.find("ol");
list.stop().slideToggle(function() { list.stop().slideToggle(function() {
var url = box.find("form").prop("action"); var url = box.find("form").prop("action");
var hidden = list.css("display") === "none"; var hidden = list.css("display") === "none";
...@@ -219,7 +219,7 @@ $(function() { ...@@ -219,7 +219,7 @@ $(function() {
headers: {"X-CSRFToken": getCookie('csrftoken')}, headers: {"X-CSRFToken": getCookie('csrftoken')},
success: function(re, textStatus, xhr) {} success: function(re, textStatus, xhr) {}
}); });
}); });
return false; return false;
}); });
......
...@@ -82,7 +82,7 @@ $(function() { ...@@ -82,7 +82,7 @@ $(function() {
/* mass operations */ /* mass operations */
$("#vm-mass-ops").on('click', '.mass-operation', function(e) { $("#vm-mass-ops").on('click', '.mass-operation', function(e) {
var icon = $(this).children("i").addClass('fa-spinner fa-spin'); var icon = $(this).children("i").addClass('fa-spinner fa-spin');
params = "?" + selected.map(function(a){return "vm=" + a.vm}).join("&"); params = "?" + selected.map(function(a){return "vm=" + a.vm;}).join("&");
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
...@@ -212,7 +212,7 @@ function updateStatuses(runs) { ...@@ -212,7 +212,7 @@ function updateStatuses(runs) {
if(checkStatusUpdate()) { if(checkStatusUpdate()) {
setTimeout( setTimeout(
function() {updateStatuses(runs + 1)}, function() {updateStatuses(runs + 1);},
1000 + Math.exp(runs * 0.05) 1000 + Math.exp(runs * 0.05)
); );
} }
......
/**
* bootbox.js v4.0.0
*
* http://bootboxjs.com/license.txt
*/
window.bootbox=window.bootbox||function a(b,c){"use strict";function d(a){var b=s[q.locale];return b?b[a]:s.en[a]}function e(a,c,d){a.preventDefault();var e=b.isFunction(d)&&d(a)===!1;e||c.modal("hide")}function f(a){var b,c=0;for(b in a)c++;return c}function g(a,c){var d=0;b.each(a,function(a,b){c(a,b,d++)})}function h(a){var c,d;if("object"!=typeof a)throw new Error("Please supply an object of options");if(!a.message)throw new Error("Please specify a message");return a=b.extend({},q,a),a.buttons||(a.buttons={}),a.backdrop=a.backdrop?"static":!1,c=a.buttons,d=f(c),g(c,function(a,e,f){if(b.isFunction(e)&&(e=c[a]={callback:e}),"object"!==b.type(e))throw new Error("button with key "+a+" must be an object");e.label||(e.label=a),e.className||(e.className=2>=d&&f===d-1?"btn-primary":"btn-default")}),a}function i(a,b){var c=a.length,d={};if(1>c||c>2)throw new Error("Invalid argument length");return 2===c||"string"==typeof a[0]?(d[b[0]]=a[0],d[b[1]]=a[1]):d=a[0],d}function j(a,c,d){return b.extend(!0,{},a,i(c,d))}function k(a,b,c){return n(j(m.apply(null,a),b,c),a)}function l(){for(var a={},b=0,c=arguments.length;c>b;b++){var e=arguments[b],f=e.toLowerCase(),g=e.toUpperCase();a[f]={label:d(g)}}return a}function m(){return{buttons:l.apply(null,arguments)}}function n(a,b){var d={};return g(b,function(a,b){d[b]=!0}),g(a.buttons,function(a){if(d[a]===c)throw new Error("button key "+a+" is not allowed (options are "+b.join("\n")+")")}),a}var o={dialog:"<div class='bootbox modal' tabindex='-1' role='dialog'><div class='modal-dialog'><div class='modal-content'><div class='modal-body'><div class='bootbox-body'></div></div></div></div></div>",header:"<div class='modal-header'><h4 class='modal-title'></h4></div>",footer:"<div class='modal-footer'></div>",closeButton:"<button type='button' class='bootbox-close-button close'>&times;</button>",form:"<form class='bootbox-form'></form>",inputs:{text:"<input class='bootbox-input form-control' autocomplete=off type=text />"}},p=b("body"),q={locale:"en",backdrop:!0,animate:!0,className:null,closeButton:!0,show:!0},r={};r.alert=function(){var a;if(a=k(["ok"],arguments,["message","callback"]),a.callback&&!b.isFunction(a.callback))throw new Error("alert requires callback property to be a function when provided");return a.buttons.ok.callback=a.onEscape=function(){return b.isFunction(a.callback)?a.callback():!0},r.dialog(a)},r.confirm=function(){var a;if(a=k(["cancel","confirm"],arguments,["message","callback"]),a.buttons.cancel.callback=a.onEscape=function(){return a.callback(!1)},a.buttons.confirm.callback=function(){return a.callback(!0)},!b.isFunction(a.callback))throw new Error("confirm requires a callback");return r.dialog(a)},r.prompt=function(){var a,d,e,f,g,h;if(f=b(o.form),d={buttons:l("cancel","confirm"),value:""},a=n(j(d,arguments,["title","callback"]),["cancel","confirm"]),h=a.show===c?!0:a.show,a.message=f,a.buttons.cancel.callback=a.onEscape=function(){return a.callback(null)},a.buttons.confirm.callback=function(){return a.callback(g.val())},a.show=!1,!a.title)throw new Error("prompt requires a title");if(!b.isFunction(a.callback))throw new Error("prompt requires a callback");return g=b(o.inputs.text),g.val(a.value),f.append(g),f.on("submit",function(a){a.preventDefault(),e.find(".btn-primary").click()}),e=r.dialog(a),e.off("shown.bs.modal"),e.on("shown.bs.modal",function(){g.focus()}),h===!0&&e.modal("show"),e},r.dialog=function(a){a=h(a);var c=b(o.dialog),d=c.find(".modal-body"),f=a.buttons,i="",j={onEscape:a.onEscape};if(g(f,function(a,b){i+="<button data-bb-handler='"+a+"' type='button' class='btn "+b.className+"'>"+b.label+"</button>",j[a]=b.callback}),d.find(".bootbox-body").html(a.message),a.animate===!0&&c.addClass("fade"),a.className&&c.addClass(a.className),a.title&&d.before(o.header),a.closeButton){var k=b(o.closeButton);a.title?c.find(".modal-header").prepend(k):k.css("margin-top","-10px").prependTo(d)}return a.title&&c.find(".modal-title").html(a.title),i.length&&(d.after(o.footer),c.find(".modal-footer").html(i)),c.on("hidden.bs.modal",function(a){a.target===this&&c.remove()}),c.on("shown.bs.modal",function(){c.find(".btn-primary:first").focus()}),c.on("escape.close.bb",function(a){j.onEscape&&e(a,c,j.onEscape)}),c.on("click",".modal-footer button",function(a){var d=b(this).data("bb-handler");e(a,c,j[d])}),c.on("click",".bootbox-close-button",function(a){e(a,c,j.onEscape)}),c.on("keyup",function(a){27===a.which&&c.trigger("escape.close.bb")}),p.append(c),c.modal({backdrop:a.backdrop,keyboard:!1,show:!1}),a.show&&c.modal("show"),c},r.setDefaults=function(a){b.extend(q,a)},r.hideAll=function(){b(".bootbox").modal("hide")};var s={br:{OK:"OK",CANCEL:"Cancelar",CONFIRM:"Sim"},da:{OK:"OK",CANCEL:"Annuller",CONFIRM:"Accepter"},de:{OK:"OK",CANCEL:"Abbrechen",CONFIRM:"Akzeptieren"},en:{OK:"OK",CANCEL:"Cancel",CONFIRM:"OK"},es:{OK:"OK",CANCEL:"Cancelar",CONFIRM:"Aceptar"},fi:{OK:"OK",CANCEL:"Peruuta",CONFIRM:"OK"},fr:{OK:"OK",CANCEL:"Annuler",CONFIRM:"D'accord"},it:{OK:"OK",CANCEL:"Annulla",CONFIRM:"Conferma"},nl:{OK:"OK",CANCEL:"Annuleren",CONFIRM:"Accepteren"},pl:{OK:"OK",CANCEL:"Anuluj",CONFIRM:"Potwierdź"},ru:{OK:"OK",CANCEL:"Отмена",CONFIRM:"Применить"},zh_CN:{OK:"OK",CANCEL:"取消",CONFIRM:"确认"},zh_TW:{OK:"OK",CANCEL:"取消",CONFIRM:"確認"}};return r.init=function(c){window.bootbox=a(c||b)},r}(window.jQuery);
\ No newline at end of file
...@@ -3,7 +3,7 @@ $('#small_rule_table i[class="fa fa-times"]').click(function() { ...@@ -3,7 +3,7 @@ $('#small_rule_table i[class="fa fa-times"]').click(function() {
csrf = getCookie('csrftoken'); csrf = getCookie('csrftoken');
var click_this = this; var click_this = this;
host = $('.page-header').children('h2').text() host = $('.page-header').children('h2').text();
group = $(this).closest('h4').text(); group = $(this).closest('h4').text();
if(group.length > 0) { if(group.length > 0) {
...@@ -47,13 +47,13 @@ function delete_rule_or_group(click_this) { ...@@ -47,13 +47,13 @@ function delete_rule_or_group(click_this) {
$(this).closest('tr').fadeOut(500, function() { $(this).closest('tr').fadeOut(500, function() {
$(this).remove(); $(this).remove();
}); });
} }
// we delete the whole div around the table // we delete the whole div around the table
else { else {
// we need to readd the deleted group to the select // we need to readd the deleted group to the select
group_pk = parseInt($(this).closest('h4').attr('id')); group_pk = parseInt($(this).closest('h4').attr('id'));
group_name = $(this).closest('h4').text(); group_name = $(this).closest('h4').text();
$(this).closest('div').fadeOut(500, function() { $(this).closest('div').fadeOut(500, function() {
$(this).remove(); $(this).remove();
$('#add_group') $('#add_group')
......
// for AJAX calls // for AJAX calls
/** /**
* Getter for user cookies * Getter for user cookies
* @param {String} name Cookie name * @param {String} name Cookie name
* @return {String} Cookie value * @return {String} Cookie value
*/ */
function getCookie(name) { function getCookie(name) {
var cookieValue = null; var cookieValue = null;
if (document.cookie && document.cookie != '') { if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';'); var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) { for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]); var cookie = jQuery.trim(cookies[i]);
if (cookie.substring(0, name.length + 1) == (name + '=')) { if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break; break;
} }
} }
} }
return cookieValue; return cookieValue;
} }
function getURLParameter(name) { function getURLParameter(name) {
...@@ -34,7 +34,7 @@ function doBlink(id, count) { ...@@ -34,7 +34,7 @@ function doBlink(id, count) {
$(this).delay(200).queue(function() { $(this).delay(200).queue(function() {
$(this).removeClass("has-warning").dequeue(); $(this).removeClass("has-warning").dequeue();
doBlink(id, count-1);}); doBlink(id, count-1);});
$(this).addClass("has-warning").dequeue() $(this).addClass("has-warning").dequeue();
}); });
} }
} }
......
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 sign in to comment