-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.php
138 lines (137 loc) · 4.95 KB
/
demo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
// require 'test.lib.php';
require 'vendor/autoload.php';
use \TangHoong\ChatBlock\ChatBlock as ChatUI;
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<title>Chatblock tutorial</title>
<meta name="description" content="">
<style>
body{
margin: 0;
padding: 0;
background:#eee;
}
.chatblock {
padding: 20px;
}
</style>
</head>
<body>
<?php
// Sources
$page = @$_GET['page'];
switch($page)
{
default:
$sample = file_get_contents('./tutorial/0-toc.txt');
break;
case '1':
$sample = file_get_contents('./tutorial/1-basic.txt');
break;
case '2':
$sample = file_get_contents('./tutorial/2-all-commands.txt');
break;
case '3':
$sample = file_get_contents('./tutorial/3-advance.txt');
break;
case '4':
$sample = file_get_contents('./tutorial/4-creative.txt');
break;
case '5':
$sample = file_get_contents('./tutorial/5-tell-a-stories.txt');
break;
case '6':
$sample = file_get_contents('./tutorial/6-starter.txt');
break;
case '99':
$sample = getAPIData(5);
var_dump($sample);
break;
// Dev sample stories
case '100':
$sample = file_get_contents('./sample/sample.txt');
break;
case '101':
$sample = file_get_contents('./sample/emanyan.1.txt');
break;
case '102':
$sample = file_get_contents('./sample/sample.2.txt');
break;
case '103':
$sample = file_get_contents('./sample/sample.custom.colon.txt');
break;
case '104':
$sample = file_get_contents('./sample/sep.1.txt');
break;
case '105':
$sample = file_get_contents('./sample/starter.template.txt');
break;
case '106':
$sample = file_get_contents('./sample/test.raw.txt');
break;
case '107':
$sample = file_get_contents('./sample/story.2.1.txt');
break;
case 'youfeng':
$sample = file_get_contents('./sample/youfeng.txt');
break;
case 'links':
$sample = file_get_contents('./sample/links.txt');
case '108':
$sample = file_get_contents('./sample/test.raw.2.txt');
break;
case 'report':
$sample = file_get_contents('./sample/report.txt');
break;
}
//
// start from here
// $cui = new ChatUI();
$cui = new ChatUI([
'allowForkScript' => 'https://editor.chatnovel.app/', // default:null
'mainCastColor' => '#198754',
'castColorMode' => 'palette', // none, random, palette
'chatHeaderSize' => 'large' // default:normal ,small, large
]);
// $cui->setColon([':']); // en, default
$cui->setColon([':']); // zh
$cui->setNarrator(['Narrator','narrator','系统','旁白']);
echo sprintf('<style>%s</style>', $cui->renderCss());
$cui->feed($sample);
echo $cui->render();
?>
<style>
/* .rawscript-chatblock-container{
height: 30px;
} */
.rawscript-chatblock-editor button{
display: block;
}
</style>
<script async defer>
/* Ignore below, no copy needed */
function toggleHeight() {
var rawscriptContainer = document.querySelector(".rawscript-chatblock-container");
var rawscriptContainerToggle = document.querySelector(".rawscript-chatblock-container a");
var toggleStatus = rawscriptContainerToggle.dataset.toggle;
if( rawscriptContainerToggle.dataset.toggle == 'collapse' )
{
rawscriptContainerToggle.dataset.toggle = 'expand';
rawscriptContainer.style.height = '100%';
}else{
rawscriptContainerToggle.dataset.toggle = 'collapse';
rawscriptContainer.style.height = '30px';
}
}
document.addEventListener('DOMContentLoaded', function() {
var rawscriptContainerToggle = document.querySelector(".rawscript-chatblock-container a");
rawscriptContainerToggle.addEventListener("click", toggleHeight, false);
});
</script>
</body>
</html>