dialogues / index.html
KikiQiQi's picture
Update index.html
12679ee
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>选择对话框页面</title>
</head>
<body>
<label for="dialogueSelector">选择对话框:</label>
<select id="dialogueSelector" onchange="loadDialogue()"></select>
<div id="dialogueContainer">
<!-- 这里将显示选定的对话框页面的内容 -->
</div>
<script>
// 文件名的前缀和总数
var prefixes = ['dialogue-4-', 'dialogue-3.5-'];
var totalFiles = 9;
// 获取选择框元素
var selectElement = document.getElementById('dialogueSelector');
// 动态生成选项
for (var j = 0; j < prefixes.length; j++) {
for (var i = 0; i <= totalFiles; i++) {
var option = document.createElement('option');
option.value = prefixes[j] + i + '.html';
option.textContent = prefixes[j] + i;
selectElement.appendChild(option);
}
}
function loadDialogue() {
var selectedValue = selectElement.value;
var dialogueContainer = document.getElementById('dialogueContainer');
// 使用 Fetch API 异步加载选定的对话框页面
fetch(selectedValue)
.then(response => response.text())
.then(data => {
// 将页面内容设置为对话框容器的innerHTML
dialogueContainer.innerHTML = data;
})
.catch(error => console.error('Error loading dialogue:', error));
}
// 页面加载时默认加载第一个对话框页面
loadDialogue();
</script>
</body>
</html>