CISTポータルで現在閲覧中のタブをクリックできるようにする
連絡 / 予定 / 授業ページ / アンケート
URLを決め打ち可能
たとえば連絡タブには /ViewUnReadTitles を設定する
この3つのページは複数の画面遷移を伴う
画面遷移の起点である /ViewUnReadTitlesなどにワンクリックで戻りたいという考えがある
配布物
URLを決め打ちできない
このタブについても、現在タブをクリックできないのは驚き最小の原則に反すると感じるt6o_o6t.icon タブのクリック操作がdisabledならば、それをスタイルで表すべきである
現在のURLをそのままセットすれば問題ない
画面遷移を伴わないため
給与明細 / 希望調査
配布物と同様の処置を行う
厳密には、配布物と異なり画面遷移を伴うため望ましくない
a.href |=
code:clickable.js
const getRootChildrenURL = (name) => {
const origin = new URL(document.URL).origin;
const url = new URL(name, origin);
return url;
}
const functionsGetAlternativeHref = {
"MyPage": () => getRootChildrenURL("MyPage"),
"連絡": () => getRootChildrenURL("ViewUnReadTitles"),
"予定": () => getRootChildrenURL("MonthlyScheduleViewer"),
"授業": () => getRootChildrenURL("CoursesForUser"),
"配布物": () => document.URL,
"給与明細": () => document.URL,
"アンケート": () => getRootChildrenURL("QuestionnaireTopPage"),
"希望調査": () => document.URL
}
const main = () => {
const tabAElements = document.querySelectorAll(".mainMenu > .tabMenu > li > a");
tabAElements.forEach(a => {
const getAlternativeHref = functionsGetAlternativeHrefa.textContent; if (!getAlternativeHref) return;
const alternativeHref = getAlternativeHref();
a.href ||= alternativeHref;
});
}
|=を間違えて使ったことで、hrefがhttps://.../0となった
hrefに非URLな文字列を格納すると、root直下のパスとして認識される?
そうではなく、index.htmlなどを直接書くのと同じことではないか?
参考