diff options
Diffstat (limited to 'public/assets')
| -rw-r--r-- | public/assets/css/bucky.css | 7 | ||||
| -rw-r--r-- | public/assets/js/lib/router.js | 10 | ||||
| -rw-r--r-- | public/assets/js/lib/views/details/details.js (renamed from public/assets/js/lib/views/details/index.js) | 0 | ||||
| -rw-r--r-- | public/assets/js/lib/views/keywords/keywords.js | 72 | ||||
| -rw-r--r-- | public/assets/js/util/format.js | 15 |
5 files changed, 93 insertions, 11 deletions
diff --git a/public/assets/css/bucky.css b/public/assets/css/bucky.css index e915ded..9d2b36e 100644 --- a/public/assets/css/bucky.css +++ b/public/assets/css/bucky.css @@ -82,10 +82,14 @@ h1 { margin-top: 2px; margin-bottom: 4px; } +a.headline:link, +a.headline:visited { color: #111; text-decoration: none; } +a.headline h1 { text-decoration: none; } +.desktop a.headline:hover { color: #654; text-decoration: none; } a:link { color: #2050ca; text-decoration: underline; } a:visited { color: #1030aa; text-decoration: none; } a:active { color: #a0a0c7; text-decoration: underline; } -a:hover { color: #2040f0; text-decoration: underline; } +.desktop a:hover { color: #2040f0; text-decoration: underline; } hr { border-color: #000; } @@ -615,7 +619,6 @@ pre br { #files .total td a { display: inline; } - #gallery { width: 100%; } diff --git a/public/assets/js/lib/router.js b/public/assets/js/lib/router.js index da5149a..9ac6336 100644 --- a/public/assets/js/lib/router.js +++ b/public/assets/js/lib/router.js @@ -13,6 +13,8 @@ var SiteRouter = Router.extend({ "/details/:id/settings": 'threadSettings', "/post": 'post', "/post/:keyword": 'post', + "/comment/:id/edit": 'editComment', + "/keywords": 'keywords', "/search": 'search', "/mail": 'mailbox', "/mail/:mailbox": 'mailbox', @@ -20,7 +22,6 @@ var SiteRouter = Router.extend({ "/mail/compose/:username": 'compose', "/mail/read/:id": 'message', "/mail/reply/:id": 'compose', - "/comment/:id/edit": 'editComment', "/profile": 'profile', "/profile/:username": 'profile', "/profile/:username/edit": 'editProfile', @@ -62,7 +63,12 @@ var SiteRouter = Router.extend({ app.view = new EditCommentForm () app.view.load(id) }, - + + keywords: function(){ + app.view = new KeywordsView () + app.view.load() + }, + mailbox: function(box){ app.view = new MailboxView () app.view.load(box) diff --git a/public/assets/js/lib/views/details/index.js b/public/assets/js/lib/views/details/details.js index 1b67b92..1b67b92 100644 --- a/public/assets/js/lib/views/details/index.js +++ b/public/assets/js/lib/views/details/details.js diff --git a/public/assets/js/lib/views/keywords/keywords.js b/public/assets/js/lib/views/keywords/keywords.js new file mode 100644 index 0000000..acb76f1 --- /dev/null +++ b/public/assets/js/lib/views/keywords/keywords.js @@ -0,0 +1,72 @@ +var KeywordsView = View.extend({ + + el: "#keyword_list", + + events: { + }, + + action: "/api/keywords/statistics", + + initialize: function(opt){ + this.template = this.$(".template").html() + console.log(this.$(".template")) + }, + + load: function(){ + $.get(this.action, this.populate.bind(this)) + }, + + populate: function(data){ + console.log(data) + var keywordThreads = {} + data.threadGroups.forEach(kw => { + keywordThreads[kw.keyword] = kw + }) + data.keywords + .map(a => [parseInt((keywordThreads[a.keyword] || {})['sum(`viewed`)']) || 0, a]) + .sort((b,a) => cmp(a[0], b[0])) + .map(a => a[1]) + .forEach(keyword => { + var thread = keywordThreads[keyword.keyword.toLowerCase()] || { + title: '', + } + // { + // keyword: "warez", + // sum(`viewed`): "498", + // id: 701, + // title: "EMS SYNTHI PLUG FOR MAC", + // lastmodified: 1192401724 + // }, + console.log(keyword, thread) + var viewed = thread['sum(`viewed`)'] + var views = viewed ? hush_views(viewed) : ['',''] + var dot = privacy_dot(thread.privacy) + var datetime = verbose_date(keyword.createdate) + var age = get_age(thread.lastmodified) + var id = thread.id + get_revision(thread) + var t = this.template + .replace(/{{keyword}}/g, sanitize(keyword.keyword)) + .replace(/{{id}}/g, id) + .replace(/{{username}}/g, keyword.username) + .replace(/{{privacy_dot}}/g, dot) + .replace(/{{title}}/g, thread.title) + .replace(/{{date}}/g, datetime[0]) + .replace(/{{time}}/g, datetime[1]) + .replace(/{{date_class}}/g, carbon_date(thread.lastmodified) ) + .replace(/{{views}}/g, views[1]) +// .replace(/{{comments}}/g, comments[1]) +// .replace(/{{files}}/g, files[1]) +// .replace(/{{size}}/g, size[1] ) + .replace(/{{views_class}}/g, views[0]) +// .replace(/{{comments_class}}/g, comments[0]) +// .replace(/{{files_class}}/g, files[0]) +// .replace(/{{show_files}}/g, thread.file_count == 0 ? "hidden" : "") +// .replace(/{{size_class}}/g, size[0] ) + .replace(/{{color}}/g, thread.color || "blue" ) + + this.$el.append(t) + }) + $("body").removeClass('loading') + }, + +})
\ No newline at end of file diff --git a/public/assets/js/util/format.js b/public/assets/js/util/format.js index e58928e..5002899 100644 --- a/public/assets/js/util/format.js +++ b/public/assets/js/util/format.js @@ -8,10 +8,11 @@ document.body.classList.add(is_desktop ? 'desktop' : 'mobile'); function csrf() { return $("[name=_csrf]").attr("value") } -function commatize (n) { +function commatize (n, radix) { + radix = radix || 1024 var nums = [], i, counter = 0, r = Math.floor - if (n > 1024) { - n /= 1024 + if (n > radix) { + n /= radix nums.unshift(r((n * 10) % 10)) nums.unshift(".") } @@ -82,7 +83,7 @@ function carbon_date (date, no_bold) { } function hush_views (n, bias, no_bold) { - var txt = commatize(n) + var txt = commatize(n, 1000) bias = bias || 1 n = n || 0 if (n < 30) { return["quiet", n + " v."] } @@ -90,11 +91,11 @@ function hush_views (n, bias, no_bold) { else if (n < 500) { return ["quiet", txt + " v."] } else if (n < 1000) { return ["old", txt + " v."] } else if (n < 5000) { return ["med", txt + " kv."] } - else if (nobold || n < 10000) { return ["recent", txt + " kv."] } + else if (no_bold || n < 10000) { return ["recent", txt + " kv."] } else { return ["new", txt + " kv."] } } -function hush_size (n, bias, nobold) { +function hush_size (n, bias, no_bold) { var txt = commatize(Math.floor(n / 1024)) bias = 1 || bias n = n || 0 @@ -113,7 +114,7 @@ function hush_size (n, bias, nobold) { else if (n < (80000000/bias)) { return ["med", txt + " mb."] } - else if (nobold || n < (170000000/bias)) { + else if (no_bold || n < (170000000/bias)) { return ["recent", txt + " mb."] } else { |
