Commit 8a338830 by Dányi Bence

webui: js whitespace fix

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