• R/O
  • HTTP
  • SSH
  • HTTPS

web: Commit

公開webページ管理


Commit MetaInfo

Revisão48ecd97d54ad643add72abc6bf82ad8d0d6ce7c7 (tree)
Hora2018-04-19 00:24:47
AutorHabu <habu@user...>
CommiterHabu

Mensagem de Log

[feature]人気のある種族・職業・性格・魔法領域の再実装React + JSX による実装

Mudança Sumário

Diff

--- /dev/null
+++ b/.babelrc
@@ -0,0 +1,5 @@
1+{
2+ "presets": [
3+ "env", "react"
4+ ]
5+}
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,36 @@
1+{
2+ "env": {
3+ "browser": true,
4+ "es6": true,
5+ "jquery": true
6+ },
7+ "extends": ["eslint:recommended", "plugin:react/recommended"],
8+ "parserOptions": {
9+ "ecmaFeatures": {
10+ "experimentalObjectRestSpread": true,
11+ "jsx": true
12+ },
13+ "sourceType": "module"
14+ },
15+ "plugins": [
16+ "react"
17+ ],
18+ "rules": {
19+ "indent": [
20+ "error",
21+ 4
22+ ],
23+ "linebreak-style": [
24+ "error",
25+ "unix"
26+ ],
27+ "quotes": [
28+ "error",
29+ "double"
30+ ],
31+ "semi": [
32+ "error",
33+ "always"
34+ ]
35+ }
36+}
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
11 web
22 node_modules
33 .vscode
4+bundle.js
5+*.bundle.js
--- /dev/null
+++ b/package.json
@@ -0,0 +1,33 @@
1+{
2+ "name": "hengband-web",
3+ "version": "1.0.0",
4+ "description": "",
5+ "main": "webpack.config.js",
6+ "scripts": {
7+ "build": "webpack --mode production",
8+ "dev": "webpack --mode development",
9+ "test": "echo \"Error: no test specified\" && exit 1"
10+ },
11+ "repository": {
12+ "type": "git",
13+ "url": "habu@git.osdn.net:/gitroot/hengband/web.git"
14+ },
15+ "keywords": [],
16+ "author": "",
17+ "license": "ISC",
18+ "devDependencies": {
19+ "babel-core": "^6.26.0",
20+ "babel-loader": "^7.1.4",
21+ "babel-preset-env": "^1.6.1",
22+ "babel-preset-react": "^6.24.1",
23+ "eslint": "^4.19.1",
24+ "eslint-plugin-react": "^7.7.0",
25+ "prop-types": "^15.6.1",
26+ "webpack": "^4.6.0",
27+ "webpack-cli": "^2.0.14"
28+ },
29+ "dependencies": {
30+ "react": "^16.3.2",
31+ "react-dom": "^16.3.2"
32+ }
33+}
--- a/score/css/score-table.css
+++ b/score/css/score-table.css
@@ -73,8 +73,3 @@ table.score tbody td a:visited {
7373 table.score tbody td a:hover {
7474 color: red;
7575 }
76-
77-table.statistics_table
78-{
79- display: none;
80-}
--- /dev/null
+++ b/score/get_popularity_ranking.php
@@ -0,0 +1,20 @@
1+<?php
2+//ini_set('display_errors', 'On');
3+
4+ini_set('log_errors', 'On');
5+ini_set('error_log', 'errors/'.pathinfo(__FILE__, PATHINFO_FILENAME).'.log');
6+
7+ini_set('zlib.output_compression', 'On');
8+
9+require_once "db_common.inc";
10+require_once "web_template.inc";
11+
12+$db = new ScoreDB();
13+
14+$time_start = microtime(true);
15+
16+$statistics = $db->get_statistics_tables('total_count');
17+
18+$query_time = microtime(true) - $time_start;
19+
20+echo json_encode($statistics);
--- /dev/null
+++ b/score/js/.htaccess
@@ -0,0 +1,5 @@
1+deny from all
2+
3+<Files ~ "\.js$">
4+allow from all
5+</Files>
--- a/score/popularity_ranking.js
+++ /dev/null
@@ -1,57 +0,0 @@
1-function storageAvailable(type) {
2- try {
3- var storage = window[type],
4- x = '__storage_test__';
5- storage.setItem(x, x);
6- storage.removeItem(x);
7- return true;
8- }
9- catch(e) {
10- return e instanceof DOMException && (
11- // everything except Firefox
12- e.code === 22 ||
13- // Firefox
14- e.code === 1014 ||
15- // test name field too, because code might not be present
16- // everything except Firefox
17- e.name === 'QuotaExceededError' ||
18- // Firefox
19- e.name === 'NS_ERROR_DOM_QUOTA_REACHED') &&
20- // acknowledge QuotaExceededError only if there's something already stored
21- storage.length !== 0;
22- }
23-}
24-
25-function select_table(table_id)
26-{
27- if (table_id === null) {
28- if (storageAvailable('sessionStorage')) {
29- table_id = sessionStorage.getItem('selected_table');
30- }
31- table_id = table_id ? table_id : "race_id";
32- }
33-
34- $("table.statistics_table").hide();
35- $("div#" + table_id + " table.statistics_table").show();
36-
37- $("a.table_select").css('font-weight', 'normal').css('font-size', 'small');
38- $("a.table_select#" + table_id).css('font-weight', 'bold').css('font-size', 'large');
39-
40- if (storageAvailable('sessionStorage')) {
41- sessionStorage.setItem('selected_table', table_id);
42- }
43-}
44-
45-$(function(){
46- $(".tablesorter").tablesorter({
47- sortList: [[1, 1]],
48- headers: {
49- 0: {sorter: false}
50- }
51- });
52- $(".table_select").on('click', function() {
53- select_table($(this).attr("id"));
54- });
55-
56- select_table(null);
57-});
--- a/score/popularity_ranking.php
+++ b/score/popularity_ranking.php
@@ -6,124 +6,8 @@ ini_set('error_log', 'errors/'.pathinfo(__FILE__, PATHINFO_FILENAME).'.log');
66
77 ini_set('zlib.output_compression', 'On');
88
9-require_once "db_common.inc";
109 require_once "web_template.inc";
1110
12-function print_popularity_table($fp, $stat, $id_name, $name)
13-{
14- fwrite(
15- $fp,
16- <<<EOM
17-<div id="{$id_name}">
18-<table class="tablesorter score statistics_table one_row">
19-<thead>
20-<tr>
21-<th>$name</th>
22-
23-EOM
24- );
25-
26- foreach ([
27- '計', '男性', '女性', '勝利', '平均スコア', '最大スコア',
28- ] as $name) {
29- fwrite($fp, "<th>${name}</th>\n");
30- }
31- fwrite($fp, "</tr>\n".
32- "</thead>\n");
33-
34- foreach ($stat as $k => $s) {
35- $name_link = "<a href='score_ranking.php?{$id_name}={$s['id']}'>{$s['name']}</a></td>";
36- fwrite(
37- $fp,
38- <<<EOM
39-<tr>
40-<td>$name_link</td>
41-<td class="number">{$s['total_count']}</td>
42-<td class="number">{$s['male_count']}</td>
43-<td class="number">{$s['female_count']}</td>
44-<td class="number">{$s['winner_count']}</td>
45-<td class="number">{$s['average_score']}</td>
46-<td class="number">{$s['max_score']}</td>
47-</tr>
48-
49-EOM
50- );
51- }
52-
53- fwrite($fp, "</table>\n".
54- "</div>\n");
55-}
56-
57-function print_realm_popularity_table($fp, $stat, $id_name)
58-{
59- // 魔法領域の統計を職業ごとにグループ分け
60- $class_ids = array_unique(array_column($stat, "class_id"));
61- $class_realm_stat_list = array_fill_keys($class_ids, []);
62-
63- foreach ($stat as $s) {
64- $class_realm_stat_list[intval($s["class_id"])][] = $s;
65- }
66-
67- fwrite($fp, "<div id=\"{$id_name}\">");
68-
69- // 職業ごとにテーブルを表示
70- foreach ($class_realm_stat_list as $class_id => $class_realm_stat) {
71- if (count($class_realm_stat) <= 1) {
72- continue; // 領域固定の職業は飛ばす
73- }
74-
75- $class_name = $class_realm_stat[0]['class_name'];
76-
77- fwrite(
78- $fp,
79- <<<EOM
80-<table class="tablesorter score statistics_table one_row" id="${id_name}">
81-<thead>
82-<tr>
83-<th>{$class_name}</th>
84-
85-EOM
86- );
87- foreach ([
88- '計', '男性', '女性', '勝利', '平均スコア', '最大スコア',
89- ] as $th_name) {
90- fwrite($fp, "<th>${th_name}</th>\n");
91- }
92- fwrite($fp, "</tr>\n".
93- "</thead>\n");
94-
95- foreach ($class_realm_stat as $realm) {
96- $name_link = "<a href='score_ranking.php?class_id={$class_id}&{$id_name}={$realm['realm_id']}'>{$realm['realm_name']}</a></td>";
97- fwrite(
98- $fp,
99- <<<EOM
100-<tr>
101-<td>$name_link</td>
102-<td class="number">{$realm['total_count']}</td>
103-<td class="number">{$realm['male_count']}</td>
104-<td class="number">{$realm['female_count']}</td>
105-<td class="number">{$realm['winner_count']}</td>
106-<td class="number">{$realm['average_score']}</td>
107-<td class="number">{$realm['max_score']}</td>
108-</tr>
109-
110-EOM
111- );
112- }
113-
114- fwrite($fp, "</table>\n");
115- }
116- fwrite($fp, "</div>\n");
117-}
118-
119-$db = new ScoreDB();
120-
121-$time_start = microtime(true);
122-
123-$statistics = $db->get_statistics_tables('total_count');
124-
125-$query_time = microtime(true) - $time_start;
126-
12711 $wt = new WebTemplate();
12812
12913 $wt->add_head_contents('<meta name="robots" content="none" />');
@@ -137,26 +21,17 @@ integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
13721 crossorigin="anonymous"></script>
13822 EOM
13923 );
140-$wt->add_head_contents('<script src="jquery.tablesorter.min.js" type="text/javascript"></script>');
141-$wt->add_head_contents('<script src="popularity_ranking.js" type="text/javascript"></script>');
24+$wt->add_head_contents('<script src="js/jquery.tablesorter.min.js" type="text/javascript"></script>');
25+//$wt->add_head_contents('<script src="react-tutorial/js/bundle.js" type="text/javascript"></script>');
14226 $wt->set_title("変愚蛮怒 スコアランキング 人気のある種族・職業・性格・魔法領域");
14327
14428 $fp = $wt->main_contents_fp();
145-fwrite($fp, "<h2>人気のある種族・職業・性格・魔法領域</h2>\n");
146-//fprintf($fp, "<small>(%.2f 秒)</small>", $query_time);
14729 fwrite(
14830 $fp,
14931 <<<EOM
150-<nobr>[ <a href="javascript:void(0)" class="table_select" id="race_id">種族</a> | <a href="javascript:void(0)" class="table_select" id="class_id">職業</a> | <a href="javascript:void(0)" class="table_select" id="personality_id">性格</a> ] [ <a href="javascript:void(0)" class="table_select" id="realm_id1">魔法領域1</a> | <a href="javascript:void(0)" class="table_select" id="realm_id2">魔法領域2</a> ]</nobr>
151-
32+<h2>人気のある種族・職業・性格・魔法領域</h2>
33+<div id="content"></div>
34+<script src="js/popularity_ranking.bundle.js" type="text/javascript"></script>
15235 EOM
153-
15436 );
155-
156-print_popularity_table($fp, $statistics['race'], 'race_id', "種族");
157-print_popularity_table($fp, $statistics['class'], 'class_id', "職業");
158-print_popularity_table($fp, $statistics['personality'], 'personality_id', "性格");
159-print_realm_popularity_table($fp, $statistics['realm1'], 'realm_id1');
160-print_realm_popularity_table($fp, $statistics['realm2'], 'realm_id2');
161-
16237 $wt->print_page();
--- /dev/null
+++ b/webpack.config.js
@@ -0,0 +1,32 @@
1+require("babel-core/register");
2+
3+//import path from "path";
4+const path = require("path");
5+
6+const src = path.resolve(__dirname, "score/react-tutorial");
7+const dist = path.resolve(__dirname, "score/js");
8+
9+module.exports = {
10+ entry: {
11+ "popularity_ranking": src + "/popurality_ranking.jsx"
12+ },
13+
14+ output: {
15+ path: dist,
16+ filename: "[name].bundle.js"
17+ },
18+
19+ module: {
20+ rules: [{
21+ test: /\.jsx$/,
22+ exclude: /node_modules/,
23+ loader: "babel-loader"
24+ }]
25+ },
26+
27+ resolve: {
28+ extensions: [".js", ".jsx"]
29+ },
30+
31+ plugins: []
32+};
Show on old repository browser