Browse Source

默认主题增加书签搜索功能

pull/4/merge
xiaoz 4 years ago
parent
commit
b679f9feea
  1. 14
      controller/index.php
  2. 17
      templates/default/index.php
  3. 37
      templates/default/static/embed.js
  4. 1
      templates/default/static/holmes.js
  5. 3
      templates/default/static/style.css
  6. 2
      version.txt

14
controller/index.php

@ -63,6 +63,17 @@ function getIP() { @@ -63,6 +63,17 @@ function getIP() {
}
return $ip;
}
//获取版本号
function get_version(){
if( file_exists('version.txt') ) {
$version = @file_get_contents('version.txt');
return $version;
}
else{
$version = 'null';
return $version;
}
}
//判断用户是否已经登录
function is_login(){
$key = md5(USER.PASSWORD.getIP().'onenav');
@ -90,6 +101,9 @@ function base64($url){ @@ -90,6 +101,9 @@ function base64($url){
$new_url = $scheme.$host.$port;
return base64_encode($new_url);
}
//获取版本号
$version = get_version();
// 载入前台首页模板
require('templates/'.TEMPLATE.'/index.php');
?>

17
templates/default/index.php

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel='stylesheet' href='https://libs.xiaoz.top/mdui/v1.0.1/css/mdui.min.css'>
<link rel="stylesheet" href="https://libs.xiaoz.top/font-awesome/4.7.0/css/font-awesome.css">
<link rel="stylesheet" href="templates/<?php echo TEMPLATE; ?>/static/style.css">
<link rel="stylesheet" href="templates/<?php echo TEMPLATE; ?>/static/style.css?v=<?php echo $version; ?>">
<script src = 'https://libs.xiaoz.top/mdui/v1.0.1/js/mdui.min.js'></script>
</head>
<body class = "mdui-drawer-body-left mdui-appbar-with-toolbar mdui-theme-primary-indigo mdui-theme-accent-pink mdui-theme-layout-auto mdui-loaded">
@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
<!-- <div class="mdui-col-lg-3">
<div class="mdui-textfield mdui-textfield-expandable mdui-float-right">
<button class="mdui-textfield-icon mdui-btn mdui-btn-icon"><i class="mdui-icon material-icons">search</i></button>
<input class="mdui-textfield-input" type="text" placeholder="Search"/>
<input class="mdui-textfield-input search" type="text" placeholder="Search"/>
<button class="mdui-textfield-close mdui-btn mdui-btn-icon"><i class="mdui-icon material-icons">close</i></button>
</div>
</div> -->
@ -77,6 +77,16 @@ @@ -77,6 +77,16 @@
<!--正文内容部分-->
<div class="mdui-container">
<!-- 搜索框 -->
<div class="mdui-row">
<div class="mdui-col-xs-12">
<div class="mdui-textfield mdui-textfield-floating-label">
<label class="mdui-textfield-label">输入书签关键词进行搜索</label>
<input class="mdui-textfield-input search" type="text" />
</div>
</div>
</div>
<!-- 搜索框END -->
<div class="mdui-row">
<!-- 遍历分类目录 -->
<?php foreach ( $categorys as $category ) {
@ -145,5 +155,6 @@ @@ -145,5 +155,6 @@
//var inst = new mdui.Drawer(selector, options);
</script>
<script src = 'https://libs.xiaoz.top/jquery/2.2.4/jquery.min.js'></script>
<script src="templates/<?php echo TEMPLATE; ?>/static/embed.js"></script>
<script src = "templates/<?php echo TEMPLATE; ?>/static/holmes.js"></script>
<script src="templates/<?php echo TEMPLATE; ?>/static/embed.js<?php echo $version; ?>"></script>
</html>

37
templates/default/static/embed.js

@ -1,4 +1,41 @@ @@ -1,4 +1,41 @@
function gotop(){
$("html,body").animate({scrollTop: '0px'}, 600);
}
$(".search").blur(function(data,status){
var keywords = $(".search").val();
console.log(keywords);
if( keywords == ''){
$(".mdui-typo-title").removeClass("mdui-hidden");
}
});
var h = holmes({
input: '.search',
find: '.link-space',
placeholder: '<h3>未搜索到匹配结果!</h3>',
mark: false,
hiddenAttr: true,
// 找到了就添加visible类,没找到添加mdui-hidden
class: {
visible: 'visible',
hidden: 'mdui-hidden'
},
onHidden(el) {
// console.log('hidden', el);
},
onFound(el) {
// console.log('found', el);
$(".mdui-typo-title").addClass("mdui-hidden");
},
onInput(el) {
$(".mdui-typo-title").addClass("mdui-hidden");
},
onVisible(el) {
$(".mdui-typo-title").removeClass("mdui-hidden");
},
onEmpty(el) {
$(".mdui-typo-title").removeClass("mdui-hidden");
}
});
//鼠标移动到链接修改为原始URL

1
templates/default/static/holmes.js

File diff suppressed because one or more lines are too long

3
templates/default/static/style.css

@ -85,3 +85,6 @@ footer a{ @@ -85,3 +85,6 @@ footer a{
font-size: 40px; color: #1E9FFF;
font-weight: bold;
}
.hidden {
display: none;
}

2
version.txt

@ -1 +1 @@ @@ -1 +1 @@
v0.9.4-20201219
v0.9.5-20201220
Loading…
Cancel
Save