From 8fbc5528a88d2f49ff55264145e87e9994975e92 Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Sun, 1 Mar 2020 01:23:16 +0000 Subject: [PATCH] Move the JS `alert` function definition to `/js/alert.js` and move the alert div to `views/layout.ecr` --- public/js/alert.js | 6 ++++++ public/js/download.js | 9 --------- public/js/title.js | 8 -------- public/js/user-edit.js | 12 +----------- public/js/user.js | 8 -------- src/views/download.ecr | 2 +- src/views/layout.ecr | 1 + src/views/title.ecr | 2 +- src/views/user-edit.ecr | 3 +-- src/views/user.ecr | 2 +- 10 files changed, 12 insertions(+), 41 deletions(-) create mode 100644 public/js/alert.js diff --git a/public/js/alert.js b/public/js/alert.js new file mode 100644 index 0000000..babc0b6 --- /dev/null +++ b/public/js/alert.js @@ -0,0 +1,6 @@ +const alert = (level, text) => { + $('#alert').empty(); + const html = `

${text}

`; + $('#alert').append(html); + $("html, body").animate({ scrollTop: 0 }); +}; diff --git a/public/js/download.js b/public/js/download.js index c9ee07c..252254e 100644 --- a/public/js/download.js +++ b/public/js/download.js @@ -286,12 +286,3 @@ const buildTable = () => { }); $('#selection-controls').removeAttr('hidden'); }; -const alert = (level, text) => { - hideAlert(); - const html = '

' + text + '

'; - $('#alert').append(html); - $("html, body").animate({ scrollTop: 0 }); -}; -const hideAlert = () => { - $('#alert').empty(); -}; diff --git a/public/js/title.js b/public/js/title.js index e2d236d..d309c1e 100644 --- a/public/js/title.js +++ b/public/js/title.js @@ -42,11 +42,3 @@ function updateProgress(titleID, entryID, page) { } }); } -function alert(level, text) { - hideAlert(); - var html = '

' + text + '

'; - $('#alert').append(html); -} -function hideAlert() { - $('#alert').empty(); -} diff --git a/public/js/user-edit.js b/public/js/user-edit.js index 12e4aa4..650d785 100644 --- a/public/js/user-edit.js +++ b/public/js/user-edit.js @@ -1,16 +1,6 @@ -$(function(){ +$(() => { var target = '/admin/user/edit'; if (username) target += username; $('form').attr('action', target); - - function alert(level, text) { - hideAlert(); - var html = '

' + text + '

'; - $('#alert').append(html); - } - function hideAlert() { - $('#alert').empty(); - } - if (error) alert('danger', error); }); diff --git a/public/js/user.js b/public/js/user.js index 9d6c111..0bce1c5 100644 --- a/public/js/user.js +++ b/public/js/user.js @@ -1,11 +1,3 @@ -function alert(level, text) { - hideAlert(); - var html = '

' + text + '

'; - $('#alert').append(html); -} -function hideAlert() { - $('#alert').empty(); -} function remove(username) { $.post('/api/admin/user/delete/' + username, function(data) { if (data.success) { diff --git a/src/views/download.ecr b/src/views/download.ecr index 0ee3665..90e9fdd 100644 --- a/src/views/download.ecr +++ b/src/views/download.ecr @@ -1,4 +1,3 @@ -

Download from MangaDex

@@ -79,5 +78,6 @@ + <% end %> diff --git a/src/views/layout.ecr b/src/views/layout.ecr index 3cfca0d..f041895 100644 --- a/src/views/layout.ecr +++ b/src/views/layout.ecr @@ -50,6 +50,7 @@
+
<%= content %>
diff --git a/src/views/title.ecr b/src/views/title.ecr index 017993a..12004ed 100644 --- a/src/views/title.ecr +++ b/src/views/title.ecr @@ -1,4 +1,3 @@ -

<%= title.title %>

<%= title.entries.size %> entries found

@@ -63,6 +62,7 @@
<% content_for "script" do %> + diff --git a/src/views/user-edit.ecr b/src/views/user-edit.ecr index 8fec3ba..f7ea939 100644 --- a/src/views/user-edit.ecr +++ b/src/views/user-edit.ecr @@ -1,5 +1,3 @@ -
-
@@ -51,5 +49,6 @@ error = '<%= error %>'; <%- end -%> + <% end %> diff --git a/src/views/user.ecr b/src/views/user.ecr index 11e62d8..7207d91 100644 --- a/src/views/user.ecr +++ b/src/views/user.ecr @@ -1,4 +1,3 @@ -
@@ -27,5 +26,6 @@ <% content_for "script" do %> + <% end %>