和 Codex 一块儿搓了个新前端 hu60next
<script>// 检测并转换楼层数字为链接
(function() {
var containers = document.querySelectorAll('.floor-content.comments-content.user-content, .floor_content.user-content');
if (!containers.length) return;
var baseUrl = window.location.href.split('?')[0].split('#')[0];
var processed = new Set();
function walk(node) {
if (node.nodeType === 3) {
var text = node.nodeValue;
var regex = /(?:^|\s| )#(\d+)(?=\s| |$)/g;
var match, lastIndex = 0, parts = [], found = false;
while ((match = regex.exec(text)) !== null) {
var num = match[1];
if (processed.has(num)) continue;
processed.add(num);
found = true;
if (match.index > lastIndex) parts.push(text.substring(lastIndex, match.index));
var link = document.createElement('a');
link.href = baseUrl + '?floor=' + num + '#' + num;
link.textContent = ' #' + num;
parts.push(link);
lastIndex = match.index + match[0].length;
}
if (found) {
if (lastIndex < text.length) parts.push(text.substring(lastIndex));
var fragment = document.createDocumentFragment();
parts.forEach(function(part) {
fragment.appendChild(typeof part === 'string' ? document.createTextNode(part) : part);
});
node.parentNode.replaceChild(fragment, node);
}
} else if (node.nodeType === 1 && node.tagName !== 'A' && node.tagName !== 'SCRIPT') {
Array.from(node.childNodes).forEach(walk);
}
}
containers.forEach(function(container) {
Array.from(container.childNodes).forEach(walk);
});
})();
</script>
新版的帖子页面,相关管理人员无法对其进行修改,删除等操作。
这就有点麻烦。
评论区也一样
手机版没有搜索框,菜单里也没有
还有,你们觉得翻页的过渡动画观感好吗?我不太喜欢,运动速度太快让人眼花缭乱,而且帖子内容多的话用时也很久,不如直接一步到位跳转到应该去的位置。
关键是运动的次数太多了,随便做点什么就一直滚来滚去:
明明点了输入框末尾,但是上传的附件却出现在了开头。
解决方法请参考以下代码(在找不到编辑点的时候应该追加到末尾而非开头):
function insertText(obj, str) {
if (document.selection) {
var sel = document.selection.createRange();
sel.text = str;
} else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') {
var startPos = obj.selectionStart,
endPos = obj.selectionEnd,
cursorPos = startPos,
tmpStr = obj.value;
obj.value = tmpStr.substring(0, startPos) + str + tmpStr.substring(endPos, tmpStr.length);
cursorPos += str.length;
obj.selectionStart = obj.selectionEnd = cursorPos;
} else {
obj.value += str;
}
}
由于快速翻页器的缺失,我现在只能通过修改URL来快速回到第一页
