From a7aea69687eb268807aa4a86d9188004fe5cb6c7 Mon Sep 17 00:00:00 2001 From: pep Date: Tue, 28 Jul 2020 21:29:32 +0000 Subject: fixed minor thing --- bucky/app/bucky.js | 11 ++---- public/assets/js/lib/views/details/commentform.js | 1 + public/assets/js/lib/views/details/files.js | 2 +- public/assets/js/lib/views/details/settings.js | 48 +++++++++++------------ public/assets/js/util/format.js | 4 +- 5 files changed, 32 insertions(+), 34 deletions(-) diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index f104e3b..244b219 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -517,15 +517,12 @@ var bucky = module.exports = { console.log(data) //this library encodes things twice so have to do it yourself url = `http://media.spermwhale.info/bucky/data/${data.thread}/${encodeURI(data.filename)}` - req.body.comment = (req.body.comment.length) ? req.body.comment + "
\n" + url + "\n" + file.originalname : url+"\n"+file.originalname + var comment_footer = url + "\n" + file.originalname + req.body.comment = (req.body.comment) ? req.body.comment + "\n
" + comment_footer : comment_footer db.createFile(data).then(function(file){ + console.log(file) resolve(file) - }).catch( (err) => reject(err) ).then( - function(){ - console.log("about to call createComment") - bucky.createComment(req, res, function(){}) - - }) + }).catch( (err) => reject(err) ) } }) }) diff --git a/public/assets/js/lib/views/details/commentform.js b/public/assets/js/lib/views/details/commentform.js index 51295cb..f3d79ac 100644 --- a/public/assets/js/lib/views/details/commentform.js +++ b/public/assets/js/lib/views/details/commentform.js @@ -54,6 +54,7 @@ var CommentForm = FormView.extend({ // window.location.reload() console.log(this) console.log(this.parent) + console.log("this is data") console.log(data) data.comment && this.parent.comments.load([data.comment]) data.files && this.parent.files.load(data.files) diff --git a/public/assets/js/lib/views/details/files.js b/public/assets/js/lib/views/details/files.js index 98b9350..915f90b 100644 --- a/public/assets/js/lib/views/details/files.js +++ b/public/assets/js/lib/views/details/files.js @@ -21,7 +21,7 @@ var FilesView = FormView.extend({ } var total = 0, has_music = false - this.files = files || this.files + this.files = this.files.concat(files) this.thread = thread || this.thread this.files.forEach(function(file){ if (is_image(file.filename)) { diff --git a/public/assets/js/lib/views/details/settings.js b/public/assets/js/lib/views/details/settings.js index a027b12..b270f02 100644 --- a/public/assets/js/lib/views/details/settings.js +++ b/public/assets/js/lib/views/details/settings.js @@ -316,32 +316,32 @@ var ThreadSettingsForm = FormView.extend({ file_names.join("\n") var should_remove = confirm(msg) if (should_remove) { - } - var promises = inputs_checked.map(node => { - return new Promise((resolve, reject) => { - $.ajax({ - method: "DELETE", - url: "/api/file/" + node.value, - headers: { "csrf-token": $("[name=_csrf]").attr("value") }, - data: JSON.stringify({ csrf: csrf() }), - dataType: "json", - success: function(data){ - console.log(data) - $(node).closest('.file').remove() - }, - error: function(){ - console.log('error deleting file', node.value) - reject() - } + var promises = inputs_checked.map(node => { + return new Promise((resolve, reject) => { + $.ajax({ + method: "DELETE", + url: "/api/file/" + node.value, + headers: { "csrf-token": $("[name=_csrf]").attr("value") }, + data: JSON.stringify({ csrf: csrf() }), + dataType: "json", + success: function(data){ + console.log(data) + $(node).closest('.file').remove() + }, + error: function(){ + console.log('error deleting file', node.value) + reject() + } + }) }) }) - }) - Promise.all(promises).then( () => { - window.location.href = '/details/' + thread_id - }).catch(() =>{ - console.error('whaaaaa') - alert('there was a problem deleting the files...') - }) + Promise.all(promises).then( () => { + window.location.href = '/details/' + thread_id + }).catch(() =>{ + console.error('whaaaaa') + alert('there was a problem deleting the files...') + }) + } }, deleteThread: function(e){ diff --git a/public/assets/js/util/format.js b/public/assets/js/util/format.js index 441430e..28c659b 100644 --- a/public/assets/js/util/format.js +++ b/public/assets/js/util/format.js @@ -213,7 +213,7 @@ function get_age (t, long) { } function tidy_urls (s, short_urls) { - var ret = s.split("\n").map(function(line){ + var ret = s.split(/(<[bh]r\/?>|\n)/).map(function(line){ if (line.indexOf("<") !== -1) { return line @@ -230,7 +230,7 @@ function tidy_urls (s, short_urls) { } }); }) - .join("\n") + .join("") .replace(/\r/g, "") .replace(/\n/g, "") .replace(/<\/code>\n/g, "") -- cgit v1.2.3-70-g09d2