diff options
| author | pep <yes@peepee.me> | 2020-07-21 20:46:56 +0000 |
|---|---|---|
| committer | pep <yes@peepee.me> | 2020-07-21 20:46:56 +0000 |
| commit | 97bee7fe1a48acb4c34e207863af56894c198151 (patch) | |
| tree | 7a03bacd383319f2e4af70beb57ff0f9ae31b010 /public/assets/js/lib/views | |
| parent | d93c099733afff27fbf7c172a40eca87519d38b7 (diff) | |
| parent | 8a3178339ad407ec85ef0cd014a6ad13bfb4cadd (diff) | |
attempt at merge
Diffstat (limited to 'public/assets/js/lib/views')
| -rw-r--r-- | public/assets/js/lib/views/details/comments.js | 8 | ||||
| -rw-r--r-- | public/assets/js/lib/views/details/files.js | 5 | ||||
| -rw-r--r-- | public/assets/js/lib/views/keywords/keywords.js | 13 | ||||
| -rw-r--r-- | public/assets/js/lib/views/users/users.js | 88 |
4 files changed, 106 insertions, 8 deletions
diff --git a/public/assets/js/lib/views/details/comments.js b/public/assets/js/lib/views/details/comments.js index b1c86bb..1e8d127 100644 --- a/public/assets/js/lib/views/details/comments.js +++ b/public/assets/js/lib/views/details/comments.js @@ -14,8 +14,8 @@ var CommentsView = FormView.extend({ this.$formRow = this.$("#comment_form") }, - load: function(comments, thread){ -console.log(comments) + load: function(comments, thread) { + // console.log(comments) thread = this.thread = thread || this.thread if (thread.settings.hootbox) { comments @@ -35,13 +35,13 @@ console.log(comments) } }, - parse: function(comment){ + parse: function(comment) { if (! comment.comment.length) return $('') var datetime = verbose_date(comment.date, true) var t = this.template.replace(/{{image}}/g, profile_image(comment.username)) .replace(/{{username}}/g, comment.username) .replace(/{{id}}/g, comment.id) - .replace(/{{comment}}/g, tidy_urls(comment.comment)) + .replace(/{{comment}}/g, function(){ return tidy_urls(comment.comment) }) .replace(/{{date}}/g, datetime[0]) .replace(/{{time}}/g, datetime[1]) var $t = $(t) diff --git a/public/assets/js/lib/views/details/files.js b/public/assets/js/lib/views/details/files.js index 44c65c4..98b9350 100644 --- a/public/assets/js/lib/views/details/files.js +++ b/public/assets/js/lib/views/details/files.js @@ -171,10 +171,15 @@ var FilesView = FormView.extend({ if (dateClass && this.reverse) { dateClass += ' italic' } + var sizeClass = this.sort === 'size' ? 'bold' : '' + if (sizeClass && this.reverse) { + sizeClass += ' italic' + } var t = this.templateTotal.replace(/{{size_class}}/g, size[0]) .replace(/{{size}}/g, size[1]) .replace(/{{nameClass}}/g, nameClass) .replace(/{{dateClass}}/g, dateClass) + .replace(/{{sizeClass}}/g, sizeClass) this.$el.append(t) }, diff --git a/public/assets/js/lib/views/keywords/keywords.js b/public/assets/js/lib/views/keywords/keywords.js index 12bd5a8..c5a9491 100644 --- a/public/assets/js/lib/views/keywords/keywords.js +++ b/public/assets/js/lib/views/keywords/keywords.js @@ -19,16 +19,21 @@ var KeywordsView = View.extend({ populate: function(data){ // console.log(data) var keywordThreads = {} - data.threadGroups.forEach(kw => { + var keywordStats = {} + data.threads.forEach(kw => { keywordThreads[kw.keyword] = kw }) + data.threadGroups.forEach(kw => { + keywordStats[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: '', + } + var stats = keywordStats[keyword.keyword.toLowerCase()] || { } // { // keyword: "warez", @@ -38,9 +43,9 @@ var KeywordsView = View.extend({ // lastmodified: 1192401724 // }, // console.log(keyword, thread) - var viewed = thread['sum(`viewed`)'] + var viewed = stats['sum(`viewed`)'] var views = viewed ? hush_views(viewed) : ['',''] - var threadCountNum = thread['count(*)'] + var threadCountNum = stats['count(*)'] var threadCount = threadCountNum ? hush_threads(threadCountNum) : ['',''] var dot = privacy_dot(thread.privacy) var datetime = verbose_date(keyword.createdate) diff --git a/public/assets/js/lib/views/users/users.js b/public/assets/js/lib/views/users/users.js new file mode 100644 index 0000000..b7e6450 --- /dev/null +++ b/public/assets/js/lib/views/users/users.js @@ -0,0 +1,88 @@ +var UsersView = View.extend({ + + el: "#user_list", + + events: { + }, + + action: "/api/users", + + initialize: function(opt){ + opt = opt || {} + this.showAll = !!opt.all + this.template = this.$(".template").html() + this.form = new NewKeywordForm ({ parent: this }) + if (!this.showAll) { + $('.all_link').attr('href', '/users/all').html('Show all users') + } else { + $('.all_link').attr('href', '/users').html('Show active users') + } + }, + + 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 + // }) + var showAll = this.showAll + var userStats = data.userStats + data.users + // .map(a => [parseInt((keywordThreads[a.keyword] || {})['sum(`viewed`)']) || 0, a]) + // .sort((b,a) => cmp(a[0], b[0])) + // .map(a => a[1]) + .map(user => { + // var user = users[user.username.toLowerCase()] || return + // var viewed = thread['sum(`viewed`)'] + // var views = viewed ? hush_views(viewed) : ['',''] + // var threadCountNum = thread['count(*)'] + // var threadCount = threadCountNum ? hush_threads(threadCountNum) : ['',''] + // "id", "username", "realname", "firstseen", "lastseen", + // "location", "website", "avatar", + var stats = userStats[user.username] || {} + if (!showAll && !stats.threads && !stats.files && !stats.comments) { + return + } + var threadCount = stats.threads ? hush_threads(stats.threads) : ['',''] + var fileCount = stats.files ? hush_null(stats.files, 'f') : ['',''] + var fileSize = stats.files ? hush_size(stats.fileSize) : ['',''] + var commentCount = stats.comments ? hush_null(stats.comments, 'c') : ['',''] + var firstseen_datetime = verbose_date(user.firstseen) + var lastseen = get_age(user.lastseen, true) + var avatar = profile_image(user.username) + var t = this.template + .replace(/{{username}}/g, sanitizeHTML(user.username)) + .replace(/{{id}}/g, user.id) + .replace(/{{avatar}}/g, user.avatar) + .replace(/{{location}}/g, sanitizeHTML(user.location)) + .replace(/{{realname}}/g, sanitizeHTML(user.realname)) + .replace(/{{firstseen_date}}/g, firstseen_datetime[0]) + .replace(/{{firstseen_time}}/g, firstseen_datetime[1]) + .replace(/{{firstseen_date_class}}/g, carbon_date(user.firstseen) ) + .replace(/{{lastseen}}/g, lastseen ) + .replace(/{{lastseen_date_class}}/g, carbon_date(lastseen) ) + .replace(/{{threadcount}}/, threadCount[1]) + .replace(/{{threadcount_class}}/, threadCount[0]) + .replace(/{{filecount}}/, fileCount[1]) + .replace(/{{filecount_class}}/, fileCount[0]) + .replace(/{{filesize}}/, fileSize[1]) + .replace(/{{filesize_class}}/, fileSize[0]) + .replace(/{{commentcount}}/, commentCount[1]) + .replace(/{{commentcount_class}}/, commentCount[0]) + var $t = $(t) + if (!user.firstseen) { + $t.find('.date').html('') + } + // if (!user.avatar) { + // $t.find('.avatar').addClass('hidden') + // } + this.$el.append($t) + }) + $("body").removeClass('loading') + }, + +}) |
