編集の要約なし タグ: mobile web edit mobile edit |
編集の要約なし |
||
| 9行目: | 9行目: | ||
overflow: hidden; | overflow: hidden; | ||
} | } | ||
#chart_div .tab { | #chart_div .tab { | ||
margin: 0; | margin: 0; | ||
| 15行目: | 16行目: | ||
overflow: hidden; | overflow: hidden; | ||
} | } | ||
#chart_div .tab li { | #chart_div .tab li { | ||
display: block; | display: block; | ||
| 22行目: | 24行目: | ||
background-color: #aca6e4; | background-color: #aca6e4; | ||
} | } | ||
#chart_div .tab a { | #chart_div .tab a { | ||
color: white; | color: white; | ||
} | } | ||
#chart_div .tab a.selected { | #chart_div .tab a.selected { | ||
font-weight: bold; | font-weight: bold; | ||
cursor: text; | cursor: text; | ||
} | } | ||
#chart_div .tab a.selected:hover { | #chart_div .tab a.selected:hover { | ||
text-decoration: none; | text-decoration: none; | ||
| 39行目: | 44行目: | ||
margin: 1rem 0; | margin: 1rem 0; | ||
} | } | ||
#chart_div .time { | #chart_div .time { | ||
width: 3rem; | width: 3rem; | ||
} | } | ||
#chart_div .pageview { | #chart_div .pageview { | ||
width: 2.5rem; | width: 2.5rem; | ||
} | } | ||
#chart_div td.time { | #chart_div td.time { | ||
text-align: right; | text-align: right; | ||
font-size: 0.8rem; | font-size: 0.8rem; | ||
} | } | ||
#chart_div td.pageview { | #chart_div td.pageview { | ||
text-align: right; | text-align: right; | ||
font-size: 0.8rem; | font-size: 0.8rem; | ||
} | } | ||
#chart_div td.page { | #chart_div td.page { | ||
text-overflow: ellipsis; | text-overflow: ellipsis; | ||
| 59行目: | 69行目: | ||
white-space: nowrap; | white-space: nowrap; | ||
} | } | ||
#chart_div th, | #chart_div th, | ||
#chart_div td { | #chart_div td { | ||
border: 1px solid #ddd; | border: 1px solid #ddd; | ||
} | } | ||
#chart_div th.selectable { | #chart_div th.selectable { | ||
cursor: pointer; | cursor: pointer; | ||
} | } | ||
#chart_div th.selected { | #chart_div th.selected { | ||
background-image: url("/resources/src/jquery.tablesorter.styles/images/sort_down.png"); | background-image: url("/resources/src/jquery.tablesorter.styles/images/sort_down.png"); | ||
| 82行目: | 95行目: | ||
<!--Load the AJAX API--> | <!--Load the AJAX API--> | ||
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
var period = "daily", | var period = "daily", | ||
orderBy = "time"; | orderBy = "time"; | ||
prepareChart(); | prepareChart(); | ||
function prepareChart() { | function prepareChart() { | ||
var sheetName = | var sheetName = | ||
| 96行目: | 110行目: | ||
"&headers=15"; | "&headers=15"; | ||
google.charts.load("current", { packages: ["corechart"] }); | google.charts.load("current", {packages: ["corechart"]}); | ||
google.charts.setOnLoadCallback(drawChart); | google.charts.setOnLoadCallback(drawChart); | ||
| 120行目: | 134行目: | ||
</tr> | </tr> | ||
</thead> | </thead> | ||
<tbody> | <tbody> | ||
`]; | `]; | ||
for (var i = 0; i < rows; i++) { | for (var i = 0; i < rows; i++) { | ||
| 146行目: | 160行目: | ||
document | document | ||
.getElementById("hourly") | .getElementById("hourly") | ||
.addEventListener("click", function() { | .addEventListener("click", function () { | ||
if (period === "hourly") return; | if (period === "hourly") return; | ||
period = "hourly"; | period = "hourly"; | ||
| 153行目: | 167行目: | ||
document | document | ||
.getElementById("daily") | .getElementById("daily") | ||
.addEventListener("click", function() { | .addEventListener("click", function () { | ||
if (period === "daily") return; | if (period === "daily") return; | ||
period = "daily"; | period = "daily"; | ||
| 160行目: | 174行目: | ||
document | document | ||
.getElementById("header-time") | .getElementById("header-time") | ||
.addEventListener("click", function() { | .addEventListener("click", function () { | ||
if (orderBy === "time") return; | if (orderBy === "time") return; | ||
orderBy = "time"; | orderBy = "time"; | ||
| 167行目: | 181行目: | ||
document | document | ||
.getElementById("header-pageview") | .getElementById("header-pageview") | ||
.addEventListener("click", function() { | .addEventListener("click", function () { | ||
if (orderBy === "pageview") return; | if (orderBy === "pageview") return; | ||
orderBy = "pageview"; | orderBy = "pageview"; | ||
| 178行目: | 192行目: | ||
return title | return title | ||
.split("/") | .split("/") | ||
.map(function(path) { | .map(function (path) { | ||
return encodeURIComponent(path); | return encodeURIComponent(path); | ||
}) | }) | ||
.join("/"); | .join("/"); | ||
} | |||
</script> | </script> | ||
</head> | </head> | ||
2020年9月7日 (月) 07:19時点における版
<html lang="ja"> <head>
<style>
#chart_div {
margin: 0;
height: 100%;
min-height: 38em;
overflow: hidden;
}
#chart_div .tab {
margin: 0;
padding: 0;
display: block;
overflow: hidden;
}
#chart_div .tab li {
display: block;
float: left;
width: 50%;
text-align: center;
background-color: #aca6e4;
}
#chart_div .tab a {
color: white;
}
#chart_div .tab a.selected {
font-weight: bold;
cursor: text;
}
#chart_div .tab a.selected:hover {
text-decoration: none;
}
#chart_div table {
width: 100%;
border-collapse: collapse;
border-spacing: 0;
margin: 1rem 0;
}
#chart_div .time {
width: 3rem;
}
#chart_div .pageview {
width: 2.5rem;
}
#chart_div td.time {
text-align: right;
font-size: 0.8rem;
}
#chart_div td.pageview {
text-align: right;
font-size: 0.8rem;
}
#chart_div td.page {
text-overflow: ellipsis;
max-width: 0;
overflow: hidden;
white-space: nowrap;
}
#chart_div th,
#chart_div td {
border: 1px solid #ddd;
}
#chart_div th.selectable {
cursor: pointer;
}
#chart_div th.selected {
background-image: url("/resources/src/jquery.tablesorter.styles/images/sort_down.png");
cursor: auto;
background-repeat: no-repeat;
background-position: center right 0.2rem;
}
@media only screen and (max-width: 993px) {
#chart_div > table > thead > tr {
width: 80%;
}
}
</style> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> var period = "daily", orderBy = "time"; prepareChart();
function prepareChart() {
var sheetName =
period +
" " +
(orderBy === "time" ? "longest time spent" : "most viewed");
var url =
"https://docs.google.com/spreadsheets/d/1niIGejZ1Czrkj07hGDPleVvk9AEBaDtjr55n63GluLw/gviz/tq?sheet=" +
sheetName +
"&headers=15";
google.charts.load("current", {packages: ["corechart"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var query = new google.visualization.Query(url);
query.send(handleQueryResponse);
}
function handleQueryResponse(response) {
var data = response.getDataTable();
var rows = data.getNumberOfRows();
var html = [`
- <a id="hourly" class="${period === "hourly" ? "selected" : ""}" href="javascript: void(0);">リアルタイム</a>
- <a id="daily" class="${period === "daily" ? "selected" : ""}" href="javascript: void(0);">一日</a>
`, `
<thead> </thead> <tbody> `]; for (var i = 0; i < rows; i++) { try { var title = data.getValue(i, 0).replace(" - 宇宙wiki", ""); var time = Math.round(data.getValue(i, 1) / 60) + "分"; var pageview = data.getValue(i, 2); var url = "/w/" + encodeTitle(title); var anchor = `<a href="${url}" target="_parent" title="${title}">${title}</a>`; html.push(` `); } catch (e) { console.log([i, e]); } } html.push("</tbody>| 時間 | PV | ページ |
|---|---|---|
| ${time} | ${pageview} | ${anchor} |
");
document.querySelector("#chart_div").innerHTML = html.join();
document
.getElementById("hourly")
.addEventListener("click", function () {
if (period === "hourly") return;
period = "hourly";
prepareChart();
});
document
.getElementById("daily")
.addEventListener("click", function () {
if (period === "daily") return;
period = "daily";
prepareChart();
});
document
.getElementById("header-time")
.addEventListener("click", function () {
if (orderBy === "time") return;
orderBy = "time";
prepareChart();
});
document
.getElementById("header-pageview")
.addEventListener("click", function () {
if (orderBy === "pageview") return;
orderBy = "pageview";
prepareChart();
});
}
}
function encodeTitle(title) {
return title
.split("/")
.map(function (path) {
return encodeURIComponent(path);
})
.join("/");
}
</script>
</head> <body>
</body> </html>