diff options
Diffstat (limited to 'public/assets/js')
| -rw-r--r-- | public/assets/js/lib/views/index/index.js | 9 | ||||
| -rw-r--r-- | public/assets/js/lib/views/index/threadform.js | 22 | ||||
| -rw-r--r-- | public/assets/js/lib/views/mail/mailbox.js | 13 |
3 files changed, 28 insertions, 16 deletions
diff --git a/public/assets/js/lib/views/index/index.js b/public/assets/js/lib/views/index/index.js index 3f217fc..edf5483 100644 --- a/public/assets/js/lib/views/index/index.js +++ b/public/assets/js/lib/views/index/index.js @@ -34,6 +34,15 @@ var IndexView = View.extend({ this.hootbox.load(data.hootbox) this.threadbox.load(data) this.lastlog.load(data.lastlog) + if (data.mail.count) { + $(".alert").show().html( + "<a href='/mail'>" + + "You have " + + data.mail.count + + " new message" + + courtesy_s(data.mail.count) + + "!</a>") + } $(".search_form input").focus() }, diff --git a/public/assets/js/lib/views/index/threadform.js b/public/assets/js/lib/views/index/threadform.js index 7a8e8ed..b2e1963 100644 --- a/public/assets/js/lib/views/index/threadform.js +++ b/public/assets/js/lib/views/index/threadform.js @@ -1,18 +1,18 @@ var ThreadForm = FormView.extend({ - + el: "#thread_form", - + events: { }, - + action: "/api/thread", method: "POST", - + initialize: function(){ this.__super__.initialize.call(this) this.template = this.$(".template").html() }, - + load: function(selected_keyword){ $.get("/api/keywords", function(data){ var tags = {} @@ -21,17 +21,19 @@ var ThreadForm = FormView.extend({ var opt = document.createElement('option') opt.value = kw opt.innerHTML = kw - if (selected_keyword === kw) { - opt.setAttribute("selected", "selected") - } tags[kw] = opt }) var sorted = Object.keys(tags).sort().map(kw => tags[kw]) this.$('[name=keyword]').append(sorted) + if (selected_keyword) { + this.$('[name=keyword]').val(selected_keyword) + } else { + this.$('[name=keyword]').val('unsorted') + } $("body").removeClass('loading') }.bind(this)) }, - + validate: function(){ var errors = [] var title = this.$("[name=title]").val() @@ -52,4 +54,4 @@ var ThreadForm = FormView.extend({ } window.location.href = "/details/" + data.id } -})
\ No newline at end of file +}) diff --git a/public/assets/js/lib/views/mail/mailbox.js b/public/assets/js/lib/views/mail/mailbox.js index 22a49c5..5635a7d 100644 --- a/public/assets/js/lib/views/mail/mailbox.js +++ b/public/assets/js/lib/views/mail/mailbox.js @@ -1,24 +1,24 @@ var MailboxView = View.extend({ el: "#messages", - + events: { 'click .discard_link': 'discard', }, - + action: "/api/mailbox/", - + initialize: function(){ this.__super__.initialize.call(this) this.template = this.$(".template").html() this.boxlist = new BoxList () }, - + load: function(name){ name = sanitize(name) || "inbox" $("h1").html(name) $.get(this.action + name, this.populate.bind(this)) }, - + populate: function(data){ if (data.boxes) { this.boxlist.load(data.boxes) @@ -37,7 +37,7 @@ var MailboxView = View.extend({ } $("body").removeClass('loading') }, - + parse: function(message, user){ var datetime = verbose_date(message.date) var size = hush_size(message.size) @@ -47,6 +47,7 @@ var MailboxView = View.extend({ var t = this.template .replace(/{{id}}/g, message.id) .replace(/{{to}}/g, is_sender ? "to " : "") + .replace(/{{unread}}/g, message.unread ? "unread" : "") .replace(/{{username}}/g, is_sender ? message.recipient : message.sender) .replace(/{{subject}}/g, message.subject) .replace(/{{date}}/g, datetime[0]) |
