-
Notifications
You must be signed in to change notification settings - Fork 3
/
search.html
executable file
·129 lines (113 loc) · 3.97 KB
/
search.html
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
[%- pagetitle = 'SEARCHMUSIC' | string %]
[%- pageicon = icons.SEARCHMUSIC %]
[% extJsScripts = BLOCK %]
<script type="text/javascript" src="[% webroot %]html/Browse.js?r=[% revision %]"></script>
<script type="text/javascript">
Ext.onReady(function(){
var sinput = new Ext.form.TextField({
applyTo: 'livesearch',
validationDelay: 100,
validateOnBlur: false,
selectOnFocus: true,
searches: [
[% FOREACH search = searches %]
{
id: 'result[% loop.index %]',
hd: 'header[% loop.index %]',
url: '[% search.values.0 %]'
}[% loop.last ? '' : ',' %]
[% END %]
],
validator: function(value, force){
var el;
if (value.length > 2 || force) {
for (var i=0; i<this.searches.length; i++) {
if (el = Ext.get(this.searches[i].id)) {
// don't wait for an earlier update to finish
if (el.getUpdateManager().isUpdating())
el.getUpdateManager().abort();
el.load({
url: this.searches[i].url,
method: 'GET',
params: {
q: value,
player: player,
ajaxUpdate: 1,
ajaxSearch: 1,
index: i
},
callback: function(el, success, response, options) {
Highlighter.init();
SqueezeJS.UI.ScrollPanel.init();
// we need to fix the URL, as the returned values are relative to the search path
var a = Ext.DomQuery.select("a[class=browseItemLink]", options.thisSearch.id);
for (i=0; i<a.length; i++) {
a[i].href = a[i].href.replace(/index.html/g, "clixmlbrowser/clicmd=browselibrary+items&linktitle=SEARCH&mode=search/");
}
var l = Ext.DomQuery.select("div[class*=browsedbListItem]", options.thisSearch.id).length;
var t = Ext.get(options.thisSearch.id).child('div[id="total"]');
var c = t ? parseInt(t.getAttribute('value')) : 0;
var m = '';
if (!c) {
m = '[%- "NONE" | string %]';
} else if (l && c && c > 1 && l < c) {
m += l + ' / ' + c + ': <a href="clixmlbrowser/clicmd=browselibrary+items&linktitle=SEARCH&mode=search/X?index='
+ options.params.index + '&q=' + options.params.q + '">[%- "MORE" | string %]</a>...';
}
Ext.get(options.thisSearch.hd).update(m);
},
thisSearch : this.searches[i]
});
}
}
}
return true;
},
// overwrite default filter to ignore key modifiers
filterValidation : function(e){
if(!e.isNavKeyPress() && !e.isSpecialKey()){
this.validationTask.delay(this.validationDelay);
}
}
});
[% IF query %]
sinput.validator('[% query | replace("'", " ") %]', true);
[% END %]
new Ext.Button({
renderTo: 'searchButton',
text: '[% "SEARCH" | string %]',
type: 'submit',
handler: function(){
document.getElementById("searchForm").submit();
}
});
Browse.init();
});
</script>
[% END %]
[% pwd_list = BLOCK %]
<a href="search.html?player=[% playerURI %]">[% "SEARCH" | string %]</a>
[% END %]
[% PROCESS pageheader.html dontscroll=browse_items.size %]
<div class="searchHeader">
<form id="searchForm" name="searchForm" method="GET" action="search.html">
<table><tr>
<td><input type="text" id="livesearch" name="query" size="30" value="[% query | html %]" autocomplete="off"/></td>
<td><span id="searchButton"></span></td>
<td id="advSearchLink" class="link"><a href="[% webroot %]advanced_search.html?player=[% playerid %]">[% "ADVANCEDSEARCH" | string %]</a></td>
</tr></table>
<input type="hidden" value="[% player %]" name="player">
</form>
</div>
<div id="browsedbHeader">
[% IF searchError %]
[% searchError %]
[% END %]
</div>
<div id="browsedblist">
[% FOREACH search = searches %]
<div class="searchResultHeader">[% search.keys.0 %]: <span id="header[% loop.index %]"></span></div>
<div id="result[% loop.index %]"></div>
[% END %]
</div>
[% PROCESS pagefooter.html %]