var UsersView = View.extend({ el: "#users_list", events: { }, action: "/api/users", initialize: function(opt){ this.template = this.$(".template").html() this.form = new NewKeywordForm ({ parent: this }) }, 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.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 create_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, sanitizeHTML(keyword.keyword)) .replace(/{{id}}/g, id) .replace(/{{username}}/g, keyword.username) .replace(/{{title}}/g, thread.title) .replace(/{{create_date}}/g, create_datetime[0]) .replace(/{{create_time}}/g, create_datetime[1]) .replace(/{{date_class}}/g, carbon_date(thread.lastmodified) ) .replace(/{{views}}/g, views[1]) .replace(/{{threadcount}}/, threadCount[1]) .replace(/{{threadcount_class}}/, threadCount[0]) // .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') }, })