2 $("document").ready( function () {
4 $( "body" ).on( "click", "button.command-button", function () {
7 command
= btn
.attr( "data-command" ),
8 href
= _site_domain
+ _index_page
+ "/ajax/command/",
12 if ( command
.match( /ENABLE/ ) ) {
13 toggle
= command
.replace( "ENABLE", "DISABLE" );
14 } else if ( command
.match( /DISABLE/ ) ) {
15 toggle
= command
.replace( "DISABLE", "ENABLE" );
18 if ( command
.match( /START/ ) ) {
19 toggle
= command
.replace( "START", "STOP" );
20 } else if ( command
.match( /STOP/ ) ) {
21 toggle
= command
.replace( "STOP", "START" );
24 btn
.attr( "disabled", true );
33 success : function( data
) {
35 var msg
= "<strong>" + data
.brief
+ "</strong><br />" + data
.description
;
37 dialog
= $.notify( msg
, {
39 "remove": function () {
40 btn
.removeAttr( "disabled" );
44 "Submit command!": function () {
55 success : function( data
) {
57 var title
= btn
.html();
59 $.notify( "Command has been executed!" );
61 if ( typeof( data
.state
) != "undefined" ) {
62 if ( data
.state
=== 0 ) {
63 title
= title
.replace( /Enable/, "Disable" );
64 title
= title
.replace( /Start/, "Stop" );
66 title
= title
.replace( /Stop/, "Start" );
67 title
= title
.replace( /Disable/, "Enable" );
71 btn
.attr( "data-state", (data
.state
== 1) ? 0 : 1 );
74 btn
.attr( "data-command", toggle
);
79 btn
.removeAttr( "disabled" );