summaryrefslogtreecommitdiffstats
path: root/data/js/script.js
diff options
context:
space:
mode:
authorJoakim Reinert <mail@jreinert.com>2015-05-01 22:30:12 +0200
committerFlorian Pritz <bluewind@xinu.at>2015-05-05 12:21:27 +0200
commitb7d501a42b2245ef1fc33171f9b53565e176c648 (patch)
treed6f575cfbc0e5c642c54e445fe15314b6d584bfc /data/js/script.js
parentda835670f796774d1f98c05dfdf7da1c7ba2655a (diff)
Refactor file uploader js
Diffstat (limited to 'data/js/script.js')
-rw-r--r--data/js/script.js88
1 files changed, 0 insertions, 88 deletions
diff --git a/data/js/script.js b/data/js/script.js
index 14250cd3d..b9f196fab 100644
--- a/data/js/script.js
+++ b/data/js/script.js
@@ -1,93 +1,5 @@
(function($) {
$(function() {
- // check file size before uploading if browser support html5
- if (window.File && window.FileList) {
- function checkFileUpload(evt) {
- var sum = 0;
- var filenum = 0;
- var files = [];
-
- $('.file-upload').each(function() {
- for (var i = 0; i < this.files.length; i++) {
- var file = this.files[i];
- files.push(file);
- }
- });
-
- for (var i = 0; i < files.length; i++) {
- var f = files[i];
- sum += f.size;
- filenum++;
- }
-
- if (filenum > max_files_per_upload) {
- document.getElementById('upload_button').innerHTML = "Too many files";
- document.getElementById('upload_button').disabled = true;
- } else if (sum > max_upload_size) {
- document.getElementById('upload_button').innerHTML = "File(s) too big";
- document.getElementById('upload_button').disabled = true;
- } else {
- document.getElementById('upload_button').innerHTML = "Upload/Paste it!";
- document.getElementById('upload_button').disabled = false;
- }
- }
-
- $(document).on('change', '.file-upload', checkFileUpload);
- }
-
- $(document).on("change", '.file-upload', function() {
- var need_new = true;
-
- $('.file-upload').each(function() {
- if ($(this).prop("files").length == 0) {
- need_new = false;
- return;
- }
- });
-
- if (need_new) {
- $(this).parent().append('<input class="file-upload" type="file" name="file[]" multiple="multiple"><br>');
- }
-
- });
-
- $(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({