Change: sort suggest
This commit is contained in:
		| @@ -170,4 +170,29 @@ $.mb_substr = function (str, begin, end) { | |||||||
| 	} | 	} | ||||||
| 	return ret; | 	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"); | localStorage.removeItem("errors"); | ||||||
| @@ -85,16 +85,34 @@ input.addEventListener("focus", function () { | |||||||
| 					//ハッシュタグ | 					//ハッシュタグ | ||||||
| 					if (json.hashtags[0] && tag) { | 					if (json.hashtags[0] && tag) { | ||||||
| 						if (tag[1]) { | 						if (tag[1]) { | ||||||
| 							var tags = ""; | 							var tags = []; | ||||||
| 							Object.keys(json.hashtags).forEach(function (key4) { | 							Object.keys(json.hashtags).forEach(function (key4) { | ||||||
| 								var tag = json.hashtags[key4]; | 								var tag = json.hashtags[key4]; | ||||||
| 								var his = tag.history; | 								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; | 								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">#' + | 								tagHTML = '<br><a onclick="tagInsert(\'#' + escapeHTML(tag.name) + '\',\'#' + q + '\')" class="pointer">#' + | ||||||
| 									escapeHTML(tag.name) + '</a> ' + uses + 'toots' | 									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() | 							$("#right-side").show() | ||||||
| 							$("#suggest").html(tags); |  | ||||||
| 							$("#poll").addClass("hide") | 							$("#poll").addClass("hide") | ||||||
| 							$("#emoji").addClass("hide") | 							$("#emoji").addClass("hide") | ||||||
| 						} | 						} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	