-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
170 lines (145 loc) · 8.92 KB
/
index.html
File metadata and controls
170 lines (145 loc) · 8.92 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>定型文生成器</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
.container {
max-width: 600px;
margin: 0 auto;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
width: 100%;
padding: 8px;
box-sizing: border-box;
}
.result {
margin-top: 20px;
padding: 20px;
border: 1px solid #ccc;
background-color: #f9f9f9;
white-space: pre-wrap;
/* 保留空白和换行 */
word-wrap: break-word;
/* 防止长单词溢出 */
}
</style>
</head>
<body>
<nav>
<a href="./ipv4.html">IPv4 Miscellaneous</a>
</nav>
<div class="container">
<h1>定型文生成器</h1>
<button id="copy", onclick="gocopy()">复制</button>
<form id="myForm">
<div class="form-group">
<label for="articleSelect">选择一篇文章:</label>
<select id="articleSelect" name="articles">
<option value="">请选择...</option>
<!-- 选项可以根据需要添加更多 -->
<option value="kim">Kim</option>
<option value="secondgame">乙游大世界</option>
<option value="showmaker">Showmaker</option>
<option value="self_intro">自我介绍</option>
</select>
</div>
<div class="form-group">
<label for="replacements">替换指令 (格式: < 标签>:content):</label>
<textarea id="replacements" name="replacements" rows="4" placeholder="例如:<name>:张三"></textarea>
</div>
</form>
<div class="result" id="result">
<p>定型文将显示在这里。</p>
</div>
</div>
<script>
// 示例文章,可以根据需要添加更多
var old = -1;
var replaceResult = "";
function gocopy(){
if(document.getElementById('result').querySelector('p').textContent != "")
navigator.clipboard.writeText(document.getElementById('result').querySelector('p').textContent);
console.log(document.getElementById('result').querySelector('p').textContent);
}
const articles = {
kim: "从<location1>访问回来的<people1>全然不顾身体的疲惫,连夜找我们几个<attribute1>的<people2>商量<event1>。谈得晚了,便送我们出<location2>,要<people3>送我们回<location3>。\
在去<location4>的路上,我们说:“<people1>,您回去休息吧。您刚从<location1>回来。”<people1>摇摇头,\
“不碍事,你们知道现在<category1>世界有很多<category_people>不支持<feature1>,不断给我们制造<problem1>。你们是<attribute1><people2>的未来,你们的事情便是<people2>的大事,是头等大事。”我们都激动了,眼里噙着<tear1>。多好的<people1>呀。\
<people1>抬头看看<location3>说:“如果世界真像这<location3>这么有序就好了,但是就有一些低级<category_people>,像<enemy2>、<enemy3>,要搞乱这个世界,他们是罪人。”\
说着,<people1>弯下腰,从<location5>里捡出一个<item1>,然后看着<location3>说:“该死的<enemy1>。”\
说着他把<item1>奋力向上一抛。很快就见一块<location6>突然爆发出耀眼的<phenomenon1>,然后就崩溃下来。“这是<category_people>的<enemy_weapon>,他们一直在<location6>里<enemy_behavior>,破坏我们的<treasure>,我已经忍了很久了。”<people1>愤愤地说。<attribute1>的<people2>们都鼓起掌来,为<category1>界有这样的领导者感到自豪。\
一会儿,<people1>叫来<people3>问:“那个<item1>抛到什么地方了?”“好像是<location7>。”<people3>说。\
<people1>一怔,说:“赶紧派<people4>去查,看有什么问题没有。”之后<people1>送我们到<location4>门口,一直挥手到看不见我们。\
第四天我们听说<location7>那边出事了,我们很紧张。而这时<people1>叫我们过去。\
他依然那么慈祥,让我们坐下说:“<career1>总是要有牺牲的。为<career1>牺牲的<item1>是伟大的。”他这时低下头说:“但我必须承认,我当时<behavior1>的行为太鲁莽了,我在这里向<location1>道歉。我将向<location1>说明情况。”\
我们顿时热泪盈眶,多好的<people1>呀,他在跟<category_people>斗争过程中的小失误竟然被他记在心里,还道了歉。我们在将来的学习中一定要向<people1>学,学他老人家那宽广的胸怀,和不耻下问的精神。",
secondgame: "<subject>简直就是一个乙游大世界。\
想要<attr1>,<attr2>有<item1>;\
想要<attr3>有<item2>;\
如果想要我们的<attr4>还有<item3>;\
要我说,你们<object>吃的也真是太好了吧;\
今天我已经垂直入坑了!",
showmaker: "那一年的<match>是<teamA>对<teamB>,最终<score>。当时我看见<player>坐在椅子上泣不成声,那一刻我就在想如果我能成为<profession>,我一定要赢下所有。如今奖杯就在眼前,我必须考虑这会不会是我此生仅有的机会。我相信<organization>能有过去的霸主地位,<player>功不可没。重铸<organization>的荣光,我辈义不容辞!",
self_intro: "<age1>岁的时候我想成为<profession>,<relative>和我说还太早了。今年是我想<career>的第<time1>个年头,我已经<age2>岁了,同龄且曾经相识的<player1>已经拿到了<title1>,而我才刚刚进入<organization1>。希望自己像bgm一样——别怕变老吧。我会一直努力下去,直到实现我的梦想。\n<grade>级<university><major><hierarchy>在读<game1>时长<time2>h/<achievement1>\n感谢<guider1>老师,老师的复盘真的很有用,收获很多,想提升思路的同学们真的可以冲!感谢<guider2><guider3><guider4><guider5><guider6>愿意相信我和我一起组队。感谢<guider7> 在<skill1>上对我的指点 感谢所有鼓励我相信我并愿意陪着我的伙伴们,我爱你们。希望这个长达<time3>年的故事能在今年回归主线,感谢你能看到这里!如果想要了解更多,主页置顶有自我介绍。"
};
document.getElementById('articleSelect').addEventListener('change', function () {
updateResult();
});
document.getElementById('replacements').addEventListener('input', function () {
updateResult();
});
function updateResult() {
const selectedArticle = document.getElementById('articleSelect').value;
const replacements = document.getElementById('replacements').value;
const resultElement = document.getElementById('result').querySelector('p');
if (!selectedArticle || !articles[selectedArticle]) {
resultElement.textContent = '请选择一篇文章。';
return;
}
let articleText = articles[selectedArticle];
// 解析替换指令
const regex = /<([^>]+)>:(.*?)(?=<|$)/g;
let match;
while ((match = regex.exec(replacements)) !== null) {
const tag = match[1];
const content = match[2].trim().replace(/\\/g, '\\\\').replace(/</g, '\\<').replace(/>/g, '\\>'); // 转义特殊字符
const replacementRegex = new RegExp(`<${tag}>`, 'g');
articleText = articleText.replace(replacementRegex, content);
}
if (old != selectedArticle) {
const tag_regex = /<([^>]+)>/g;
let all_tags = new Set(articleText.match(tag_regex));
//console.log(all_tags);
document.getElementById("replacements").value = "";
all_tags.forEach(function(value){
//console.log(typeof(value));
document.getElementById("replacements").value += value + ":" + value + " ";
})
//let it = all_tags.values();
/*for(let i = 0; i < all_tags.size; i++) {
console.log(all_tags);
document.getElementById("replacements").value += toString(all_tags[i]) + ":" + toString(all_tags[i]) + " ";
}*/
}
old = selectedArticle;
resultElement.textContent = articleText;
replaceResult = document.articleText;
}
</script>
</body>
</html>