Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
fc692ce3
authored
Feb 19, 2013
by
Dányi Bence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webui: format js code
parent
eb5ac7c7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
61 deletions
+75
-61
one/static/script/cloud.js
+75
-61
No files found.
one/static/script/cloud.js
View file @
fc692ce3
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
);
...
@@ -10,47 +10,55 @@ $(function() {
...
@@ -10,47 +10,55 @@ $(function() {
}
}
})
})
$
(
'.delete-template-button'
).
click
(
function
(
e
)
{
$
(
'.delete-template-button'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
preventDefault
();
e
.
stopPropagation
();
delete_template_confirm
(
$
(
this
).
data
(
'id'
),
$
(
this
).
data
(
'name'
));
delete_template_confirm
(
$
(
this
).
data
(
'id'
),
$
(
this
).
data
(
'name'
));
});
});
$
(
'.entry .summary'
).
unbind
(
'click'
).
click
(
toggleDetails
);
$
(
'.entry .summary'
).
unbind
(
'click'
).
click
(
toggleDetails
);
if
(
window
.
navigator
.
userAgent
.
indexOf
(
'cloud-gui'
)
>
-
1
)
{
if
(
window
.
navigator
.
userAgent
.
indexOf
(
'cloud-gui'
)
>
-
1
)
{
$
(
'.connect-vm-button'
).
click
(
function
(
e
)
{
$
(
'.connect-vm-button'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
preventDefault
();
e
.
stopPropagation
();
get_vm_details
(
$
(
this
).
data
(
'id'
));
get_vm_details
(
$
(
this
).
data
(
'id'
));
});
});
}
}
else
{
else
{
$
(
'.connect-vm-button'
).
click
(
function
(
e
)
{
$
(
'.connect-vm-button'
).
click
(
function
(
e
)
{
e
.
stopPropagation
();
e
.
stopPropagation
();
});
});
}
}
$
(
'.try-template-button'
).
click
(
function
(
e
)
{
$
(
'.try-template-button'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
preventDefault
();
new_vm
(
$
(
this
).
data
(
'id'
)
);
e
.
stopPropagation
();
new_vm
(
$
(
this
).
data
(
'id'
));
});
});
$
(
'.stop-vm-button'
).
click
(
function
(
e
)
{
$
(
'.stop-vm-button'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
preventDefault
();
e
.
stopPropagation
();
stop_vm
(
$
(
this
).
data
(
'id'
),
$
(
this
).
data
(
'name'
));
stop_vm
(
$
(
this
).
data
(
'id'
),
$
(
this
).
data
(
'name'
));
});
});
$
(
'.resume-vm-button'
).
click
(
function
(
e
)
{
$
(
'.resume-vm-button'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
preventDefault
();
e
.
stopPropagation
();
manage_vm
(
$
(
this
).
data
(
'id'
),
"resume"
);
manage_vm
(
$
(
this
).
data
(
'id'
),
"resume"
);
});
});
$
(
'.delete-vm-button'
).
click
(
function
(
e
)
{
$
(
'.delete-vm-button'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
preventDefault
();
e
.
stopPropagation
();
delete_vm
(
$
(
this
).
data
(
'id'
),
$
(
this
).
data
(
'name'
));
delete_vm
(
$
(
this
).
data
(
'id'
),
$
(
this
).
data
(
'name'
));
});
});
$
(
'.restart-vm-button'
).
click
(
function
(
e
)
{
$
(
'.restart-vm-button'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
preventDefault
();
e
.
stopPropagation
();
restart_vm
(
$
(
this
).
data
(
'id'
),
$
(
this
).
data
(
'name'
));
restart_vm
(
$
(
this
).
data
(
'id'
),
$
(
this
).
data
(
'name'
));
});
});
$
(
'.renew-suspend-vm-button'
).
click
(
function
(
e
)
{
$
(
'.renew-suspend-vm-button'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
preventDefault
();
e
.
stopPropagation
();
renew_suspend_vm
(
$
(
this
).
data
(
'id'
))
renew_suspend_vm
(
$
(
this
).
data
(
'id'
))
});
});
$
(
'.renew-delete-vm-button'
).
click
(
function
(
e
)
{
$
(
'.renew-delete-vm-button'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
preventDefault
();
e
.
stopPropagation
();
renew_delete_vm
(
$
(
this
).
data
(
'id'
))
renew_delete_vm
(
$
(
this
).
data
(
'id'
))
});
});
$
(
'#new-vm-button'
).
click
(
function
()
{
$
(
'#new-vm-button'
).
click
(
function
()
{
...
@@ -69,8 +77,9 @@ $(function() {
...
@@ -69,8 +77,9 @@ $(function() {
$
(
'#modal-container'
).
html
(
''
);
$
(
'#modal-container'
).
html
(
''
);
})
})
$
(
'.template-share'
).
click
(
function
(
e
)
{
$
(
'.template-share'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
preventDefault
();
$
.
get
(
'/ajax/share/'
+
$
(
this
).
data
(
'id'
)
+
'/'
+
$
(
this
).
data
(
'gid'
),
function
(
data
)
{
e
.
stopPropagation
();
$
.
get
(
'/ajax/share/'
+
$
(
this
).
data
(
'id'
)
+
'/'
+
$
(
this
).
data
(
'gid'
),
function
(
data
)
{
$
(
'#modal-container'
).
html
(
data
);
$
(
'#modal-container'
).
html
(
data
);
})
})
$
(
'#modal'
).
show
();
$
(
'#modal'
).
show
();
...
@@ -100,6 +109,7 @@ $(function() {
...
@@ -100,6 +109,7 @@ $(function() {
$
(
'#shadow'
).
click
(
function
()
{
$
(
'#shadow'
).
click
(
function
()
{
$
(
'#new-group-wizard'
).
html
(
content
);
$
(
'#new-group-wizard'
).
html
(
content
);
})
})
function
updateSummary
()
{
function
updateSummary
()
{
$
(
'#new-group-summary-name'
).
html
(
$
(
'#new-group-name'
).
val
());
$
(
'#new-group-summary-name'
).
html
(
$
(
'#new-group-name'
).
val
());
$
(
'#new-group-summary-count'
).
html
(
function
(
text
)
{
$
(
'#new-group-summary-count'
).
html
(
function
(
text
)
{
...
@@ -112,15 +122,15 @@ $(function() {
...
@@ -112,15 +122,15 @@ $(function() {
$
(
'#new-group-semester'
).
change
(
updateSummary
);
$
(
'#new-group-semester'
).
change
(
updateSummary
);
$
(
'#new-group-members'
).
change
(
updateSummary
);
$
(
'#new-group-members'
).
change
(
updateSummary
);
});
});
$
(
'#vm-password-show'
).
click
(
function
(){
$
(
'#vm-password-show'
).
click
(
function
()
{
$
(
'#vm-password-show'
).
hide
();
$
(
'#vm-password-show'
).
hide
();
$
(
'#vm-password'
).
show
();
$
(
'#vm-password'
).
show
();
});
});
$
(
'.hidden-password'
).
each
(
function
(){
$
(
'.hidden-password'
).
each
(
function
()
{
$
(
this
).
val
(
'******'
);
$
(
this
).
val
(
'******'
);
});
});
$
(
'.hidden-password'
).
click
(
function
(){
$
(
'.hidden-password'
).
click
(
function
()
{
if
(
!
$
(
this
).
hasClass
(
'shown'
)){
if
(
!
$
(
this
).
hasClass
(
'shown'
))
{
$
(
this
).
val
(
$
(
this
).
data
(
'value'
));
$
(
this
).
val
(
$
(
this
).
data
(
'value'
));
$
(
this
).
addClass
(
'shown'
);
$
(
this
).
addClass
(
'shown'
);
}
else
{
}
else
{
...
@@ -133,14 +143,15 @@ $(function() {
...
@@ -133,14 +143,15 @@ $(function() {
/**
/**
* Connect button new window
* Connect button new window
*/
*/
function
get_vm_details
(
id
)
{
function
get_vm_details
(
id
)
{
$
.
get
(
'/vm/credentials/'
+
id
,
function
(
data
)
{
$
.
get
(
'/vm/credentials/'
+
id
,
function
(
data
)
{
$
(
'#modal-container'
).
html
(
data
);
$
(
'#modal-container'
).
html
(
data
);
$
(
'.hidden-password'
).
each
(
function
(){
$
(
'.hidden-password'
).
each
(
function
()
{
$
(
this
).
val
(
'******'
);
$
(
this
).
val
(
'******'
);
});
});
$
(
'.hidden-password'
).
click
(
function
(){
$
(
'.hidden-password'
).
click
(
function
()
{
if
(
!
$
(
this
).
hasClass
(
'shown'
)){
if
(
!
$
(
this
).
hasClass
(
'shown'
))
{
$
(
this
).
val
(
$
(
this
).
data
(
'value'
));
$
(
this
).
val
(
$
(
this
).
data
(
'value'
));
$
(
this
).
addClass
(
'shown'
);
$
(
this
).
addClass
(
'shown'
);
}
else
{
}
else
{
...
@@ -171,7 +182,7 @@ $(function() {
...
@@ -171,7 +182,7 @@ $(function() {
*/
*/
function
stop_vm
(
id
,
name
)
{
function
stop_vm
(
id
,
name
)
{
confirm_message
=
interpolate
(
gettext
(
"Are you sure stopping %s?"
),
[
"<strong>"
+
name
+
"</strong>"
])
confirm_message
=
interpolate
(
gettext
(
"Are you sure stopping %s?"
),
[
"<strong>"
+
name
+
"</strong>"
])
vm_confirm_popup
(
confirm_message
,
gettext
(
"Stop"
),
function
()
{
vm_confirm_popup
(
confirm_message
,
gettext
(
"Stop"
),
function
()
{
manage_vm
(
id
,
"stop"
)
manage_vm
(
id
,
"stop"
)
});
});
...
@@ -181,7 +192,7 @@ $(function() {
...
@@ -181,7 +192,7 @@ $(function() {
*/
*/
function
delete_vm
(
id
,
name
)
{
function
delete_vm
(
id
,
name
)
{
confirm_message
=
interpolate
(
gettext
(
"Are you sure deleting %s?"
),
[
"<strong>"
+
name
+
"</strong>"
])
confirm_message
=
interpolate
(
gettext
(
"Are you sure deleting %s?"
),
[
"<strong>"
+
name
+
"</strong>"
])
vm_confirm_popup
(
confirm_message
,
gettext
(
"Delete"
),
function
()
{
vm_confirm_popup
(
confirm_message
,
gettext
(
"Delete"
),
function
()
{
manage_vm
(
id
,
"delete"
)
manage_vm
(
id
,
"delete"
)
})
})
...
@@ -191,7 +202,7 @@ $(function() {
...
@@ -191,7 +202,7 @@ $(function() {
*/
*/
function
restart_vm
(
id
,
name
)
{
function
restart_vm
(
id
,
name
)
{
confirm_message
=
interpolate
(
gettext
(
"Are you sure restarting %s?"
),
[
"<strong>"
+
name
+
"</strong>"
])
confirm_message
=
interpolate
(
gettext
(
"Are you sure restarting %s?"
),
[
"<strong>"
+
name
+
"</strong>"
])
vm_confirm_popup
(
confirm_message
,
gettext
(
"Restart"
),
function
()
{
vm_confirm_popup
(
confirm_message
,
gettext
(
"Restart"
),
function
()
{
manage_vm
(
id
,
"restart"
)
manage_vm
(
id
,
"restart"
)
})
})
...
@@ -226,10 +237,9 @@ $(function() {
...
@@ -226,10 +237,9 @@ $(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
();
}
}
}
}
...
@@ -238,6 +248,7 @@ $(function() {
...
@@ -238,6 +248,7 @@ $(function() {
/**
/**
* New VM
* New VM
*/
*/
function
new_vm
(
template_id
)
{
function
new_vm
(
template_id
)
{
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
...
@@ -245,7 +256,6 @@ $(function() {
...
@@ -245,7 +256,6 @@ $(function() {
success
:
function
(
data
,
b
,
xhrRequest
)
{
success
:
function
(
data
,
b
,
xhrRequest
)
{
window
.
location
.
href
=
'/'
;
//xhrRequest.getResponseHeader("Location");
window
.
location
.
href
=
'/'
;
//xhrRequest.getResponseHeader("Location");
//alert(xhrRequest.getResponseHeader("Location"));
//alert(xhrRequest.getResponseHeader("Location"));
window
.
location
.
href
=
xhrRequest
.
getResponseHeader
(
"Location"
);
window
.
location
.
href
=
xhrRequest
.
getResponseHeader
(
"Location"
);
}
}
})
})
...
@@ -254,8 +264,9 @@ $(function() {
...
@@ -254,8 +264,9 @@ $(function() {
/**
/**
* Template delete
* Template delete
*/
*/
function
delete_template_confirm
(
id
,
name
)
{
function
delete_template_confirm
(
id
,
name
)
{
confirm_message
=
interpolate
(
gettext
(
"Are you sure deleting this %s template?"
),
[
"<strong>"
+
name
+
"</strong>"
])
confirm_message
=
interpolate
(
gettext
(
"Are you sure deleting this %s template?"
),
[
"<strong>"
+
name
+
"</strong>"
])
vm_confirm_popup
(
confirm_message
,
gettext
(
"Delete"
),
function
()
{
vm_confirm_popup
(
confirm_message
,
gettext
(
"Delete"
),
function
()
{
delete_template
(
id
)
delete_template
(
id
)
})
})
...
@@ -263,6 +274,7 @@ $(function() {
...
@@ -263,6 +274,7 @@ $(function() {
/**
/**
* Template delete
* Template delete
*/
*/
function
delete_template
(
id
)
{
function
delete_template
(
id
)
{
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
...
@@ -274,64 +286,66 @@ $(function() {
...
@@ -274,64 +286,66 @@ $(function() {
alert
(
data
[
'responseText'
]);
alert
(
data
[
'responseText'
]);
},
},
200
:
function
(
data
)
{
200
:
function
(
data
)
{
$
(
"#t"
+
id
).
remove
()
$
(
"#t"
+
id
).
remove
()
},
},
}
}
})
})
}
}
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
;
window
.
localStorage
.
setItem
(
'hidden_groups'
,
JSON
.
stringify
(
hidden_groups
));
window
.
localStorage
.
setItem
(
'hidden_groups'
,
JSON
.
stringify
(
hidden_groups
));
$
(
'#group-'
+
id
).
slideUp
(
700
);
$
(
'#group-'
+
id
).
slideUp
(
700
);
}
}
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
();
}
}
}
}
function
show_hidden_groups
(){
function
show_hidden_groups
()
{
var
hidden_groups
=
JSON
.
parse
(
window
.
localStorage
.
getItem
(
'hidden_groups'
))
||
{};
var
hidden_groups
=
JSON
.
parse
(
window
.
localStorage
.
getItem
(
'hidden_groups'
))
||
{};
hidden_groups
[
current_user
]
=
[];
hidden_groups
[
current_user
]
=
[];
window
.
localStorage
.
setItem
(
'hidden_groups'
,
JSON
.
stringify
(
hidden_groups
));
window
.
localStorage
.
setItem
(
'hidden_groups'
,
JSON
.
stringify
(
hidden_groups
));
}
}
hide_groups
();
hide_groups
();
function
hidden_group_count
(){
function
hidden_group_count
()
{
var
hidden_groups
=
JSON
.
parse
(
window
.
localStorage
.
getItem
(
'hidden_groups'
))
||
{};
var
hidden_groups
=
JSON
.
parse
(
window
.
localStorage
.
getItem
(
'hidden_groups'
))
||
{};
return
(
hidden_groups
[
current_user
]
||
[]).
length
;
return
(
hidden_groups
[
current_user
]
||
[]).
length
;
}
}
if
(
hidden_group_count
()
==
0
){
if
(
hidden_group_count
()
==
0
)
{
$
(
'#show-hidden-groups'
).
hide
();
$
(
'#show-hidden-groups'
).
hide
();
}
}
$
(
'.hide-group'
).
click
(
function
(
e
){
$
(
'.hide-group'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
preventDefault
();
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
;
});
});
$
(
'#show-hidden-groups'
).
click
(
function
(
e
){
$
(
'#show-hidden-groups'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
preventDefault
();
e
.
stopPropagation
();
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
);
}
}
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment