Commit 8a338830 by Dányi Bence

webui: js whitespace fix

parent 503aeb70
var toggleDetails; var toggleDetails;
$(function() { $(function() {
toggleDetails = cloud.throttle(function() { toggleDetails = cloud.throttle(function() {
if($(this).parent('.entry').hasClass('opened')) { if ($(this).parent('.entry').hasClass('opened')) {
$(this).parent('.entry').removeClass('opened'); $(this).parent('.entry').removeClass('opened');
$(this).next('.details').slideUp(700); $(this).next('.details').slideUp(700);
} else { } else {
...@@ -9,7 +9,7 @@ $(function() { ...@@ -9,7 +9,7 @@ $(function() {
$(this).next('.details').slideDown(700); $(this).next('.details').slideDown(700);
} }
}) })
$('a').click(function(e){ $('a').click(function(e) {
e.stopPropagation(); e.stopPropagation();
}); });
$('.delete-template').click(function(e) { $('.delete-template').click(function(e) {
...@@ -32,19 +32,19 @@ $(function() { ...@@ -32,19 +32,19 @@ $(function() {
}); });
}); });
}); });
$('#reset-key').click(function(e){ $('#reset-key').click(function(e) {
vm_confirm_popup(gettext('Are you sure about reseting store credentials?<br /> You will lose your access to your store account on your existing virtual machines!'), gettext('Reset'), function(){ vm_confirm_popup(gettext('Are you sure about reseting store credentials?<br /> You will lose your access to your store account on your existing virtual machines!'), gettext('Reset'), function() {
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: '/ajax/key/reset/', url: '/ajax/key/reset/',
success: function(){ success: function() {
window.location.reload(); window.location.reload();
} }
}) })
}); });
}); });
$('.entry .summary').click(toggleDetails); $('.entry .summary').click(toggleDetails);
if(window.navigator.userAgent.indexOf('cloud-gui') < 0) { if (window.navigator.userAgent.indexOf('cloud-gui') < 0) {
$('.connect-vm').click(function(e) { $('.connect-vm').click(function(e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
...@@ -141,7 +141,7 @@ $(function() { ...@@ -141,7 +141,7 @@ $(function() {
}) })
$('#modal').show(); $('#modal').show();
}); });
$('.template-unshare').click(function(e){ $('.template-unshare').click(function(e) {
e.stopPropagation(); e.stopPropagation();
}); });
$('#old-upload').click(function(e) { $('#old-upload').click(function(e) {
...@@ -154,7 +154,7 @@ $(function() { ...@@ -154,7 +154,7 @@ $(function() {
$(this).css('backgroundColor', function(w) { $(this).css('backgroundColor', function(w) {
return 'hsla(' + (120 - parseFloat(w) / 100 * 120).toFixed(0) + ', 100%, 50%, 0.2)'; return 'hsla(' + (120 - parseFloat(w) / 100 * 120).toFixed(0) + ', 100%, 50%, 0.2)';
}($(this)[0].style.width)); }($(this)[0].style.width));
if(parseInt($(this).css('width')) > 0) $(this).css('borderRight', function(w) { if (parseInt($(this).css('width')) > 0) $(this).css('borderRight', function(w) {
return '1px solid hsla(' + (120 - parseFloat(w) / 100 * 120).toFixed(0) + ', 100%, 30%, 0.4)'; return '1px solid hsla(' + (120 - parseFloat(w) / 100 * 120).toFixed(0) + ', 100%, 30%, 0.4)';
}($(this)[0].style.width)); }($(this)[0].style.width));
}); });
...@@ -183,20 +183,21 @@ $(function() { ...@@ -183,20 +183,21 @@ $(function() {
$('#new-group-members').change(updateSummary); $('#new-group-members').change(updateSummary);
}); });
$('.hidden-password').click(function() { $('.hidden-password').click(function() {
if($(this).attr('type') == 'password'){ if ($(this).attr('type') == 'password') {
$(this).attr('type', 'text'); $(this).attr('type', 'text');
$(this).addClass('shown'); $(this).addClass('shown');
} else if(this.selectionStart-this.selectionEnd == 0) { } else if (this.selectionStart - this.selectionEnd == 0) {
$(this).attr('type', 'password'); $(this).attr('type', 'password');
$(this).removeClass('shown'); $(this).removeClass('shown');
} }
}); });
$('.shares li').click(function(e){ $('.shares li').click(function(e) {
e.preventDefault(); e.stopPropagation(); e.preventDefault();
e=$(this); e.stopPropagation();
if(!e.hasClass('description')){ e = $(this);
if(e.next().is(':hidden')){ if (!e.hasClass('description')) {
if (e.next().is(':hidden')) {
e.next().slideDown(700); e.next().slideDown(700);
} else { } else {
e.next().slideUp(700); e.next().slideUp(700);
...@@ -205,12 +206,13 @@ $(function() { ...@@ -205,12 +206,13 @@ $(function() {
e.slideUp(700); e.slideUp(700);
} }
}); });
$('.shares .edit').click(function(e){ $('.shares .edit').click(function(e) {
e.preventDefault(); e.stopPropagation(); e.preventDefault();
e.stopPropagation();
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: '/ajax/shareEdit/'+$(this).data('id')+'/', url: '/ajax/shareEdit/' + $(this).data('id') + '/',
success: function(data){ success: function(data) {
$('#modal').show(); $('#modal').show();
$('#modal-container').html(data); $('#modal-container').html(data);
} }
...@@ -225,7 +227,7 @@ $(function() { ...@@ -225,7 +227,7 @@ $(function() {
$.get('/vm/credentials/' + id, function(data) { $.get('/vm/credentials/' + id, function(data) {
$('#modal-container').html(data); $('#modal-container').html(data);
$('#modal-container .hidden-password').click(function() { $('#modal-container .hidden-password').click(function() {
if($(this).attr('type') == 'password'){ if ($(this).attr('type') == 'password') {
$(this).attr('type', 'text'); $(this).attr('type', 'text');
$(this).addClass('shown'); $(this).addClass('shown');
} else { } else {
...@@ -311,7 +313,7 @@ $(function() { ...@@ -311,7 +313,7 @@ $(function() {
type: 'POST', type: 'POST',
url: '/vm/' + state + '/' + id + '/', url: '/vm/' + state + '/' + id + '/',
success: function(data, b, c) { success: function(data, b, c) {
if(state == "resume") { if (state == "resume") {
window.location.href = '/vm/show/' + id + "/"; window.location.href = '/vm/show/' + id + "/";
} else { } else {
window.location.reload(); window.location.reload();
...@@ -370,9 +372,9 @@ $(function() { ...@@ -370,9 +372,9 @@ $(function() {
function hide_group(id) { function hide_group(id) {
var hidden_groups = JSON.parse(window.localStorage.getItem('hidden_groups')) || {}; var hidden_groups = JSON.parse(window.localStorage.getItem('hidden_groups')) || {};
var hidden_groups_for_user = hidden_groups[current_user] || []; var hidden_groups_for_user = hidden_groups[current_user] || [];
for(var i in hidden_groups_for_user) { for (var i in hidden_groups_for_user) {
var hide = hidden_groups_for_user[i]; var hide = hidden_groups_for_user[i];
if(hide == id) return false; if (hide == id) return false;
} }
hidden_groups_for_user.push(id); hidden_groups_for_user.push(id);
hidden_groups[current_user] = hidden_groups_for_user; hidden_groups[current_user] = hidden_groups_for_user;
...@@ -383,7 +385,7 @@ $(function() { ...@@ -383,7 +385,7 @@ $(function() {
function hide_groups() { function hide_groups() {
var hidden_groups = JSON.parse(window.localStorage.getItem('hidden_groups')) || {}; var hidden_groups = JSON.parse(window.localStorage.getItem('hidden_groups')) || {};
var hidden_groups_for_user = hidden_groups[current_user] || []; var hidden_groups_for_user = hidden_groups[current_user] || [];
for(var i in hidden_groups_for_user) { for (var i in hidden_groups_for_user) {
var hide = hidden_groups_for_user[i]; var hide = hidden_groups_for_user[i];
$('#group-' + hide).hide(); $('#group-' + hide).hide();
} }
...@@ -408,7 +410,7 @@ $(function() { ...@@ -408,7 +410,7 @@ $(function() {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
hide_group($(this).data('id')); hide_group($(this).data('id'));
if($('#show-hidden-groups').is(':hidden')) { if ($('#show-hidden-groups').is(':hidden')) {
$('#show-hidden-groups').slideDown(700); $('#show-hidden-groups').slideDown(700);
} }
return false; return false;
...@@ -419,7 +421,7 @@ $(function() { ...@@ -419,7 +421,7 @@ $(function() {
show_hidden_groups(); show_hidden_groups();
$('#show-hidden-groups').slideUp(700); $('#show-hidden-groups').slideUp(700);
$('#groups > li').each(function() { $('#groups > li').each(function() {
if($(this).is(':hidden')) { if ($(this).is(':hidden')) {
$(this).slideDown(700); $(this).slideDown(700);
} }
}) })
...@@ -454,46 +456,38 @@ $(function() { ...@@ -454,46 +456,38 @@ $(function() {
}); });
$('#new-owner-form input').keyup(function() { $('#new-owner-form input').keyup(function() {
var timer; var timer;
return function(e){ return function(e) {
var val=$(this).val().split(' ')[0]; var val = $(this).val().split(' ')[0];
clearTimeout(timer); clearTimeout(timer);
timer=setTimeout(function(){ timer = setTimeout(function() {
if(val.length<1) return; if (val.length < 1) return;
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
data: 'q='+val, data: 'q=' + val,
url: '/ajax/group/autocomplete/', url: '/ajax/group/autocomplete/',
dataType: 'json', dataType: 'json',
success: function(data){ success: function(data) {
console.log(data); console.log(data);
$('#new-owner-autocomplete')[0].innerHTML='<ul>'; $('#new-owner-autocomplete')[0].innerHTML = '<ul>';
var el=$('#new-owner-autocomplete')[0]; var el = $('#new-owner-autocomplete')[0];
for(var i in data){ for (var i in data) {
var d=data[i]; var d = data[i];
el.innerHTML+='<li>' el.innerHTML += '<li>' + d.name + ': ' + d.neptun + ' <input type="button" value="' + gettext('Add owner') + '" data-neptun="' + d.neptun + '" />' + '<div class="clear"></div></li>';
+d.name+': '
+d.neptun
+' <input type="button" value="'+gettext('Add owner')+'" data-neptun="'+d.neptun+'" />'
+'<div class="clear"></div></li>';
} }
if(data.length == 0){ if (data.length == 0) {
el.innerHTML+='<li>' el.innerHTML += '<li>' + gettext('Unknown') + ': ' + val + ' <input type="button" value="' + gettext('Add owner') + '" data-neptun="' + val + '" />' + '<div class="clear"></div></li>';
+gettext('Unknown')+': '
+val
+' <input type="button" value="'+gettext('Add owner')+'" data-neptun="'+val+'" />'
+'<div class="clear"></div></li>';
} }
el.innerHTML+='</ul>'; el.innerHTML += '</ul>';
$(el).find('input').each(function(){ $(el).find('input').each(function() {
var self=this; var self = this;
$(this).click(function(e){ $(this).click(function(e) {
e.stopPropagation(); e.stopPropagation();
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
data: 'neptun='+$(self).data('neptun'), data: 'neptun=' + $(self).data('neptun'),
url: '/ajax/group/'+$('#new-owner').data('gid')+'/addOwner/', url: '/ajax/group/' + $('#new-owner').data('gid') + '/addOwner/',
dataType: 'json', dataType: 'json',
success: function(data){ success: function(data) {
window.location.reload(); window.location.reload();
} }
}) })
...@@ -501,7 +495,7 @@ $(function() { ...@@ -501,7 +495,7 @@ $(function() {
}) })
} }
}); });
},1000); }, 1000);
e.stopPropagation(); e.stopPropagation();
} }
}()); }());
......
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