1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-22 09:02:28 +01:00

convert frontend javascript into revealing module pattern

This commit is contained in:
Jakob Schrettenbrunner 2017-01-27 00:44:28 +01:00
parent 344e3b4330
commit 0c1559c922
4 changed files with 301 additions and 245 deletions

View File

@ -17,7 +17,11 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
$(document).ready(function () {
var TwoFactorModal = (function () {
function bindListeners() {
$(document).ready(function () {
$('#close_reload').click(function () {
location.reload();
});
@ -73,4 +77,15 @@ $(document).ready(function () {
$('#submit_action').html('Submit').removeClass('disabled');
});
});
});
}
return {
init: function () {
bindListeners();
}
}
});
TwoFactorModal.init();

View File

@ -17,7 +17,10 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
(function initSocket() {
var Server = (function () {
function initSocket() {
if (typeof $.notifyDefaults !== 'function') {
console.error('Notify does not appear to be loaded.');
return;
@ -73,9 +76,9 @@
Socket.on('status', function (data) {
setStatusIcon(data.status);
});
})();
}
function setStatusIcon(status) {
function setStatusIcon(status) {
switch (status) {
case 0:
$('#server_status_icon').html('<i class="fa fa-circle text-danger"></i> Offline');
@ -92,4 +95,16 @@ function setStatusIcon(status) {
default:
break;
}
}
}
return {
init: function () {
initSocket();
},
setStatusIcon: setStatusIcon,
}
})();
Server.init();

View File

@ -17,14 +17,17 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
var Status = {
var ServerList = (function () {
var Status = {
0: 'Offline',
1: 'Online',
2: 'Starting',
3: 'Stopping'
};
};
(function updateServerStatus () {
function updateServerStatus () {
$('.dynamic-update').each(function (index, data) {
var element = $(this);
var serverShortUUID = $(this).data('server');
@ -72,4 +75,14 @@ var Status = {
});
});
setTimeout(updateServerStatus, 10000);
}
return {
init: function () {
updateServerStatus();
}
};
})();
ServerList.init();

View File

@ -17,7 +17,10 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
(function initTaskFunctions() {
var Tasks = (function () {
function initTaskFunctions() {
$('[data-action="delete-task"]').click(function (event) {
var self = $(this);
swal({
@ -99,4 +102,14 @@
});
});
});
}
return {
init: function () {
initTaskFunctions();
}
}
})();
Tasks.init();