comparison s4-main.js @ 1037:634fee6a6bd2 draft

Add row number to title attribute after sort.
author HIROSE Yuuji <yuuji@gentei.org>
date Wed, 06 Mar 2024 09:55:20 +0900
parents 9c392ddb4d8a
children 78e904f9be34
comparison
equal deleted inserted replaced
1036:9c392ddb4d8a 1037:634fee6a6bd2
998 if (a.key2 > b.key2) return 1; 998 if (a.key2 > b.key2) return 1;
999 return 0; 999 return 0;
1000 } 1000 }
1001 sbtn.addEventListener("click", (e)=>{ 1001 sbtn.addEventListener("click", (e)=>{
1002 let uidsort = (sbtn.textContent.indexOf(umode) >= 0); 1002 let uidsort = (sbtn.textContent.indexOf(umode) >= 0);
1003 let rows = [], elm, 1003 let rows = [], elm, i=0,
1004 tbl = document.querySelector("table.blog_replies"); 1004 tbl = document.querySelector("table.blog_replies");
1005 for (let tr of tbl.rows) { 1005 for (let tr of tbl.rows) {
1006 elm = {}; 1006 elm = {};
1007 elm.tr = tr; 1007 elm.tr = tr;
1008 elm.key1 = tr.querySelector("a.author").title; // userid 1008 elm.key1 = tr.querySelector("a.author").title; // userid
1009 tr.innerHTML.match(/<a href="(#[0-9]+)">\1</); // ArticleID 1009 tr.innerHTML.match(/<a href="(#[0-9]+)">\1</); // ArticleID
1010 elm.key2 = RegExp.$1; 1010 elm.key2 = RegExp.$1;
1011 rows.push(elm); 1011 rows.push(elm);
1012 } 1012 }
1013 rows.sort(uidsort ? compareRowsByUid : compareRowsByAid); 1013 rows.sort(uidsort ? compareRowsByUid : compareRowsByAid);
1014 for (let r of rows) tbl.appendChild(r.tr); 1014 for (let r of rows) {
1015 tbl.appendChild(r.tr);
1016 r.tr.title = ++i;
1017 }
1015 sbtn.textContent = uidsort ? amode : umode; 1018 sbtn.textContent = uidsort ? amode : umode;
1016 }); 1019 });
1017 } 1020 }
1018 } 1021 }
1019 function initGrpAction() { 1022 function initGrpAction() {

yatex.org