diff options
Diffstat (limited to 'public/assets/js')
| -rw-r--r-- | public/assets/js/lib/views/details/index.js | 17 | ||||
| -rw-r--r-- | public/assets/js/lib/views/index/index.js | 2 | ||||
| -rw-r--r-- | public/assets/js/lib/views/index/threadbox.js | 26 | ||||
| -rw-r--r-- | public/assets/js/util/format.js | 9 | ||||
| -rw-r--r-- | public/assets/js/vendor/view/view.js | 1 |
5 files changed, 46 insertions, 9 deletions
diff --git a/public/assets/js/lib/views/details/index.js b/public/assets/js/lib/views/details/index.js index 554c475..6290738 100644 --- a/public/assets/js/lib/views/details/index.js +++ b/public/assets/js/lib/views/details/index.js @@ -6,11 +6,13 @@ var DetailsView = View.extend({ action: "/api/thread/", keywordAction: "/api/keyword/", + initialize: function(opt){ this.comments = new CommentsView ({ parent: this }) this.files = new FilesView ({ parent: this }) this.gallery = new GalleryView ({ parent: this }) this.threadbox = new ThreadBox ({ parent: this }) + this.metadataTemplate = $(".metadata_template").html() }, load: function(id){ @@ -19,7 +21,20 @@ var DetailsView = View.extend({ }, populate: function(data){ - $("h1").html(data.thread.title) + var thread = data.thread + $("h1").html(thread.title) + var datetime = verbose_date(thread.createdate, true) + var age = get_age(thread.lastmodified, true) + var t = this.metadataTemplate + .replace(/{{ username }}/g, thread.username) + .replace(/{{ date }}/g, datetime[0]) + .replace(/{{ time }}/g, datetime[1]) + .replace(/{{ active }}/g, age + " ago") + .replace(/{{ views }}/g, thread.viewed + " " + courtesy_s(thread.viewed, "view")) +console.log(t) + console.log(data.thread) +// name date time active views + $(".metadata").html(t) this.comments.load(data.comments) this.files.load(data.files) this.gallery.load(data.files) diff --git a/public/assets/js/lib/views/index/index.js b/public/assets/js/lib/views/index/index.js index a1e8af5..d66ea1c 100644 --- a/public/assets/js/lib/views/index/index.js +++ b/public/assets/js/lib/views/index/index.js @@ -8,7 +8,7 @@ var IndexView = View.extend({ initialize: function(opt){ // opt.parent = parent this.hootbox = new HootBox ({ parent: this }) - this.threadbox = new ThreadBox ({ parent: this }) + this.threadbox = new ThreadBox ({ parent: this, latest: true }) this.lastlog = new LastLog ({ parent: this }) this.load() }, diff --git a/public/assets/js/lib/views/index/threadbox.js b/public/assets/js/lib/views/index/threadbox.js index 0475382..0c6a4be 100644 --- a/public/assets/js/lib/views/index/threadbox.js +++ b/public/assets/js/lib/views/index/threadbox.js @@ -12,10 +12,26 @@ var ThreadBox = View.extend({ load: function(data){ if (data.keyword) { - var $row = this.parseKeyword(data.keyword) - this.$el.append($row) + this.appendKeyword(data.keyword) + data.threads.forEach(this.appendThread.bind(this)) + } + else if (this.options.latest) { + data.threads.sort( (a,b) => { + return b.lastmodified - a.lastmodified + }).slice(0, 50).forEach(this.appendThread.bind(this)) + } + else { + var keywords = {} + data.threads.forEach((thread) => { + var keyword = thread.keyword || '__unsorted' + keywords[keyword] = keywords[keyword] || [] + keywords[keyword].push(thread) + }) + Object.keys(keywords).sort().forEach((keyword) => { + this.appendKeyword({ keyword }) + keywords[keyword].forEach(this.appendThread.bind(this)) + }) } - data.threads.forEach(this.appendThread.bind(this)) }, parse: function(thread){ @@ -65,4 +81,8 @@ var ThreadBox = View.extend({ this.$el.append($row) }, + appendKeyword: function(keyword){ + var $row = $( this.parseKeyword(keyword) ) + this.$el.append($row) + }, }) diff --git a/public/assets/js/util/format.js b/public/assets/js/util/format.js index 501108a..889ab09 100644 --- a/public/assets/js/util/format.js +++ b/public/assets/js/util/format.js @@ -132,7 +132,7 @@ function hush_null (n, unit, no_bold) { } } -function courtesy_s (n, s) { return v == 1 ? "" : (s || "s") } +function courtesy_s (n, s) { return n == 1 ? "" : (s || "s") } var revision_letters = "z a b c d f g h j k l m n p q r s t v w x y".split(" ") function get_revision (thread) { @@ -207,10 +207,11 @@ function make_link(file){ } function make_thumb(file){ if (file.filename.indexOf("http") !== 0) { - return "//carbonpictures.com/bucky/data/" + file.thread + "/.thumb/t." + file.filename.toLowerCase() + return "//carbonpictures.com/bucky/data/" + file.thread + "/" + file.filename } else { - var partz = file.filename.toLowerCase().split("/") - return partz.splice(partz.length-2, 0, ".thumb").join("/") + return "//carbonpictures.com/bucky/data/" + file.thread + "/" + file.filename + // var partz = file.filename.toLowerCase().split("/") + // return partz.splice(partz.length-2, 0, ".thumb").join("/") } }
\ No newline at end of file diff --git a/public/assets/js/vendor/view/view.js b/public/assets/js/vendor/view/view.js index 9a8ab5b..82e5117 100644 --- a/public/assets/js/vendor/view/view.js +++ b/public/assets/js/vendor/view/view.js @@ -4,6 +4,7 @@ var View = (function($, _){ this._id = _.uniqueId('view') this.type = "view" options || (options = {}); + this.options = options _.extend(this, _.pick(options, viewOptions)) this._ensureElement() this.initialize.apply(this, arguments) |
