aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/serve.js24
-rw-r--r--lib/util.js12
2 files changed, 18 insertions, 18 deletions
diff --git a/lib/serve.js b/lib/serve.js
index 3ade4f6..354e75f 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -594,8 +594,8 @@ Serve.prototype.syncPager = function (opts) {
var max = (reverse ? opts.first : opts.last) || Number(q.lt)
var minDate = new Date(min)
var maxDate = new Date(max)
- var qOlder = mergeOpts(q, {lt: min, gt: undefined, forwards: undefined})
- var qNewer = mergeOpts(q, {gt: max, lt: undefined, forwards: 1})
+ var qOlder = u.mergeOpts(q, {lt: min, gt: undefined, forwards: undefined})
+ var qNewer = u.mergeOpts(q, {gt: max, lt: undefined, forwards: 1})
var atNewest = reverse ? !q.lt : !max
var atOldest = reverse ? !min : !q.gt
if (atNewest && !reverse) qOlder.lt++
@@ -1125,31 +1125,19 @@ Serve.prototype.renderThread = function () {
)
}
-function mergeOpts(a, b) {
- var obj = {}, k
- for (k in a) {
- obj[k] = a[k]
- }
- for (k in b) {
- if (b[k] != null) obj[k] = b[k]
- else delete obj[k]
- }
- return obj
-}
-
Serve.prototype.renderThreadPaginated = function (opts, feedId, q) {
var self = this
function linkA(opts, name) {
- var q1 = mergeOpts(q, opts)
+ var q1 = u.mergeOpts(q, opts)
return h('a', {href: '?' + qs.stringify(q1)}, name || q1.limit)
}
function links(opts) {
var limit = opts.limit || q.limit || 10
return h('tr', h('td.paginate', {colspan: 3},
opts.forwards ? '↑ newer ' : '↓ older ',
- linkA(mergeOpts(opts, {limit: 1})), ' ',
- linkA(mergeOpts(opts, {limit: 10})), ' ',
- linkA(mergeOpts(opts, {limit: 100}))
+ linkA(u.mergeOpts(opts, {limit: 1})), ' ',
+ linkA(u.mergeOpts(opts, {limit: 10})), ' ',
+ linkA(u.mergeOpts(opts, {limit: 100}))
))
}
diff --git a/lib/util.js b/lib/util.js
index e4cf415..57183d2 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -186,3 +186,15 @@ u.pullSlice = function (start, end) {
}
}
}
+
+u.mergeOpts = function (a, b) {
+ var obj = {}, k
+ for (k in a) {
+ obj[k] = a[k]
+ }
+ for (k in b) {
+ if (b[k] != null) obj[k] = b[k]
+ else delete obj[k]
+ }
+ return obj
+}