summaryrefslogtreecommitdiff
path: root/public/assets
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets')
-rw-r--r--public/assets/css/bucky.css5
-rw-r--r--public/assets/js/lib/views/mail/mailbox.js17
-rw-r--r--public/assets/js/lib/views/search/results.js23
-rw-r--r--public/assets/js/util/format.js12
4 files changed, 36 insertions, 21 deletions
diff --git a/public/assets/css/bucky.css b/public/assets/css/bucky.css
index e0c5be0..c768f86 100644
--- a/public/assets/css/bucky.css
+++ b/public/assets/css/bucky.css
@@ -807,7 +807,7 @@ pre br {
padding: 5px;
margin: 10px 0;
}
-#search .next_page {
+.next_page {
font-size: 14px;
display: block;
padding: 10px;
@@ -847,6 +847,9 @@ pre br {
color: #211;
}
+#no_messages {
+ display: none;
+}
#messages {
width: 100%;
}
diff --git a/public/assets/js/lib/views/mail/mailbox.js b/public/assets/js/lib/views/mail/mailbox.js
index 5635a7d..9d988cb 100644
--- a/public/assets/js/lib/views/mail/mailbox.js
+++ b/public/assets/js/lib/views/mail/mailbox.js
@@ -16,7 +16,8 @@ var MailboxView = View.extend({
load: function(name){
name = sanitize(name) || "inbox"
$("h1").html(name)
- $.get(this.action + name, this.populate.bind(this))
+ var query = window.location.search.substr(1)
+ $.get(this.action + name, query, this.populate.bind(this))
},
populate: function(data){
@@ -26,7 +27,19 @@ var MailboxView = View.extend({
var user = data.user
var max = data.messages.length-1
if (data.messages.length) {
- $("#no_messages").hide()
+ var limit = data.query.limit || 50
+ var offset = data.query.offset + data.messages.length
+ if (limit > data.messages.length) {
+ $(".next_page").hide()
+ }
+ else {
+ var query = { limit, offset }
+ $(".next_page a").attr("href", "?" + querystring(query))
+ }
+ }
+ else {
+ $("#no_messages").show()
+ $(".next_page").hide()
}
data.messages.forEach(function(message, i){
var $row = this.parse(message, user)
diff --git a/public/assets/js/lib/views/search/results.js b/public/assets/js/lib/views/search/results.js
index 0af68ba..0f34845 100644
--- a/public/assets/js/lib/views/search/results.js
+++ b/public/assets/js/lib/views/search/results.js
@@ -2,15 +2,15 @@ var SearchResults = View.extend({
el: "#search",
template: $("#search .template").html(),
-
+
events: {
},
-
+
action: "/api/search",
-
+
initialize: function(opt){
},
-
+
load: function(){
var query = window.location.search.substr(1)
if (! query || ! query.length) {
@@ -19,7 +19,7 @@ var SearchResults = View.extend({
}
$.get(this.action, query, this.populate.bind(this))
},
-
+
populate: function(res){
var query = sanitize(res.meta.query)
var terms = res.meta.terms
@@ -63,16 +63,3 @@ var SearchResults = View.extend({
},
})
-
-function bold_terms (s, terms) {
- s = sanitize(s)
- terms.forEach( (term) => {
- s = s.replace(new RegExp(term, "ig"), "<b>" + term + "</b>")
- })
- return s
-}
-function querystring(opt){
- return '?' + Object.keys(opt).map((key) => {
- return encodeURIComponent(key) + "=" + encodeURIComponent(opt[key])
- }).join("&")
-}
diff --git a/public/assets/js/util/format.js b/public/assets/js/util/format.js
index c765052..7032305 100644
--- a/public/assets/js/util/format.js
+++ b/public/assets/js/util/format.js
@@ -10,6 +10,18 @@ function choice(a){ return a[randint(a.length)] }
function csrf() {
return $("[name=_csrf]").attr("value")
}
+function bold_terms (s, terms) {
+ s = sanitize(s)
+ terms.forEach( (term) => {
+ s = s.replace(new RegExp(term, "ig"), "<b>" + term + "</b>")
+ })
+ return s
+}
+function querystring(opt){
+ return '?' + Object.keys(opt).map((key) => {
+ return encodeURIComponent(key) + "=" + encodeURIComponent(opt[key])
+ }).join("&")
+}
function commatize (n, radix) {
radix = radix || 1024
var nums = [], i, counter = 0, r = Math.floor