summaryrefslogtreecommitdiffstats
path: root/data/js/script.js
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-02-23 11:26:14 +0100
committerFlorian Pritz <bluewind@xinu.at>2015-02-23 11:26:14 +0100
commitea8471781ee26f79c3835e68b31353601e78d0a8 (patch)
tree0fa2552509011f8b330f044459384eaa1899d418 /data/js/script.js
parented6077c460039ae1ca279c7a9d6d334caf1c2314 (diff)
upload_form: Support multiple textareas/files at the same time
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'data/js/script.js')
-rw-r--r--data/js/script.js39
1 files changed, 38 insertions, 1 deletions
diff --git a/data/js/script.js b/data/js/script.js
index ee8ba9e3c..c96bdb5b7 100644
--- a/data/js/script.js
+++ b/data/js/script.js
@@ -155,7 +155,7 @@ function fixedEncodeURIComponent (str) {
document.getElementById('upload_button').innerHTML = "File(s) too big";
document.getElementById('upload_button').disabled = true;
} else {
- document.getElementById('upload_button').innerHTML = "Upload it!";
+ document.getElementById('upload_button').innerHTML = "Upload/Paste it!";
document.getElementById('upload_button').disabled = false;
}
}
@@ -179,6 +179,43 @@ function fixedEncodeURIComponent (str) {
});
+ $(document).on("input propertychange", '.text-upload', function() {
+ var need_new = true;
+
+ $('.text-upload').each(function() {
+ if (!$(this).val()) {
+ need_new = false;
+ return;
+ }
+ });
+
+ if (need_new) {
+ var i = $('#textboxes .tab-content .tab-pane').length + 1;
+ var new_tab = $('#text-upload-tab-1')
+ .clone()
+ .attr("id", "text-upload-tab-"+i)
+ .toggleClass("active", false)
+ .appendTo('#textboxes .tab-content');
+ new_tab.find("[name^=filename]").attr("name", "filename["+i+"]").val("");
+ new_tab.find("[name^=content]").attr("name", "content["+i+"]").val("");
+ $('#textboxes ul.nav')
+ .append('<li><a href="#text-upload-tab-'+i+'" data-toggle="tab">Paste '+i+' </a></li>');
+ }
+ });
+
+ $(document).on("input propertychange", '#textboxes input[name^=filename]', function() {
+ var name = $(this).val();
+ var tabId = $(this).closest("[id^=text-upload-tab-]").attr("id");
+ var id = tabId.match(/-(\d)$/)[1];
+ var tab = $('#textboxes .nav a[href="#'+tabId+'"]');
+
+ if (name != "") {
+ tab.text(name);
+ } else {
+ tab.text("Paste " + id);
+ }
+ });
+
if (typeof $.tablesorter !== 'undefined') {
// source: https://projects.archlinux.org/archweb.git/tree/sitestatic/archweb.js
$.tablesorter.addParser({