summaryrefslogtreecommitdiffstats
path: root/script
diff options
context:
space:
mode:
authorSimon Rettberg2017-11-29 11:31:26 +0100
committerSimon Rettberg2017-11-29 11:31:26 +0100
commit4d120b829ad657dc329282ae6969cf1b988e544c (patch)
tree4f3c1d35eead4dfaf3caad8caaf06e64562c1d49 /script
parent[runmode] Implement delete-machine action (diff)
downloadslx-admin-4d120b829ad657dc329282ae6969cf1b988e544c.tar.gz
slx-admin-4d120b829ad657dc329282ae6969cf1b988e544c.tar.xz
slx-admin-4d120b829ad657dc329282ae6969cf1b988e544c.zip
[js] Move all our fixes into one file, add browser history/URL fix for messages
Hides all the ugly message[]= entries from the URL string, so copy/paste won't show the message out of context again
Diffstat (limited to 'script')
-rw-r--r--script/collapse.js3
-rw-r--r--script/fileselect.js20
-rw-r--r--script/slx-fixes.js42
3 files changed, 42 insertions, 23 deletions
diff --git a/script/collapse.js b/script/collapse.js
deleted file mode 100644
index ca026f87..00000000
--- a/script/collapse.js
+++ /dev/null
@@ -1,3 +0,0 @@
-$('.slx-decollapse').click(function () {
- $(this).siblings('.collapse').removeClass('collapse');
-}); \ No newline at end of file
diff --git a/script/fileselect.js b/script/fileselect.js
deleted file mode 100644
index 13711fd5..00000000
--- a/script/fileselect.js
+++ /dev/null
@@ -1,20 +0,0 @@
-$(document).on('change', '.btn-file :file', function() {
- var input = $(this);
- var numFiles = input.get(0).files ? input.get(0).files.length : 1;
- var label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
- input.trigger('fileselect', [numFiles, label]);
-});
-
-$(document).ready(function() {
- $('.btn-file :file').on('fileselect', function(event, numFiles, label) {
- var input = $(this).parents('.upload-ex').find(':text');
- var log = numFiles > 1 ? numFiles + ' files selected' : label;
- if (input.length) {
- input.val(log);
- }
- });
-});
-
-$('.upload-ex :text').click(function () {
- $(this).parents('.upload-ex').find(':file').click();
-}); \ No newline at end of file
diff --git a/script/slx-fixes.js b/script/slx-fixes.js
new file mode 100644
index 00000000..12db9c79
--- /dev/null
+++ b/script/slx-fixes.js
@@ -0,0 +1,42 @@
+// Give file select dialogs a modern style and feel
+$(document).on('change', '.btn-file :file', function() {
+ var input = $(this);
+ var numFiles = input.get(0).files ? input.get(0).files.length : 1;
+ var label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
+ input.trigger('fileselect', [numFiles, label]);
+});
+$(document).ready(function() {
+ $('.btn-file :file').on('fileselect', function(event, numFiles, label) {
+ var input = $(this).parents('.upload-ex').find(':text');
+ var log = numFiles > 1 ? numFiles + ' files selected' : label;
+ if (input.length) {
+ input.val(log);
+ }
+ });
+});
+$('.upload-ex :text').click(function () {
+ $(this).parents('.upload-ex').find(':file').click();
+});
+
+// Replace message query params in URL, so you won't see them again if you bookmark or share the link
+if (history && history.replaceState && window && window.location && window.location.search && window.location.search.indexOf('message[]=') !== -1) {
+ var str = window.location.search;
+ console.log('TRUE: ' + str);
+ do {
+ var repl = str.match(/([\?&])message\[\]=[^&]+(&|$)/);
+ console.log(repl);
+ if (!repl) break;
+ if (repl[2].length === 0) {
+ str = str.replace(repl[0], '');
+ } else {
+ str = str.replace(repl[0], repl[1]);
+ }
+ console.log('Replace: ' + str);
+ } while (1);
+ history.replaceState(null, null, window.location.pathname + str);
+}
+
+// Simple decollapse functionality for tables
+$('.slx-decollapse').click(function () {
+ $(this).siblings('.collapse').removeClass('collapse');
+}); \ No newline at end of file