Change: sort suggest
This commit is contained in:
parent
fd9c97a126
commit
7fa805fe3a
|
@ -170,4 +170,29 @@ $.mb_substr = function (str, begin, end) {
|
|||
}
|
||||
return ret;
|
||||
};
|
||||
//ソートするやつ
|
||||
function object_array_sort(data, key, order, fn) {
|
||||
var num_a = -1;
|
||||
var num_b = 1;
|
||||
if (order === 'asc') {
|
||||
num_a = 1;
|
||||
num_b = -1;
|
||||
}
|
||||
data = data.sort(function (a, b) {
|
||||
var x = a[key];
|
||||
var y = b[key];
|
||||
if (x > y) return num_a;
|
||||
if (x < y) return num_b;
|
||||
return 0;
|
||||
});
|
||||
var arrObj = {};
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
arrObj[data[i]['family']] = data[i];
|
||||
}
|
||||
data = [];
|
||||
for (var key in arrObj) {
|
||||
data.push(arrObj[key]);
|
||||
}
|
||||
fn(data);
|
||||
}
|
||||
localStorage.removeItem("errors");
|
|
@ -85,16 +85,34 @@ input.addEventListener("focus", function () {
|
|||
//ハッシュタグ
|
||||
if (json.hashtags[0] && tag) {
|
||||
if (tag[1]) {
|
||||
var tags = "";
|
||||
var tags = [];
|
||||
Object.keys(json.hashtags).forEach(function (key4) {
|
||||
var tag = json.hashtags[key4];
|
||||
var his = tag.history;
|
||||
var uses = his[0].uses*1+ his[1].uses*1+ his[2].uses*1+ his[3].uses*1+ his[4].uses*1+ his[5].uses*1+ his[6].uses*1;
|
||||
tags = tags + '<br><a onclick="tagInsert(\'#' + escapeHTML(tag.name) + '\',\'#' + q + '\')" class="pointer">#' +
|
||||
var uses = his[0].uses * 1 + his[1].uses * 1 + his[2].uses * 1 + his[3].uses * 1 + his[4].uses * 1 + his[5].uses * 1 + his[6].uses * 1;
|
||||
tagHTML = '<br><a onclick="tagInsert(\'#' + escapeHTML(tag.name) + '\',\'#' + q + '\')" class="pointer">#' +
|
||||
escapeHTML(tag.name) + '</a> ' + uses + 'toots'
|
||||
var item = {
|
||||
"uses": uses,
|
||||
"html": tagHTML
|
||||
}
|
||||
tags.push(item)
|
||||
});
|
||||
var num_a = -1;
|
||||
var num_b = 1;
|
||||
tags = tags.sort(function (a, b) {
|
||||
var x = a["uses"];
|
||||
var y = b["uses"];
|
||||
if (x > y) return num_a;
|
||||
if (x < y) return num_b;
|
||||
return 0;
|
||||
});
|
||||
var ins = ""
|
||||
Object.keys(tags).forEach(function (key7) {
|
||||
ins = ins + tags[key7].html
|
||||
});
|
||||
$("#suggest").html(ins);
|
||||
$("#right-side").show()
|
||||
$("#suggest").html(tags);
|
||||
$("#poll").addClass("hide")
|
||||
$("#emoji").addClass("hide")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user