Skip to content

Commit

Permalink
code: update js for memories
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Lord committed Nov 10, 2023
1 parent 2538b4c commit 1d0ad72
Showing 1 changed file with 102 additions and 56 deletions.
158 changes: 102 additions & 56 deletions memories.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,62 +133,6 @@ id: page-memories
| **传说之下** & **三角符文** | 英语:**UNDERTALE** & **DELTARUNE** | 游戏 | 8 | meta 元素应用最知名的作品吧,可惜本人并没有很好的理解其内涵,只能给出这个分数了,最欣赏的是其游戏性上的创新 | 201x |
| **我的世界** | 英语:**Minecraft** | 游戏 | 10 | 真正的开放世界,没有任何固定的流程;高度的自动化与自定义化。退坑前应该有几千小时游戏时长了吧…… | 201[3-6] |

<script>
//来自 https://blog.csdn.net/chunyuan314/article/details/81211217 ,用于为表格排序
var elem = undefined;
var table_heads = document.getElementsByTagName("th");
var need_sort = [];
for(var i=0;i<table_heads.length;i+=1){
if(["评分","名字","类别"].indexOf(table_heads[i].innerText)!==-2){need_sort.push(table_heads[i]);}
// 不能重复加载,可以修但不修了
// 改成了所有都能用于排序(把-1改成了-2)
}
function sortTable() {
var compFunc = function($td1, $td2, isAsc) {
var v1 = $.trim($td1.text()).replace(/,|\s+|%/g, '');
var v2 = $.trim($td2.text()).replace(/,|\s+|%/g, '');
var pattern = /^\d+(\.\d*)?$/;
if (pattern.test(v1) && pattern.test(v2)) {
v1 = parseFloat(v1);
v2 = parseFloat(v2);
}
return isAsc ? v1 > v2 : v1 < v2;
};
var doSort = function($tbody, index, compFunc, isAsc)
{
var $trList = $tbody.find("tr");
var len = $trList.length;
for(var i=0; i<len-1; i++) {
for(var j=0; j<len-i-1; j++) {
var $td1 = $trList.eq(j).find("td").eq(index);
var $td2 = $trList.eq(j+1).find("td").eq(index);
if (compFunc($td1, $td2, isAsc)) {
var t = $trList.eq(j+1);
$trList.eq(j).insertAfter(t);
$trList = $tbody.find("tr");
}
}
}
}
var init = function(elem) {
var $th = $(elem);
this.$table = $th.closest("table");
var that = this;
$th.click(function(){
var index = $(this).index();
var asc = $(this).attr('data-asc');
isAsc = asc === undefined ? true : (asc > 0 ? true : false);
doSort(that.$table.find("tbody"), index, compFunc, isAsc);
$(this).attr('data-asc', 1 - (isAsc ? 1 : 0));
});
$th.css({'cursor': 'pointer'})
.attr('title', '点击以'+elem.innerText+'为依据排序');
};
need_sort.forEach(function(item){init(item)});
}
window.Lazyload.js(window.TEXT_VARIABLES.sources.jquery, function(){sortTable();})
</script>

电子设备记录:

总配置格式:A+B。A代表存储空间,B代表运行内存大小。如果有扩展的,则以`(基础+扩展)`表示。默认单位为GB,也可特殊标识单位。
Expand All @@ -208,3 +152,105 @@ window.Lazyload.js(window.TEXT_VARIABLES.sources.jquery, function(){sortTable();
| / | 酷派 | 手机 | / | / | / | × | × || × | Micro USB | / ||
| 清华同方超锐 T43 | 清华同方 | 电脑 | / | 2022前 ~ 至今 | 目前把SSD划出一块装Deepin作日用机。电池废了。 | / | / ||| 专用圆口 | 256+4 | 人脸 |
| 联想昭阳E53-80 | 联想 | 电脑 | / | 2021前 ~ 至今 | Win10 + Ubuntu双系统。Windows下风扇总是异常响。额外安装了256G的SSD与4G的内存条。 | / | / ||| 专用方口、Type-C | (256+1024)+(4+4) ||

<script>
// 来自 https://blog.csdn.net/chunyuan314/article/details/81211217 ,用于为表格排序
(function() {
var elem = undefined;
var table_heads = document.getElementsByTagName("th");
var need_sort = [];
for (var i = 0; i < table_heads.length; i += 1) {
if (["评分", "名字", "类别"].indexOf(table_heads[i].innerText) !== -2) {
need_sort.push(table_heads[i]);
}
// 不能重复加载,可以修但不修了
// 改成了所有都能用于排序(把-1改成了-2)
}

function sortTable() {
var compFunc = function($td1, $td2, isAsc) {
var v1 = $.trim($td1.text())
.replace(/,|\s+|%/g, '');
var v2 = $.trim($td2.text())
.replace(/,|\s+|%/g, '');
var pattern = /^\d+(\.\d*)?$/;
if (pattern.test(v1) && pattern.test(v2)) {
v1 = parseFloat(v1);
v2 = parseFloat(v2);
}
return isAsc ? v1 > v2 : v1 < v2;
};
var doSort = function($tbody, index, compFunc, isAsc) {
var $trList = $tbody.find("tr");
var len = $trList.length;
for (var i = 0; i < len - 1; i++) {
for (var j = 0; j < len - i - 1; j++) {
var $td1 = $trList.eq(j)
.find("td")
.eq(index);
var $td2 = $trList.eq(j + 1)
.find("td")
.eq(index);
if (compFunc($td1, $td2, isAsc)) {
var t = $trList.eq(j + 1);
$trList.eq(j)
.insertAfter(t);
$trList = $tbody.find("tr");
}
}
}
}
var init = function(elem) {
var $th = $(elem);
this.$table = $th.closest("table");
var that = this;
$th.click(function() {
var index = $(this)
.index();
var asc = $(this)
.attr('data-asc');
isAsc = asc === undefined ? true : (asc > 0 ? true : false);
doSort(that.$table.find("tbody"), index, compFunc, isAsc);
$(this)
.attr('data-asc', 1 - (isAsc ? 1 : 0));
});
$th.css({
'cursor': 'pointer'
})
.attr('title', '点击以' + elem.innerText + '为依据排序');
};
need_sort.forEach(function(item) {
init(item)
});
}
window.Lazyload.js(window.TEXT_VARIABLES.sources.jquery, function() {
sortTable();
})
})()
</script>

<script>
// 用于根据URL中的hash跳转
(function() {
var hash = window.location.hash;
if (typeof hash !== 'string') {
return;
}
hash = hash.slice(1); // 去掉 #
if (hash.length === 0) {
return;
}
Array.from(document.getElementsByTagName("tbody"))
.forEach((tbody) => {
Array.from(tbody.children)
.forEach((tr) => {
text_element = tr.children[0];
if (text_element.innerText.indexOf(hash) === 0) {
text_element.scrollIntoView({
block: 'center'
});
}
})
})
})()
</script>

0 comments on commit 1d0ad72

Please sign in to comment.