Skip to content

Commit 777cc5b

Browse files
Merge branch 'ryo-test-game' of github.com:xeejp/xee into Tat-host-start
2 parents 95d9975 + ebd93ff commit 777cc5b

File tree

10 files changed

+124
-37
lines changed

10 files changed

+124
-37
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
[submodule "require/vardb"]
1111
path = require/vardb
1212
url = https://github.com/ryo33/VariablesDB-php.git
13-
[submodule "require/tediff"]
14-
path = require/tediff
15-
url = https://github.com/ryo33/lwte-diff-php.git
1613
[submodule "require/modui"]
1714
path = require/modui
1815
url = https://github.com/ryo33/ModUI-php.git

game/test/admin.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
$_modui->add(new StringUI('test'));

game/test/index.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
class TestUI extends ModUIComponent{
4+
5+
private $value;
6+
7+
public function __construct($value){
8+
$this->value = $value;
9+
}
10+
11+
public function get_template_name($name){
12+
return 'test';
13+
}
14+
15+
public function get_templates($name){
16+
$template = <<<TMPL
17+
<p>{value}</p>
18+
<input id="{name}" type="text" value="{value}">
19+
<button id="{name}-button">update</button>
20+
TMPL;
21+
return ['test' => $template];
22+
}
23+
24+
public function get_values($name){
25+
return ['value' => $this->value];
26+
}
27+
28+
public function get_scripts($name){
29+
return ["function(selector){return $(\"#$name\").val();}", "$(\"$name-button\").click(update);"];
30+
}
31+
32+
public function input($name, $value){
33+
}
34+
35+
}
36+
37+
$_modui->add(new TestUI('It\'s a test.'));

index.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
$_loader->register_directory(__DIR__ . '/require/model');
2424
$_loader->register_directory(__DIR__ . '/require/rplib');
2525
$_loader->register_directory(__DIR__ . '/require/diffdb');
26-
$_loader->register_directory(__DIR__ . '/require/tediff');
2726
$_loader->register_directory(__DIR__ . '/require/vardb');
2827
$_loader->register_directory(__DIR__ . '/require/modui');
2928
$_loader->register_directory(__DIR__ . '/modui_components');

js/game.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

modui_components/StringUI.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
class StringUI extends ModUIComponent{
4+
5+
private $value;
6+
7+
public function __construct($value){
8+
$this->value = $value;
9+
}
10+
11+
public function get_template_name($name){
12+
return 'string';
13+
}
14+
15+
public function get_templates($name){
16+
$template = <<<TMPL
17+
<input id="{name}" type="text" value="{value}">
18+
TMPL;
19+
return ['string' => $template];
20+
}
21+
22+
public function get_values($name){
23+
return ['value' => $this->value];
24+
}
25+
26+
public function get_scripts($name){
27+
return ["function(selector){return $(\"#$name\").val();}", ''];
28+
}
29+
30+
public function input($name, $value){
31+
}
32+
33+
}

page/api/index.php

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,55 @@
11
<?php
2+
define('NEXT_DEFAULT', 5000);
23

4+
$_vdb = new VarDB($_pdo, 'experiment-' . $_experiment['id']);
5+
$_page = $_vdb->get('_page');
6+
$_modui = new ModUI('test', new NormalContainer());
7+
require DIR_ROOT . 'game/' . $_game_id . '/index.php';
38
if($_request->request_method === Request::GET){
4-
$_ted = new TEDiff($_pdo);
5-
$_vdb = new VarDB($_pdo, 'experiment-' . $_experiment['id']);
9+
$_modui->enable_auto_reload(5000, <<<JS
10+
function(){
11+
$.ajax({
12+
url: window.location.pathname,
13+
method: "POST",
14+
dataType: "json",
15+
data: { _page: current_page }
16+
}).done(function(data){
17+
if(data == 'reload'){
18+
location.reload(true);
19+
}else
20+
update_auto('test', data, lwte);
21+
}
22+
});
23+
}
24+
JS
25+
);
26+
$_result = $_modui->display();
27+
28+
$_tmpl = new Template();
29+
foreach($_result['templates'] as $key => $template){
30+
$_tmpl->lwte_add($key, $template);
31+
}
32+
$_tmpl->lwte_use('#container', 'test', $_result['values']);
33+
$_tmpl->add_script($_result['script']);
34+
$_tmpl->add_script(<<<JS
35+
function update_modui(name, value){
36+
$.ajax({
37+
url: window.location.pathname,
38+
method: "POST",
39+
dataType: "json",
40+
data: { "name": name, "value": JSON.stringify(value)}
41+
}).done(function(data){
42+
$("#container").html(lwte.useTemplate("test", data));
43+
});
44+
}
45+
JS
46+
);
47+
echo $_tmpl->display();
648
}else{
49+
if($_POST['_post'] !== $_page){
50+
header('Content-Type: application/json');
51+
echo json_encode('reload');
52+
exit();
53+
}
54+
$_modui->input($_POST);
755
}

require/tediff

Lines changed: 0 additions & 1 deletion
This file was deleted.

tables.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,4 @@
3131
$_ddb->addTable($name, $structure);
3232
}
3333
$_vdb->setup($_ddb);
34-
$_tediff = new TEDiff($_pdo, null);
35-
$_tediff->setup($_ddb);
3634
$_ddb->updateDB();

0 commit comments

Comments
 (0)