「Widget:人気ページ」の版間の差分

編集の要約なし
Add table-layout:fixed for mobile fix
 
(4人の利用者による、間の90版が非表示)
1行目: 1行目:
<includeonly>
<html lang="ja">
<html lang="ja">
  <head>
<head>


     <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=UTF-8">
     <style>
    <META HTTP-EQUIV="CONTENT-LANGUAGE" CONTENT="ja">
        #chart_div table {
            table-layout: fixed;
            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: center;
            font-size: 0.8rem;
        }


    <style>
        #chart_div td.page {
      #chart_div {
            text-overflow: ellipsis;
        margin: 0;
            overflow: hidden;
        height: 100%;
            white-space: nowrap;
        min-height: 38em;
         }
         overflow: hidden;
 
      }
        #chart_div th,
      #chart_div .tab {
        #chart_div td {
        margin: 0;
            border: 1px solid #ddd;
         padding: 0;
         }
         display: block;
          
         overflow: hidden;
         #chart_div th {
      }
            text-align: center;
      #chart_div .tab li {
         }
        display: block;
 
        float: left;
        #chart_div th.selectable {
        width: 50%;
            cursor: pointer;
        text-align: center;
        }
         background-color: #aca6e4;
 
      }
        #chart_div th.selected {
      #chart_div .tab a {
            cursor: auto;
        color: white;
            background-repeat: no-repeat;
      }
            background-position: center right 0.2rem;
      #chart_div .tab a.selected {
        }
        font-weight: bold;
 
        cursor: text;
        .page {
      }
            overflow: hidden;
      #chart_div .tab a.selected:hover {
    text-overflow: ellipsis;
        text-decoration: none;
    white-space: nowrap;
      }
        }


      #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;
      }
     </style>
     </style>
     <!--Load the AJAX API-->
     <!--Load the AJAX API-->
     <script
     <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></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 = "pageview";
      prepareChart();
        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"] });
         function prepareChart() {
        google.charts.setOnLoadCallback(drawChart);
            var sheetName =
                period +
                " " +
                (orderBy === "time" ? "longest time spent" : "most viewed");
            var url =
                "https://docs.google.com/spreadsheets/d/1QrIPnTnAaJSoKRy-IcWCoDylC3K8pdbfINNVFs7XEnA/gviz/tq?sheet=" +
                sheetName +
                "&headers=15";


        function drawChart() {
            google.charts.load("current", {packages: ["corechart"]});
          var query = new google.visualization.Query(url);
            google.charts.setOnLoadCallback(drawChart);
          query.send(handleQueryResponse);
 
         }
            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 = [
`<table>
    <thead bgcolor = #507f50>
        <tr>
            <th id="header-pageview" class="pageview selectable ${orderBy === "pageview" ? "selected" : ""}">PV</th>
            <th>ページ</th>
         </tr>
    </thead>
    <tbody>
                `];
                for (var i = 0; i < rows; i++) {
                    try {
                        var title = data.getValue(i, 1).replace(" - 宇宙wiki", "");
                        var pageview = data.getValue(i, 3);
                        var url = "/w/" + encodeTitle(title);
                        var anchor = `<a href="${url}" target="_parent" title="${title}">${title}</a>`;
 
                        html.push(`
<tr>
    <td class="pageview">${pageview}</td>
    <td class="page" >${anchor}</td>
</tr>
`);
                    } catch (e) {
                        console.log([i, e]);
                    }
                }
                html.push("</tbody></table>");
                document.querySelector("#chart_div").innerHTML = html.join('');


        function handleQueryResponse(response) {
                document
          var data = response.getDataTable();
                    .getElementById("hourly")
          var rows = data.getNumberOfRows();
                    .addEventListener("click", function () {
          var html = [
                        if (period === "hourly") return;
            '<ul class="tab">' +
                        period = "hourly";
              '<li><a id="hourly" class="' +
                        prepareChart();
              (period == "hourly" ? "selected" : "") +
                    });
              '" href="javascript: void(0);">リアルタイム</a></li>' +
                document
              '<li><a id="daily" class="' +
                    .getElementById("daily")
              (period == "daily" ? "selected" : "") +
                    .addEventListener("click", function () {
              '" href="javascript: void(0);">一日</a></li>' +
                        if (period === "daily") return;
              "</ul>" +
                        period = "daily";
              "<table><thead><tr>" +
                        prepareChart();
              '<th id="header-time" class="time selectable ' +
                    });
              (orderBy == "time" ? "selected" : "") +
                document
              '">時間</th>' +
                    .getElementById("header-pageview")
              '<th id="header-pageview" class="pageview selectable ' +
                    .addEventListener("click", function () {
              (orderBy == "pageview" ? "selected" : "") +
                        if (orderBy === "pageview") return;
              '">PV</th>' +
                        orderBy = "pageview";
              "<th>ページ</th>" +
                        prepareChart();
              "</tr></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(
                "<tr>" +
                  '<td class="time">' +
                  time +
                  "</td>" +
                  '<td class="pageview">' +
                  pageview +
                  "</td>" +
                  '<td class="page">' +
                  anchor +
                  "</td>" +
                  "</tr>"
              );
            } catch (e) {
              console.log([i, e]);
             }
             }
          }
          html.push("</tbody></table>");
          document.querySelector("#chart_div").innerHTML = html.join("\n");
console.log(html);
          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) {
        function encodeTitle(title) {
        return title
            return title
          .split("/")
                .split("/")
          .map(function(path) {
                .map(function (path) {
            return encodeURIComponent(path);
                    return encodeURIComponent(path);
          })
                })
          .join("/");
                .join("/");
      }
        }
     </script>
     </script>
  </head>
</head>
  <body>
<body>
    <div id="chart_div"></div>
<div id="chart_div"></div>
  </body>
</body>
</html>
</html>
</includeonly>
<noinclude>
{{DEFAULTSORT:}}
</noinclude>

2026年5月28日 (木) 15:08時点における最新版