summaryrefslogtreecommitdiff
path: root/public/assets/js/lib
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/js/lib')
-rw-r--r--public/assets/js/lib/views/details/index.js9
-rw-r--r--public/assets/js/lib/views/index/index.js2
-rw-r--r--public/assets/js/lib/views/index/threadbox.js23
-rw-r--r--public/assets/js/lib/views/mail/mailbox.js58
-rw-r--r--public/assets/js/lib/views/mail/message.js0
5 files changed, 81 insertions, 11 deletions
diff --git a/public/assets/js/lib/views/details/index.js b/public/assets/js/lib/views/details/index.js
index d7fb26f..554c475 100644
--- a/public/assets/js/lib/views/details/index.js
+++ b/public/assets/js/lib/views/details/index.js
@@ -4,11 +4,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 })
},
load: function(id){
@@ -21,6 +23,13 @@ var DetailsView = View.extend({
this.comments.load(data.comments)
this.files.load(data.files)
this.gallery.load(data.files)
+ if (data.thread.keyword) {
+ $.get(this.keywordAction + data.thread.keyword, this.populateKeyword.bind(this))
+ }
+ },
+
+ populateKeyword: function(data){
+ this.threadbox.load(data)
},
success: function(){
diff --git a/public/assets/js/lib/views/index/index.js b/public/assets/js/lib/views/index/index.js
index 3d4dc72..a1e8af5 100644
--- a/public/assets/js/lib/views/index/index.js
+++ b/public/assets/js/lib/views/index/index.js
@@ -19,7 +19,7 @@ var IndexView = View.extend({
populate: function(data){
this.hootbox.load(data.hootbox)
- this.threadbox.load(data.threads)
+ this.threadbox.load(data)
this.lastlog.load(data.lastlog)
},
diff --git a/public/assets/js/lib/views/index/threadbox.js b/public/assets/js/lib/views/index/threadbox.js
index bcaaceb..eee7a5c 100644
--- a/public/assets/js/lib/views/index/threadbox.js
+++ b/public/assets/js/lib/views/index/threadbox.js
@@ -1,11 +1,3 @@
-/*
-age_class
-views_class
-comments_class
-size_class
-files_class
-*/
-
var ThreadBox = View.extend({
el: ".threads",
@@ -15,10 +7,15 @@ var ThreadBox = View.extend({
initialize: function(){
this.__super__.initialize.call(this)
this.template = this.$(".template").html()
+ this.keywordTemplate = this.$(".keywordTemplate").html()
},
- load: function(threads){
- threads.forEach(this.appendThread.bind(this))
+ load: function(data){
+ if (data.keyword) {
+ var $row = this.parseKeyword(data.keyword)
+ this.$el.append($row)
+ }
+ data.threads.forEach(this.appendThread.bind(this))
},
parse: function(thread){
@@ -52,6 +49,12 @@ var ThreadBox = View.extend({
return t
},
+ parseKeyword: function(keyword){
+ var t = this.keywordTemplate
+ .replace(/{{keyword}}/g, keyword.keyword)
+ return t
+ },
+
prependThread: function(thread){
var $row = $( this.parse(thread) )
this.$el.prepend($row)
diff --git a/public/assets/js/lib/views/mail/mailbox.js b/public/assets/js/lib/views/mail/mailbox.js
new file mode 100644
index 0000000..fe16980
--- /dev/null
+++ b/public/assets/js/lib/views/mail/mailbox.js
@@ -0,0 +1,58 @@
+var Mailbox = View.extend({
+ el: ".mailbox",
+
+ events: {
+ },
+
+ action: "/api/mailbox/",
+
+ initialize: function(){
+ this.__super__.initialize.call(this)
+ this.template = this.$(".template").html()
+ this.boxTemplate = this.$(".boxTemplate").html()
+ },
+
+ load: function(name){
+ $("h1").html(name)
+ $.get(this.action + name, this.populate.bind(this))
+ },
+
+ populate: function(data){
+ data.boxes.forEach(this.appendBox.bind(this))
+ data.messages.forEach(this.appendMessage.bind(this))
+ },
+
+ parseBox: function(box){
+ var t = this.boxTemplate
+ .replace(/{{box}}/g, box.name)
+ .replace(/{{count}}/g, box.count)
+ return t
+ },
+
+ parseMessage: function(message){
+ var datetime = verbose_date(message.date)
+ var id = message.id
+
+ var t = this.template
+ .replace(/{{id}}/g, thread.id)
+ .replace(/{{username}}/g, thread.username)
+ .replace(/{{subject}}/g, thread.title)
+ .replace(/{{date}}/g, datetime[0])
+ .replace(/{{time}}/g, datetime[1])
+ .replace(/{{date_class}}/g, carbon_date(thread.lastmodified) )
+ .replace(/{{size}}/g, size[1] )
+ .replace(/{{size_class}}/g, size[0] )
+ return t
+ },
+
+ appendBox: function(box){
+ var $row = $( this.parseBox(box) )
+ this.$el.append($row)
+ },
+
+ appendMessage: function(message){
+ var $row = $( this.parseMessage(message) )
+ this.$el.append($row)
+ },
+
+})
diff --git a/public/assets/js/lib/views/mail/message.js b/public/assets/js/lib/views/mail/message.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/public/assets/js/lib/views/mail/message.js