-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathkey.php
121 lines (101 loc) · 3.9 KB
/
key.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
<?php include 'include/header.php'; ?>
<?php include '../geturl/urlhtml.php'; ?>
<div class="container">
<div class="bs-callout bs-callout-danger">
<h1>关键字匹配文章</h1>
<p>随意输入中英文、拼音……关键字,列出相关文章</p>
<strong class="text-danger">数据爬取自搜索引擎!</strong>
</div>
<div class="row">
<label class="col-sm-2 control-label"><h4>任意字符:</h4></label>
<div class="col-sm-6">
<label for="searchKey" class="placeholder">请输入………</label>
<input type="text" class="form-control" id="searchKey" name="searchKey" value="">
</div>
<div class="col-sm-2">
<div class="input-group">
<div class="input-group-addon">第</div>
<input type="text" class="form-control" id="pageNum" name="pageNum" value="1">
<div class="input-group-addon">页</div>
</div>
</div>
<div class="col-sm-2">
<input type="submit" class="btn btn-primary searchGo" value=" G O " />
</div>
</div>
<div class="row">
<label class="col-sm-2 contro-label">随便选一个</label>
<div class="col-sm-10 random">
<label class="col-sm-1 contro-label">创业</label>
<label class="col-sm-1 contro-label">机器人</label>
<label class="col-sm-1 contro-label">热门职位</label>
<label class="col-sm-1 contro-label">APEC</label>
<label class="col-sm-1 contro-label">大数据</label>
<label class="col-sm-1 contro-label">购物</label>
</div>
</div>
</div>
<div class="container">
<div class="row">
<iframe id="refresh_view" width="100%" frameborder='0' scrolling="no" ></iframe>
</div>
</div>
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
<script src="../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript">
$('#header').find('li').eq(3).attr('class','active');
var randomLabel = $('.random').find('label'),
searchKey = $('#searchKey'),
searchGo = $('.searchGo'),
pageNum = $('#pageNum'),
placeholder = $('.placeholder'),
key_GET = decodeURIComponent("<?php echo isset($_GET['key']) ? $_GET['key'] : '请输入………'; ?>");
if (key_GET==='请输入………'){
}else{
placeholder.text(key_GET);
placeholder.addClass('placeholderHigh');
//执行搜索
urlhtmlResult(key_GET,pageNum.val());
};
//聚焦判断
$('#searchKey').on('focusin focusout', function(){
placeholder.toggleClass('none');
if (searchKey.val()!='') {
placeholder.addClass('none');
}else{
placeholder.removeClass('none');
};
});
//随便选一个
randomLabel.on('click',function(){
var thisText = $(this).text();
searchKey.val('');
placeholder.removeClass('none').text(thisText).addClass('placeholderHigh');//显示label,值,高亮
//searchKey.val(thisText);//设置value
//执行搜索
urlhtmlResult(thisText,pageNum.val());
});
//搜索判断
searchGo.on('click', function(){
if (searchKey.val()==''&&placeholder.text()=='请输入………') {
$('#searchKey').addClass('redborder');
}else{
nowKey = searchKey.val()=='' ? placeholder.text() : searchKey.val();
//console.log(nowKey);
//执行搜索
urlhtmlResult(nowKey,pageNum.val());
};
});
//var domain = window.location.host;
function urlhtmlResult(key,page){
var searchtype = '1',
url = '../geturl/searchapi.php?postkey='+key+'&pagenum='+page+'&searchtype='+searchtype;
$('#refresh_view').attr('src',url);
//调试
//link = 'http://weixin.sogou.com/weixin?query='+key+'&type=2&page=1&ie=utf8';
//var href = window.location.href;
//window.location.href = href.substr(0, href.indexOf('#')) + '#' + link;
return false;
}
</script>
<?php include 'include/footer.php'; ?>