diff s4-main.js @ 1003:5bd1b5125049 draft

Direct link to lshandoutall in group home for grp-admin
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 11 Dec 2022 17:19:32 +0859
parents 47b3e770372d
children 1ffaa8b2b1bf
line wrap: on
line diff
--- a/s4-main.js	Sun Dec 04 16:59:59 2022 +0859
+++ b/s4-main.js	Sun Dec 11 17:19:32 2022 +0859
@@ -1189,6 +1189,24 @@
 	else
 	    rewriteReplyHover();
     }
+    var getHandoutCSV;
+    function initGetHandoutCSV() {
+	getHandoutCSV = document.getElementById("gethandoutcsv");
+	if (!getHandoutCSV) return;
+	document.getElementById("bommsg").innerText =
+	    `Excelで開く場合は上記CSVリンクをCtrlを押しながら。
+You need to click CSV link above with Ctrl-key when you handle CSV with Excel`;
+	getHandoutCSV.addEventListener("click", (e) => {
+	    e.preventDefault();		// Stop visiting link
+	    let bom = e.ctrlKey;
+	    let csv = document.getElementById("totalcsv");
+	    if (!csv || !csv.textContent) return;
+	    let fn = "report-count", plus=myurl.lastIndexOf("+");
+	    if (plus) fn += ("-"+myurl.substring(1+plus));
+	    fn = fn.replace(/#.*/, "");
+	    downloadFile(fn+".csv", csv.textContent, bom);
+	});
+    }
     function init() {
 	isOlderJS = !("insertAdjacentElement" in document.body);
 	initGrpAction();
@@ -1198,6 +1216,7 @@
 	initGrphome();
 	initMath();
 	initReplyHover();
+	initGetHandoutCSV();
     }
     document.addEventListener('DOMContentLoaded', init, null);
 })();

yatex.org