-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
90 lines (84 loc) · 3.43 KB
/
Copy pathscript.js
File metadata and controls
90 lines (84 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
'use strict';
console.log('ほろっほぅ')
const changeTable = () => {
// ボタンの辞書
const button = {};
for (let i = 0; i < 5; i++) {
let week = "";
switch (i) {
case 0:
week = "mon_";
break
case 1:
week = "tue_";
break
case 2:
week = "wed_";
break
case 3:
week = "thu_";
break
case 4:
week = "fri_";
break
}
for (let j = 0; j < 5; j++) {
const period = (j + 1).toString();
button[week + period] = " ".repeat(20);// "nullnullうなぎ";
}
}
// ボタンの集合が入っているidを指定
const topnav = document.getElementById("topnav");
// ボタンの集合を取る.
const links = topnav.getElementsByClassName('link-container');
// ボタン集合を精査する.
for (let i = 0; i < links.length; i++) {
const title = links.item(i).title;
const chrToRemove = "限";
const removedTitle = title.split(chrToRemove).join("");
const classifier = jpn2eng(removedTitle.substr(-3).substr(0, 2));
const classifier2 = jpn2eng(removedTitle.substr(-5).substr(0, 2)); // 画像処理対策
// console.log(classifier)
// if () {
// console.log(title)
// classifier = jpn2eng(removedTitle.substr(-5).substr(0, 2));
// }
const tagBtnName = title.replace(/(\(|().+$/, "")
const tag = "<a href=" + links.item(i).href + ">" + "<span>" + tagBtnName + "</span>" + "</a>"
button[classifier] = tag;
button[classifier2] = tag;
}
console.log(button)
topnav.innerHTML = makeTable(button);
console.log(button)
}
const makeTable = (button) => {
const headTable = "<table><tr><th>月曜日</th><th>火曜日</th><th>水曜日</th><th>木曜日</th><th>金曜日</th></tr>";
const firstTable = "<tr><td>" + button.mon_1 + "</td><td>" + button.tue_1 + "</td><td>" + button.wed_1 + "</td><td>" + button.thu_1 + "</td><td>" + button.fri_1 + "</td></tr>";
const secondTable = "<tr><td>" + button.mon_2 + "</td><td>" + button.tue_2 + "</td><td>" + button.wed_2 + "</td><td>" + button.thu_2 + "</td><td>" + button.fri_2 + "</td></tr>";
const thirdTable = "<tr><td>" + button.mon_3 + "</td><td>" + button.tue_3 + "</td><td>" + button.wed_3 + "</td><td>" + button.thu_3 + "</td><td>" + button.fri_3 + "</td></tr>";
const fourthTable = "<tr><td>" + button.mon_4 + "</td><td>" + button.tue_4 + "</td><td>" + button.wed_4 + "</td><td>" + button.thu_4 + "</td><td>" + button.fri_4 + "</td></tr>";
const fifthTable = "<tr><td>" + button.mon_5 + "</td><td>" + button.tue_5 + "</td><td>" + button.wed_5 + "</td><td>" + button.thu_5 + "</td><td>" + button.fri_5 + "</td></tr>";
return headTable + firstTable + secondTable + thirdTable + fourthTable + fifthTable
}
const jpn2eng = (str) => {
const jpnMap = {
"1": "1",
"2": "2",
"3": "3",
"4": "4",
"5": "5",
"月": "mon_",
"火": "tue_",
"水": "wed_",
"木": "thu_",
"金": "fri_",
"土": "sat_",
}
const reg = new RegExp('(' + Object.keys(jpnMap).join('|') + ')', 'g');
return str
.replace(reg, function (match) {
return jpnMap[match];
})
};
changeTable();