• R/O
  • HTTP
  • SSH
  • HTTPS

web: Commit

公開webページ管理


Commit MetaInfo

Revisão788d2d6ad619904d27070be457e3b8cf9aedd68e (tree)
Hora2018-04-20 22:09:16
AutorHabu <habu@user...>
CommiterHabu

Mensagem de Log

[feature]人気のある種族・職業・性格・魔法領域のページを再実装

TypeScript + React による再実装
ソート機能も自前で実装した

Mudança Sumário

Diff

--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,37 @@
1+{
2+ "env": {
3+ "commonjs": true,
4+ "browser": true,
5+ "es6": true,
6+ "jquery": true
7+ },
8+ "extends": ["eslint:recommended", "plugin:react/recommended"],
9+ "parserOptions": {
10+ "ecmaFeatures": {
11+ "experimentalObjectRestSpread": true,
12+ "jsx": true
13+ },
14+ "sourceType": "module"
15+ },
16+ "plugins": [
17+ "react"
18+ ],
19+ "rules": {
20+ "indent": [
21+ "error",
22+ 4
23+ ],
24+ "linebreak-style": [
25+ "error",
26+ "unix"
27+ ],
28+ "quotes": [
29+ "error",
30+ "double"
31+ ],
32+ "semi": [
33+ "error",
34+ "always"
35+ ]
36+ }
37+}
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
11 web
22 node_modules
33 .vscode
4+bundle.js
5+*.bundle.js
6+*.map
--- /dev/null
+++ b/package.json
@@ -0,0 +1,38 @@
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+ "watch": "webpack --watch --mode development",
10+ "test": "echo \"Error: no test specified\" && exit 1"
11+ },
12+ "repository": {
13+ "type": "git",
14+ "url": "habu@git.osdn.net:/gitroot/hengband/web.git"
15+ },
16+ "keywords": [],
17+ "author": "",
18+ "license": "ISC",
19+ "devDependencies": {
20+ "awesome-typescript-loader": "^5.0.0",
21+ "eslint": "^4.19.1",
22+ "eslint-plugin-react": "^7.7.0",
23+ "prop-types": "^15.6.1",
24+ "source-map-loader": "^0.2.3",
25+ "tslint": "^5.9.1",
26+ "typescript": "^2.8.1",
27+ "webpack": "^4.6.0",
28+ "webpack-cli": "^2.0.14"
29+ },
30+ "dependencies": {
31+ "@types/jquery": "^3.3.1",
32+ "@types/react": "^16.3.11",
33+ "@types/react-dom": "^16.0.5",
34+ "jquery": "^3.3.1",
35+ "react": "^16.3.2",
36+ "react-dom": "^16.3.2"
37+ }
38+}
--- a/score/.htaccess
+++ b/score/.htaccess
@@ -1,5 +1,5 @@
11 deny from all
22
3-<Files ~ "(\.php|\.js)$">
3+<Files ~ "\.php$">
44 allow from all
55 </Files>
--- a/score/css/score-table.css
+++ b/score/css/score-table.css
@@ -1,80 +1,100 @@
1-table.score
2-{
3- width: 100%;
1+table.score {
2+ width: 100%;
43 }
54
65 table.score thead tr th,
7-table.score tfoot tr th
8-{
9- background-color: #302010;
10- border: 1px solid #d27d00;
11- padding: 4px;
6+table.score tfoot tr th {
7+ background-color: #302010;
8+ border: 1px solid #d27d00;
9+ padding: 4px;
1210 }
1311
14-table.score tbody td
15-{
16- color: black;
17- padding: 4px;
18- background-color: #e9967a;
19- vertical-align: top;
12+table.score tbody td {
13+ color: black;
14+ padding: 4px;
15+ background-color: #e9967a;
16+ vertical-align: top;
2017 }
2118
22-table.score tbody td.rank
23-{
19+table.score tbody td.rank {
2420 text-align: center;
2521 vertical-align: middle;
2622 }
2723
28-table.score tbody td.player_name a span
29-{
24+table.score tbody td.player_name a span {
3025 text-decoration: underline;
3126 }
3227
3328 table.score tbody td.player_name span,
34-table.score tbody td.class_name span
35-{
29+table.score tbody td.class_name span {
3630 white-space: nowrap;
3731 display: inline-block;
3832 }
3933
40-table.score tbody td.race_name
41-{
34+table.score tbody td.race_name {
4235 white-space: nowrap;
4336 }
4437
45-table.score tbody td.sex
46-{
38+table.score tbody td.sex {
4739 text-align: center;
4840 }
4941
5042 table.two_rows tbody tr:nth-child(4n+1) td,
51-table.two_rows tbody tr:nth-child(4n+2) td
52-{
53- background-color: #f9b69a;
43+table.two_rows tbody tr:nth-child(4n+2) td {
44+ background-color: #f9b69a;
5445 }
5546
56-table.one_row tbody tr:nth-child(odd) td
57-{
58- background-color: #f9b69a;
47+table.one_row tbody tr:nth-child(odd) td {
48+ background-color: #f9b69a;
5949 }
6050
61-table.score tbody td.number
62-{
63- text-align: right;
51+table.score tbody td.number {
52+ text-align: right;
6453 }
6554
66-table.score tbody td a:link
67-{
68- color: black;
55+table.score tbody td a:link {
56+ color: black;
6957 }
58+
7059 table.score tbody td a:visited {
71- color: gray;
60+ color: gray;
7261 }
62+
7363 table.score tbody td a:hover {
74- color: red;
64+ color: red;
65+}
66+
67+table.statistics_table th.sort {
68+ cursor: pointer;
69+}
70+
71+table.statistics_table th.sort:after {
72+ content: '';
73+ float: right;
74+ margin-top: 7px;
75+ border-width: 4px 4px 0;
76+ border-style: solid;
77+ border-color: #f9b69a transparent;
78+ visibility: hidden;
79+ opacity: 0;
80+ -ms-user-select: none;
81+ -webkit-user-select: none;
82+ -moz-user-select: none;
83+ user-select: none;
84+}
85+
86+table.statistics_table th.sort.ascend:after {
87+
88+ border-width: 0 4px 4px;
89+}
90+
91+table.statistics_table th.sort.ascend:after,
92+table.statistics_table th.sort.descend:after {
93+ visibility: visible;
94+ opacity: 0.6;
7595 }
7696
77-table.statistics_table
78-{
79- display: none;
97+table.statistics_table th.sort:hover:after {
98+ visibility: visible;
99+ opacity: 1;
80100 }
--- /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);
--- a/score/jquery.tablesorter.min.js
+++ /dev/null
@@ -1,4 +0,0 @@
1-
2-(function($){$.extend({tablesorter:new
3-function(){var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",cssChildRow:"expand-child",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,sortLocaleCompare:true,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",decimal:'/\.|\,/g',onRenderHeader:null,selectorHeaders:'thead th',debug:false};function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms");}this.benchmark=benchmark;function log(s){if(typeof console!="undefined"&&typeof console.debug!="undefined"){console.log(s);}else{alert(s);}}function buildParserCache(table,$headers){if(table.config.debug){var parsersDebug="";}if(table.tBodies.length==0)return;var rows=table.tBodies[0].rows;if(rows[0]){var list=[],cells=rows[0].cells,l=cells.length;for(var i=0;i<l;i++){var p=false;if($.metadata&&($($headers[i]).metadata()&&$($headers[i]).metadata().sorter)){p=getParserById($($headers[i]).metadata().sorter);}else if((table.config.headers[i]&&table.config.headers[i].sorter)){p=getParserById(table.config.headers[i].sorter);}if(!p){p=detectParserForColumn(table,rows,-1,i);}if(table.config.debug){parsersDebug+="column:"+i+" parser:"+p.id+"\n";}list.push(p);}}if(table.config.debug){log(parsersDebug);}return list;};function detectParserForColumn(table,rows,rowIndex,cellIndex){var l=parsers.length,node=false,nodeValue=false,keepLooking=true;while(nodeValue==''&&keepLooking){rowIndex++;if(rows[rowIndex]){node=getNodeFromRowAndCellIndex(rows,rowIndex,cellIndex);nodeValue=trimAndGetNodeText(table.config,node);if(table.config.debug){log('Checking if value was empty on row:'+rowIndex);}}else{keepLooking=false;}}for(var i=1;i<l;i++){if(parsers[i].is(nodeValue,table,node)){return parsers[i];}}return parsers[0];}function getNodeFromRowAndCellIndex(rows,rowIndex,cellIndex){return rows[rowIndex].cells[cellIndex];}function trimAndGetNodeText(config,node){return $.trim(getElementText(config,node));}function getParserById(name){var l=parsers.length;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==name.toLowerCase()){return parsers[i];}}return false;}function buildCache(table){if(table.config.debug){var cacheTime=new Date();}var totalRows=(table.tBodies[0]&&table.tBodies[0].rows.length)||0,totalCells=(table.tBodies[0].rows[0]&&table.tBodies[0].rows[0].cells.length)||0,parsers=table.config.parsers,cache={row:[],normalized:[]};for(var i=0;i<totalRows;++i){var c=$(table.tBodies[0].rows[i]),cols=[];if(c.hasClass(table.config.cssChildRow)){cache.row[cache.row.length-1]=cache.row[cache.row.length-1].add(c);continue;}cache.row.push(c);for(var j=0;j<totalCells;++j){cols.push(parsers[j].format(getElementText(table.config,c[0].cells[j]),table,c[0].cells[j]));}cols.push(cache.normalized.length);cache.normalized.push(cols);cols=null;};if(table.config.debug){benchmark("Building cache for "+totalRows+" rows:",cacheTime);}return cache;};function getElementText(config,node){var text="";if(!node)return"";if(!config.supportsTextContent)config.supportsTextContent=node.textContent||false;if(config.textExtraction=="simple"){if(config.supportsTextContent){text=node.textContent;}else{if(node.childNodes[0]&&node.childNodes[0].hasChildNodes()){text=node.childNodes[0].innerHTML;}else{text=node.innerHTML;}}}else{if(typeof(config.textExtraction)=="function"){text=config.textExtraction(node);}else{text=$(node).text();}}return text;}function appendToTable(table,cache){if(table.config.debug){var appendTime=new Date()}var c=cache,r=c.row,n=c.normalized,totalRows=n.length,checkCell=(n[0].length-1),tableBody=$(table.tBodies[0]),rows=[];for(var i=0;i<totalRows;i++){var pos=n[i][checkCell];rows.push(r[pos]);if(!table.config.appender){var l=r[pos].length;for(var j=0;j<l;j++){tableBody[0].appendChild(r[pos][j]);}}}if(table.config.appender){table.config.appender(table,rows);}rows=null;if(table.config.debug){benchmark("Rebuilt table:",appendTime);}applyWidget(table);setTimeout(function(){$(table).trigger("sortEnd");},0);};function buildHeaders(table){if(table.config.debug){var time=new Date();}var meta=($.metadata)?true:false;var header_index=computeTableHeaderCellIndexes(table);$tableHeaders=$(table.config.selectorHeaders,table).each(function(index){this.column=header_index[this.parentNode.rowIndex+"-"+this.cellIndex];this.order=formatSortingOrder(table.config.sortInitialOrder);this.count=this.order;if(checkHeaderMetadata(this)||checkHeaderOptions(table,index))this.sortDisabled=true;if(checkHeaderOptionsSortingLocked(table,index))this.order=this.lockedOrder=checkHeaderOptionsSortingLocked(table,index);if(!this.sortDisabled){var $th=$(this).addClass(table.config.cssHeader);if(table.config.onRenderHeader)table.config.onRenderHeader.apply($th);}table.config.headerList[index]=this;});if(table.config.debug){benchmark("Built headers:",time);log($tableHeaders);}return $tableHeaders;};function computeTableHeaderCellIndexes(t){var matrix=[];var lookup={};var thead=t.getElementsByTagName('THEAD')[0];var trs=thead.getElementsByTagName('TR');for(var i=0;i<trs.length;i++){var cells=trs[i].cells;for(var j=0;j<cells.length;j++){var c=cells[j];var rowIndex=c.parentNode.rowIndex;var cellId=rowIndex+"-"+c.cellIndex;var rowSpan=c.rowSpan||1;var colSpan=c.colSpan||1
4-var firstAvailCol;if(typeof(matrix[rowIndex])=="undefined"){matrix[rowIndex]=[];}for(var k=0;k<matrix[rowIndex].length+1;k++){if(typeof(matrix[rowIndex][k])=="undefined"){firstAvailCol=k;break;}}lookup[cellId]=firstAvailCol;for(var k=rowIndex;k<rowIndex+rowSpan;k++){if(typeof(matrix[k])=="undefined"){matrix[k]=[];}var matrixrow=matrix[k];for(var l=firstAvailCol;l<firstAvailCol+colSpan;l++){matrixrow[l]="x";}}}}return lookup;}function checkCellColSpan(table,rows,row){var arr=[],r=table.tHead.rows,c=r[row].cells;for(var i=0;i<c.length;i++){var cell=c[i];if(cell.colSpan>1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}function checkHeaderOptionsSortingLocked(table,i){if((table.config.headers[i])&&(table.config.headers[i].lockedOrder))return table.config.headers[i].lockedOrder;return false;}function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i<l;i++){getWidgetById(c[i]).format(table);}}function getWidgetById(name){var l=widgets.length;for(var i=0;i<l;i++){if(widgets[i].id.toLowerCase()==name.toLowerCase()){return widgets[i];}}};function formatSortingOrder(v){if(typeof(v)!="Number"){return(v.toLowerCase()=="desc")?1:0;}else{return(v==1)?1:0;}}function isValueInArray(v,a){var l=a.length;for(var i=0;i<l;i++){if(a[i][0]==v){return true;}}return false;}function setHeadersCss(table,$headers,list,css){$headers.removeClass(css[0]).removeClass(css[1]);var h=[];$headers.each(function(offset){if(!this.sortDisabled){h[this.column]=$(this);}});var l=list.length;for(var i=0;i<l;i++){h[list[i][0]].addClass(css[list[i][1]]);}}function fixColumnWidth(table,$headers){var c=table.config;if(c.widthFixed){var colgroup=$('<colgroup>');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('<col>').css('width',$(this).width()));});$(table).prepend(colgroup);};}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;i<l;i++){var s=sortList[i],o=c.headerList[s[0]];o.count=s[1];o.count++;}}function multisort(table,sortList,cache){if(table.config.debug){var sortTime=new Date();}var dynamicExp="var sortWrapper = function(a,b) {",l=sortList.length;for(var i=0;i<l;i++){var c=sortList[i][0];var order=sortList[i][1];var s=(table.config.parsers[c].type=="text")?((order==0)?makeSortFunction("text","asc",c):makeSortFunction("text","desc",c)):((order==0)?makeSortFunction("numeric","asc",c):makeSortFunction("numeric","desc",c));var e="e"+i;dynamicExp+="var "+e+" = "+s;dynamicExp+="if("+e+") { return "+e+"; } ";dynamicExp+="else { ";}var orgOrderCol=cache.normalized[0].length-1;dynamicExp+="return a["+orgOrderCol+"]-b["+orgOrderCol+"];";for(var i=0;i<l;i++){dynamicExp+="}; ";}dynamicExp+="return 0; ";dynamicExp+="}; ";if(table.config.debug){benchmark("Evaling expression:"+dynamicExp,new Date());}eval(dynamicExp);cache.normalized.sort(sortWrapper);if(table.config.debug){benchmark("Sorting on "+sortList.toString()+" and dir "+order+" time:",sortTime);}return cache;};function makeSortFunction(type,direction,index){var a="a["+index+"]",b="b["+index+"]";if(type=='text'&&direction=='asc'){return"("+a+" == "+b+" ? 0 : ("+a+" === null ? Number.POSITIVE_INFINITY : ("+b+" === null ? Number.NEGATIVE_INFINITY : ("+a+" < "+b+") ? -1 : 1 )));";}else if(type=='text'&&direction=='desc'){return"("+a+" == "+b+" ? 0 : ("+a+" === null ? Number.POSITIVE_INFINITY : ("+b+" === null ? Number.NEGATIVE_INFINITY : ("+b+" < "+a+") ? -1 : 1 )));";}else if(type=='numeric'&&direction=='asc'){return"("+a+" === null && "+b+" === null) ? 0 :("+a+" === null ? Number.POSITIVE_INFINITY : ("+b+" === null ? Number.NEGATIVE_INFINITY : "+a+" - "+b+"));";}else if(type=='numeric'&&direction=='desc'){return"("+a+" === null && "+b+" === null) ? 0 :("+a+" === null ? Number.POSITIVE_INFINITY : ("+b+" === null ? Number.NEGATIVE_INFINITY : "+b+" - "+a+"));";}};function makeSortText(i){return"((a["+i+"] < b["+i+"]) ? -1 : ((a["+i+"] > b["+i+"]) ? 1 : 0));";};function makeSortTextDesc(i){return"((b["+i+"] < a["+i+"]) ? -1 : ((b["+i+"] > a["+i+"]) ? 1 : 0));";};function makeSortNumeric(i){return"a["+i+"]-b["+i+"];";};function makeSortNumericDesc(i){return"b["+i+"]-a["+i+"];";};function sortText(a,b){if(table.config.sortLocaleCompare)return a.localeCompare(b);return((a<b)?-1:((a>b)?1:0));};function sortTextDesc(a,b){if(table.config.sortLocaleCompare)return b.localeCompare(a);return((b<a)?-1:((b>a)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$.data(this,"tablesorter",config);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){$this.trigger("sortStart");var $cell=$(this);var i=this.column;this.order=this.count++%2;if(this.lockedOrder)this.order=this.lockedOrder;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j<a.length;j++){if(a[j][0]!=i){config.sortList.push(a[j]);}}}config.sortList.push([i,this.order]);}else{if(isValueInArray(i,config.sortList)){for(var j=0;j<config.sortList.length;j++){var s=config.sortList[j],o=config.headerList[s[0]];if(s[0]==i){o.count=s[1];o.count++;s[1]=o.count%2;}}}else{config.sortList.push([i,this.order]);}};setTimeout(function(){setHeadersCss($this[0],$headers,config.sortList,sortCSS);appendToTable($this[0],multisort($this[0],config.sortList,cache));},1);return false;}}).mousedown(function(){if(config.cancelSelection){this.onselectstart=function(){return false};return false;}});$this.bind("update",function(){var me=this;setTimeout(function(){me.config.parsers=buildParserCache(me,$headers);cache=buildCache(me);},1);}).bind("updateCell",function(e,cell){var config=this.config;var pos=[(cell.parentNode.rowIndex-1),cell.cellIndex];cache.normalized[pos[0]][pos[1]]=config.parsers[pos[1]].format(getElementText(config,cell),cell);}).bind("sorton",function(e,list){$(this).trigger("sortStart");config.sortList=list;var sortList=config.sortList;updateHeaderSortCount(this,sortList);setHeadersCss(this,$headers,sortList,sortCSS);appendToTable(this,multisort(this,sortList,cache));}).bind("appendCache",function(){appendToTable(this,cache);}).bind("applyWidgetId",function(e,id){getWidgetById(id).format(this);}).bind("applyWidgets",function(){applyWidget(this);});if($.metadata&&($(this).metadata()&&$(this).metadata().sortlist)){config.sortList=$(this).metadata().sortlist;}if(config.sortList.length>0){$this.trigger("sorton",[config.sortList]);}applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==parser.id.toLowerCase()){a=false;}}if(a){parsers.push(parser);};};this.addWidget=function(widget){widgets.push(widget);};this.formatFloat=function(s){var i=parseFloat(s);return(isNaN(i))?0:i;};this.formatInt=function(s){var i=parseInt(s);return(isNaN(i))?0:i;};this.isDigit=function(s,config){return/^[-+]?\d*$/.test($.trim(s.replace(/[,.']/g,'')));};this.clearTableBody=function(table){if($.browser.msie){function empty(){while(this.firstChild)this.removeChild(this.firstChild);}empty.apply(table.tBodies[0]);}else{table.tBodies[0].innerHTML="";}};}});$.fn.extend({tablesorter:$.tablesorter.construct});var ts=$.tablesorter;ts.addParser({id:"text",is:function(s){return true;},format:function(s){return $.trim(s.toLocaleLowerCase());},type:"text"});ts.addParser({id:"digit",is:function(s,table){var c=table.config;return $.tablesorter.isDigit(s,c);},format:function(s){return $.tablesorter.formatFloat(s);},type:"numeric"});ts.addParser({id:"currency",is:function(s){return/^[£$€?.]/.test(s);},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/[£$€]/g),""));},type:"numeric"});ts.addParser({id:"ipAddress",is:function(s){return/^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(s);},format:function(s){var a=s.split("."),r="",l=a.length;for(var i=0;i<l;i++){var item=a[i];if(item.length==2){r+="0"+item;}else{r+=item;}}return $.tablesorter.formatFloat(r);},type:"numeric"});ts.addParser({id:"url",is:function(s){return/^(https?|ftp|file):\/\/$/.test(s);},format:function(s){return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//),''));},type:"text"});ts.addParser({id:"isoDate",is:function(s){return/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s);},format:function(s){return $.tablesorter.formatFloat((s!="")?new Date(s.replace(new RegExp(/-/g),"/")).getTime():"0");},type:"numeric"});ts.addParser({id:"percent",is:function(s){return/\%$/.test($.trim(s));},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g),""));},type:"numeric"});ts.addParser({id:"usLongDate",is:function(s){return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/));},format:function(s){return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"shortDate",is:function(s){return/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s);},format:function(s,table){var c=table.config;s=s.replace(/\-/g,"/");if(c.dateFormat=="us"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$1/$2");}else if(c.dateFormat=="uk"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$2/$1");}else if(c.dateFormat=="dd/mm/yy"||c.dateFormat=="dd-mm-yy"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,"$1/$2/$3");}return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"time",is:function(s){return/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s);},format:function(s){return $.tablesorter.formatFloat(new Date("2000/01/01 "+s).getTime());},type:"numeric"});ts.addParser({id:"metadata",is:function(s){return false;},format:function(s,table,cell){var c=table.config,p=(!c.parserMetadataName)?'sortValue':c.parserMetadataName;return $(cell).metadata()[p];},type:"numeric"});ts.addWidget({id:"zebra",format:function(table){if(table.config.debug){var time=new Date();}var $tr,row=-1,odd;$("tr:visible",table.tBodies[0]).each(function(i){$tr=$(this);if(!$tr.hasClass(table.config.cssChildRow))row++;odd=(row%2==0);$tr.removeClass(table.config.widgetZebra.css[odd?0:1]).addClass(table.config.widgetZebra.css[odd?1:0])});if(table.config.debug){$.tablesorter.benchmark("Applying Zebra widget",time);}}});})(jQuery);
\ No newline at end of file
--- a/score/tablesorter-theme/.htaccess
+++ b/score/js/.htaccess
@@ -1,5 +1,5 @@
11 deny from all
22
3-<Files ~ "(\.gif|\.css)$">
3+<Files ~ "\.js$">
44 allow from all
55 </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,157 +6,28 @@ 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" />');
13014 $wt->add_head_contents('<link rel="stylesheet" type="text/css" href="css/score-table.css">');
131-$wt->add_head_contents('<link rel="stylesheet" type="text/css" href="tablesorter-theme/style.css">');
13215 $wt->add_head_contents(
13316 <<<EOM
134-<script
135-src="https://code.jquery.com/jquery-3.3.1.min.js"
136-integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
137-crossorigin="anonymous"></script>
17+<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
18+<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
13819 EOM
13920 );
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>');
21+//$wt->add_head_contents('<script src="react-tutorial/js/bundle.js" type="text/javascript"></script>');
14222 $wt->set_title("変愚蛮怒 スコアランキング 人気のある種族・職業・性格・魔法領域");
14323
14424 $fp = $wt->main_contents_fp();
145-fwrite($fp, "<h2>人気のある種族・職業・性格・魔法領域</h2>\n");
146-//fprintf($fp, "<small>(%.2f 秒)</small>", $query_time);
14725 fwrite(
14826 $fp,
14927 <<<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-
28+<h2>人気のある種族・職業・性格・魔法領域</h2>
29+<div id="content"></div>
30+<script src="js/popularity_ranking.bundle.js" type="text/javascript"></script>
15231 EOM
153-
15432 );
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-
16233 $wt->print_page();
--- /dev/null
+++ b/score/src/popurality_ranking.tsx
@@ -0,0 +1,483 @@
1+import React from "react";
2+import ReactDOM from "react-dom";
3+
4+const name2j: { [key: string]: string } = {
5+ class: "職業",
6+ personality: "性格",
7+ race: "種族",
8+ realm1: "魔法領域1",
9+ realm2: "魔法領域2",
10+};
11+
12+const column2j: { [col: string]: string } = {
13+ average_score: "平均スコア",
14+ female_count: "女性",
15+ male_count: "男性",
16+ max_score: "最大スコア",
17+ total_count: "計",
18+ winner_count: "勝利",
19+};
20+
21+const columnOrder = [
22+ "total_count",
23+ "male_count",
24+ "female_count",
25+ "winner_count",
26+ "average_score",
27+ "max_score",
28+];
29+
30+/**
31+ * 表示テーブル選択ボタンコンポーネントプロパティ
32+ */
33+interface ITableSelectButtonProps {
34+ /** ボタンが選択状態かどうか */
35+ selected: boolean;
36+ /** ボタンの銘板 */
37+ name: string;
38+ /** ボタンがクリックされた時に呼び出されるコールバック関数 */
39+ onClick: () => void;
40+}
41+
42+/**
43+ * 表示テーブル選択ボタンコンポーネント
44+ */
45+// tslint:disable-next-line:max-classes-per-file
46+class TableSelectButton extends React.Component<ITableSelectButtonProps> {
47+ public shouldComponentUpdate(nextProps: ITableSelectButtonProps) {
48+ return this.props.selected !== nextProps.selected;
49+ }
50+
51+ public render() {
52+ if (this.props.selected) {
53+ return (
54+ <b>
55+ {name2j[this.props.name]}
56+ </b>
57+ );
58+ } else {
59+ return (
60+ <a href="javascript:void(0)" onClick={() => this.props.onClick()}>
61+ {name2j[this.props.name]}
62+ </a>
63+ );
64+ }
65+ }
66+}
67+
68+/**
69+ * 表示テーブル選択コンポーネントプロパティ
70+ */
71+interface ITableSelectProps {
72+ /** 選択中のテーブル名称 */
73+ selectedTableName: string;
74+ /**
75+ * 選択テーブル切替時に呼び出されるコールバック関数
76+ * @param name 新たに選択されたテーブル名称
77+ */
78+ onSelectChange: (name: string) => void;
79+}
80+
81+/**
82+ * 表示テーブル選択コンポーネント
83+ */
84+// tslint:disable-next-line:max-classes-per-file
85+class TableSelector extends React.Component<ITableSelectProps> {
86+ public render() {
87+ return (
88+ <div>
89+ [ {this.renderSelectButton("race")} | {this.renderSelectButton("class")} |
90+ {this.renderSelectButton("personality")} ]
91+ [ {this.renderSelectButton("realm1")} | {this.renderSelectButton("realm2")} ]
92+ </div>
93+ );
94+ }
95+
96+ private renderSelectButton(name: string) {
97+ return <TableSelectButton
98+ selected={this.props.selectedTableName === name}
99+ name={name}
100+ onClick={() => this.props.onSelectChange(name)} />;
101+ }
102+}
103+
104+/**
105+ * テーブルヘッダコンポーネントプロパティ
106+ */
107+interface ITableHeaderProps {
108+ /** テーブル名称 */
109+ tableName: string;
110+ /** ソートキーカラム */
111+ sortKeyColumn: string;
112+ /** ソート順 */
113+ sortOrder: SortOrder;
114+ /**
115+ * ヘッダをクリックした時に呼ばれるコールバック関数
116+ * @param clickColumn クリックしたカラムの名称
117+ */
118+ onClick: (clickColumn: string) => void;
119+}
120+
121+/**
122+ * テーブルヘッダコンポーネント
123+ */
124+function TableHeader(props: ITableHeaderProps) {
125+ return (
126+ <thead>
127+ <tr>
128+ <th>{props.tableName}</th>
129+ {columnOrder.map((col) => {
130+ let className = "sort";
131+ if (props.sortKeyColumn === col) {
132+ className += " ";
133+ className += (props.sortOrder === SortOrder.Ascend) ? "ascend" : "descend";
134+ }
135+ return (
136+ <th className={className} onClick={() => props.onClick(col)}>
137+ {column2j[col]}
138+ </th>
139+ );
140+ })}
141+ </tr>
142+ </thead>
143+ );
144+}
145+
146+/**
147+ * テーブル行データコンポーネントプロパティ
148+ */
149+interface ITableDataRowProps {
150+ /** スコアランキングのURLのリンクに渡すパラメータ */
151+ linkParam: string;
152+ /** 行データの名称(第1カラムに表示される文字列) */
153+ rowName: string;
154+ /** 行データ */
155+ row_data: { [key: string]: string | number };
156+}
157+
158+/**
159+ * テーブル行データコンポーネント
160+ */
161+function TableDataRow(props: ITableDataRowProps) {
162+ return (
163+ <tr key={props.row_data.id}>
164+ <td>
165+ <a href={`score_ranking.php?${props.linkParam}`}>
166+ {props.rowName}
167+ </a>
168+ </td>
169+ {columnOrder.map((col) =>
170+ <td className="number">{props.row_data[col]}</td>)}
171+ </tr>
172+ );
173+}
174+
175+/**
176+ * ソート順序列挙体
177+ */
178+enum SortOrder {
179+ /** 昇順 */
180+ Ascend,
181+ /** 降順 */
182+ Descend,
183+}
184+
185+/**
186+ * 人気データテーブルコンポーネントプロパティ
187+ */
188+interface IPopuralityTableProps {
189+ /** データ内容 */
190+ data: Array<{ [col: string]: any }>;
191+ /** データ名称 */
192+ name: string;
193+ /** テーブルの表示/非表示 */
194+ visible: boolean;
195+}
196+
197+/**
198+ * 人気データテーブルコンポーネントステータス
199+ */
200+interface IPopuralityTableState {
201+ /** データソートのキーとするカラムの名称 */
202+ sortKeyColumn: string;
203+ /** データソートの順序 */
204+ sortOrder: SortOrder;
205+}
206+
207+/**
208+ * 人気データテーブルコンポーネント
209+ */
210+// tslint:disable-next-line:max-classes-per-file
211+class PopuralityTable extends React.Component<IPopuralityTableProps, IPopuralityTableState> {
212+ constructor(props: IPopuralityTableProps) {
213+ super(props);
214+ this.state = {
215+ sortKeyColumn: columnOrder[0],
216+ sortOrder: SortOrder.Descend,
217+ };
218+ }
219+
220+ public render() {
221+ if (!this.props.visible) {
222+ return "";
223+ }
224+
225+ const data = this.get_sorted_data();
226+ const tableName = this.props.name;
227+ return (
228+ <table className="score statistics_table one_row">
229+ <TableHeader
230+ tableName={name2j[tableName]}
231+ sortKeyColumn={this.state.sortKeyColumn}
232+ sortOrder={this.state.sortOrder}
233+ onClick={this.selectSortColumn.bind(this)}
234+ />
235+ <tbody>
236+ {data.map((row) =>
237+ <TableDataRow
238+ linkParam={`${tableName}_id=${row.id}`}
239+ rowName={row.name}
240+ row_data={row}
241+ />)}
242+ </tbody>
243+ </table>
244+ );
245+ }
246+
247+ /**
248+ * ソートされたデータを得る
249+ * @return ソートされたデータ
250+ */
251+ protected get_sorted_data() {
252+ const sortedData = this.props.data.slice();
253+
254+ const col = this.state.sortKeyColumn;
255+ const order = this.state.sortOrder;
256+
257+ sortedData.sort((a, b) =>
258+ (order === (SortOrder.Ascend) ?
259+ a[col] - b[col] : b[col] - a[col]));
260+
261+ return sortedData;
262+ }
263+
264+ /**
265+ * ソートするカラムを選択する
266+ * @param column ソートするカラムの名称
267+ */
268+ protected selectSortColumn(column: string) {
269+ let newSortOrder = SortOrder.Descend;
270+ if (this.state.sortKeyColumn === column) {
271+ newSortOrder =
272+ (this.state.sortOrder === SortOrder.Ascend) ?
273+ SortOrder.Descend : SortOrder.Ascend;
274+ }
275+ this.setState({
276+ sortKeyColumn: column,
277+ sortOrder: newSortOrder,
278+ });
279+ }
280+}
281+
282+/**
283+ * 人気データテーブルコンポーネント(魔法領域)
284+ */
285+// tslint:disable-next-line:max-classes-per-file
286+class PopuralityRealmTable extends PopuralityTable {
287+ public render() {
288+ if (!this.props.visible) {
289+ return "";
290+ }
291+
292+ const data = this.get_sorted_data();
293+ const realm = this.props.name;
294+ return (
295+ <table className="score statistics_table one_row">
296+ <TableHeader
297+ tableName={this.props.data[0].class_name}
298+ sortKeyColumn={this.state.sortKeyColumn}
299+ sortOrder={this.state.sortOrder}
300+ onClick={this.selectSortColumn.bind(this)}
301+ />
302+ <tbody>
303+ {data.map((row) =>
304+ <TableDataRow
305+ linkParam={`class_id=${row.class_id}&${realm}_id=${row.realm_id}`}
306+ rowName={row.realm_name}
307+ row_data={row}
308+ />)}
309+ </tbody>
310+ </table>
311+ );
312+ }
313+}
314+
315+/**
316+ * 人気データテーブル全体表示コンポーネントプロパティ
317+ */
318+interface IRankingTablesProps {
319+ /** 表示選択中のテーブル名称 */
320+ selectedTableName: string;
321+ /** テーブルデータ */
322+ data: { [col: string]: any[] };
323+}
324+
325+/**
326+ * 人気データテーブル全体表示コンポーネント
327+ */
328+// tslint:disable-next-line:max-classes-per-file
329+class RankingTables extends React.Component<IRankingTablesProps> {
330+ public shouldComponentUpdate(nextProps: IRankingTablesProps) {
331+ return (this.props.data === null && nextProps.data !== null) ||
332+ (this.props.selectedTableName !== nextProps.selectedTableName);
333+ }
334+
335+ public render() {
336+ const tables = Object.keys(name2j).map((name) => {
337+ if (!name.startsWith("realm")) {
338+ return (
339+ <div id={name} key={name}>
340+ <PopuralityTable
341+ data={this.props.data[name]}
342+ visible={this.props.selectedTableName === name}
343+ name={name} />
344+ </div>
345+ );
346+ } else {
347+ const realmTables = this.props.data[name].map((i) => {
348+ return <PopuralityRealmTable
349+ data={i}
350+ name={name}
351+ visible={this.props.selectedTableName === name}
352+ key={i[0].class_id} />;
353+ });
354+ return <div id={name} key={name}>{realmTables}</div>;
355+ }
356+ });
357+ return <div>{tables}</div>;
358+ }
359+}
360+
361+/**
362+ * 人気データ表示コンポーネントプロパティ
363+ */
364+interface IPopuralityRankingProps {
365+ /** 人気データ取得URL */
366+ dataUrl: string;
367+}
368+
369+/**
370+ * 人気データ表示コンポーネントステータス
371+ */
372+interface IPopuralityRankingState {
373+ /** 表示選択中テーブル名称 */
374+ selectedTableName: string;
375+ /** データ内容 */
376+ data: { [col: string]: any[] };
377+ /** データ表示状態を示すメッセージ */
378+ stateMessage: string;
379+}
380+
381+/**
382+ * 人気データ表示コンポーネント
383+ */
384+// tslint:disable-next-line:max-classes-per-file
385+class PopuralityRanking extends React.Component<IPopuralityRankingProps, IPopuralityRankingState> {
386+ constructor(props: IPopuralityRankingProps) {
387+ super(props);
388+ const selectedTableName = this.storageAvailable("sessionStorage") ?
389+ sessionStorage.getItem("selectedTableName") : null;
390+
391+ this.state = {
392+ data: {},
393+ selectedTableName: selectedTableName !== null ? selectedTableName : "race",
394+ stateMessage: "Loading...",
395+ };
396+ }
397+
398+ public componentDidMount() {
399+ fetch(this.props.dataUrl).then((response) => {
400+ if (!response.ok) {
401+ throw Error(`${response.status} ${response.statusText}`);
402+ }
403+ return response.json();
404+ }).then((data) => {
405+ data.realm1 = this.group_by_class(data.realm1);
406+ data.realm2 = this.group_by_class(data.realm2);
407+ this.setState({
408+ data,
409+ stateMessage: "Success",
410+ });
411+ }).catch((err) => {
412+ this.setState({ stateMessage: err.message });
413+ });
414+ }
415+
416+ public componentDidUpdate() {
417+ if (this.storageAvailable("sessionStorage")) {
418+ sessionStorage.setItem("selectedTableName", this.state.selectedTableName);
419+ }
420+ }
421+
422+ public render() {
423+ if (Object.keys(this.state.data).length === 0) {
424+ return <div>{this.state.stateMessage}</div>;
425+ }
426+
427+ return (
428+ <div>
429+ <TableSelector
430+ onSelectChange={this.selectTable.bind(this)}
431+ selectedTableName={this.state.selectedTableName}
432+ />
433+ <RankingTables
434+ data={this.state.data}
435+ selectedTableName={this.state.selectedTableName}
436+ />
437+ </div>
438+ );
439+ }
440+
441+ private storageAvailable(type: string) {
442+ const storage = (window as any)[type];
443+ try {
444+ const x = "__storage_test__";
445+ storage.setItem(x, x);
446+ storage.removeItem(x);
447+ return true;
448+ } catch (e) {
449+ return e instanceof DOMException && (
450+ // everything except Firefox
451+ e.code === 22 ||
452+ // Firefox
453+ e.code === 1014 ||
454+ // test name field too, because code might not be present
455+ // everything except Firefox
456+ e.name === "QuotaExceededError" ||
457+ // Firefox
458+ e.name === "NS_ERROR_DOM_QUOTA_REACHED") &&
459+ // acknowledge QuotaExceededError only if there's something already stored
460+ storage.length !== 0;
461+ }
462+ }
463+
464+ private selectTable(tableName: string) {
465+ this.setState({ selectedTableName: tableName });
466+ }
467+
468+ private group_by_class(data: any[]) {
469+ const result: any[] = [];
470+ data.forEach((i) => {
471+ if (result[i.class_id] === undefined) {
472+ result[i.class_id] = [];
473+ }
474+ result[i.class_id].push(i);
475+ });
476+ return result.filter((e) => e.length > 1);
477+ }
478+}
479+
480+ReactDOM.render(
481+ <PopuralityRanking dataUrl="get_popularity_ranking.php" />,
482+ document.getElementById("content"),
483+);
Binary files a/score/tablesorter-theme/asc.gif and /dev/null differ
Binary files a/score/tablesorter-theme/bg.gif and /dev/null differ
Binary files a/score/tablesorter-theme/desc.gif and /dev/null differ
--- a/score/tablesorter-theme/style.css
+++ /dev/null
@@ -1,16 +0,0 @@
1-/* tables */
2-table.tablesorter thead tr .header {
3- background-image: url(bg.gif);
4- background-repeat: no-repeat;
5- background-position: center right;
6- cursor: pointer;
7-}
8-table.tablesorter thead tr .headerSortUp {
9- background-image: url(asc.gif);
10-}
11-table.tablesorter thead tr .headerSortDown {
12- background-image: url(desc.gif);
13-}
14-table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp {
15- border: 3px ridge #d27d00;
16-}
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,57 @@
1+{
2+ "compilerOptions": {
3+ /* Basic Options */
4+ "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
5+ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
6+ // "lib": [], /* Specify library files to be included in the compilation. */
7+ // "allowJs": true, /* Allow javascript files to be compiled. */
8+ // "checkJs": true, /* Report errors in .js files. */
9+ "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
10+ // "declaration": true, /* Generates corresponding '.d.ts' file. */
11+ "sourceMap": true, /* Generates corresponding '.map' file. */
12+ // "outFile": "./", /* Concatenate and emit output to single file. */
13+ // "outDir": "./", /* Redirect output structure to the directory. */
14+ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
15+ // "removeComments": true, /* Do not emit comments to output. */
16+ // "noEmit": true, /* Do not emit outputs. */
17+ // "importHelpers": true, /* Import emit helpers from 'tslib'. */
18+ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
19+ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
20+
21+ /* Strict Type-Checking Options */
22+ "strict": true, /* Enable all strict type-checking options. */
23+ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
24+ // "strictNullChecks": true, /* Enable strict null checks. */
25+ // "strictFunctionTypes": true, /* Enable strict checking of function types. */
26+ // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
27+ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
28+ // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
29+
30+ /* Additional Checks */
31+ // "noUnusedLocals": true, /* Report errors on unused locals. */
32+ // "noUnusedParameters": true, /* Report errors on unused parameters. */
33+ // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
34+ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
35+
36+ /* Module Resolution Options */
37+ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
38+ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
39+ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
40+ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
41+ // "typeRoots": [], /* List of folders to include type definitions from. */
42+ // "types": [], /* Type declaration files to be included in compilation. */
43+ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
44+ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
45+ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
46+
47+ /* Source Map Options */
48+ // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
49+ // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
50+ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
51+ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
52+
53+ /* Experimental Options */
54+ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
55+ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
56+ }
57+}
--- /dev/null
+++ b/tslint.json
@@ -0,0 +1,9 @@
1+{
2+ "defaultSeverity": "error",
3+ "extends": [
4+ "tslint:recommended"
5+ ],
6+ "jsRules": {},
7+ "rules": {},
8+ "rulesDirectory": []
9+}
\ No newline at end of file
--- /dev/null
+++ b/webpack.config.js
@@ -0,0 +1,50 @@
1+//import path from "path";
2+const path = require("path");
3+
4+const src = path.resolve(__dirname, "score/src");
5+const dist = path.resolve(__dirname, "score/js");
6+
7+module.exports = {
8+ entry: {
9+ "popularity_ranking": src + "/popurality_ranking.tsx"
10+ },
11+
12+ output: {
13+ path: dist,
14+ filename: "[name].bundle.js"
15+ },
16+
17+ devtool: "source-map",
18+
19+ resolve: {
20+ // Add '.ts' and '.tsx' as resolvable extensions.
21+ extensions: [".ts", ".tsx", ".js", ".jsx", ".json"]
22+ },
23+
24+ module: {
25+ rules: [
26+ // All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
27+ {
28+ test: /\.tsx?$/,
29+ loader: "awesome-typescript-loader"
30+ },
31+
32+ // All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
33+ {
34+ enforce: "pre",
35+ test: /\.js$/,
36+ loader: "source-map-loader"
37+ }
38+ ]
39+
40+ },
41+
42+ // When importing a module whose path matches one of the following, just
43+ // assume a corresponding global variable exists and use that instead.
44+ // This is important because it allows us to avoid bundling all of our
45+ // dependencies, which allows browsers to cache those libraries between builds.
46+ externals: {
47+ "react": "React",
48+ "react-dom": "ReactDOM",
49+ },
50+};
Show on old repository browser