mirror of
https://gitee.com/tawords/tawords
synced 2025-09-13 05:41:39 +08:00
80 lines
2.9 KiB
PHP
80 lines
2.9 KiB
PHP
<?php
|
|
/*
|
|
* 页面: 查单词
|
|
* 版本号: 1.0.0
|
|
* 修改时间: 2020.08.16
|
|
* 备注: 可上线
|
|
*
|
|
* 调用前需要的变量:
|
|
* 必须变量:
|
|
* $
|
|
* 可选变量:
|
|
* $ 备注
|
|
*
|
|
*/
|
|
?>
|
|
|
|
<!--标题-->
|
|
<div style="text-align: center; margin-top:1em; margin-bottom:-2.5em; font-weight:400;">
|
|
<!-- 标题 -->
|
|
<h1>查单词</h1>
|
|
</div>
|
|
|
|
<!-- 文本框 -->
|
|
<div class="mdui-textfield mdui-textfield-floating-label" mdui-tooltip="{content: '请输入您要查询的英文单词,然后按回车或点击下方的按钮'}">
|
|
<i class="mdui-icon material-icons">search</i>
|
|
<label class="mdui-textfield-label">查英语单词</label>
|
|
<input id="searchword" class="mdui-textfield-input" type="text" value="<?=isset($word)?$word:''?>" autocomplete="off" onmouseover="this.focus()" onfocus="this.select()" />
|
|
<div class="mdui-textfield-helper">请输入您要查询的英文单词,然后按回车或点击下方的按钮</div>
|
|
</div>
|
|
<script>
|
|
const obj = document.getElementById("searchword");
|
|
|
|
//回车搜索
|
|
$('#searchword').bind('keydown', function (event) {
|
|
var event = window.event || arguments.callee.caller.arguments[0];
|
|
if (event.keyCode == 13){
|
|
dosearch()
|
|
}
|
|
});
|
|
function dosearch(){
|
|
window.location.href = "./?page=<?=$page?>&word=" + urlencode(obj.value.trim());
|
|
}
|
|
function doclean(){
|
|
obj.value = "";
|
|
obj.focus();
|
|
}
|
|
function urlencode (str) {
|
|
str = (str + '').toString();
|
|
|
|
return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
|
|
replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
|
|
}
|
|
</script>
|
|
<div class="mdui-container">
|
|
<div class="mdui-row">
|
|
<div class="mdui-col-offset-sm-3 mdui-col-sm-3">
|
|
<button style="width:100%;" class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme" onclick='dosearch()'>
|
|
<i class="mdui-icon material-icons">search</i>搜索
|
|
</button>
|
|
</div>
|
|
<div class="mdui-col-sm-3 ">
|
|
<button style="width:100%;" class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme-100" onclick='doclean()'>
|
|
<i class="mdui-icon material-icons">clear</i>清除
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<?php
|
|
if(!isset($word) || !$word || trim($word) == ""){
|
|
$word = "";
|
|
} else {
|
|
// 单词展示模块
|
|
?><!-- 分割线 -->
|
|
<div class="mdui-divider" style="margin-top:1.8em; margin-bottom:1.8em;"></div><?php
|
|
require_once __DIR__."/component/words-block/words-block.php";
|
|
$word_block = new word_block();
|
|
$word_block -> show($word/*单词*/, true/*显示单词*/, true/*显示音标*/, true/*显示中文*/, true/*显示信息*/, false/*显示刷新按钮*/, false/*显示控制按钮*/);
|
|
}
|