-
Notifications
You must be signed in to change notification settings - Fork 0
/
js.js
448 lines (409 loc) · 15.8 KB
/
js.js
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
// JavaScript Document
var getWhereFilterEvents=false;
function loadMoreRecords()
{
var extraUrl='';
if(getWhereFilterEvents)//if load more records after serching the box
{
// alert(1);
var dateValue=$( "#inputField" ).val();
var fromTime=$( "#fromTime" ).val();
var toTime=$( "#toTime" ).val();
extraUrl="&dateValue="+dateValue+"&fromTime="+fromTime+"&toTime="+toTime;
}
var currOffset=parseInt($('#indexPage').val());
var nextOffset=currOffset+1;
var currentCat=parseInt($('#currentCat').val());
document.getElementById('indexPage').value=nextOffset;
allowRun=false;
$.ajax({
type: "POST",
url: "ajax.php",
data: "action=loadMoreRecords&nextOffset="+nextOffset+"¤tCat="+currentCat+extraUrl,
cache: false,
success: function(html){
// document.getElementById('loaderImg').style.display='none';
if(html!=0)
{
document.getElementById('SuggestedEvent').style.height=parseInt( document.getElementById('SuggestedEvent').style.height)+500+'px';
document.getElementById('SuggestedEvent').innerHTML+=html;
allowRun=true;
}else
{
//document.getElementById('endRecords').style.display='block';
}
}
});
}
/*
search header box values
*/
var currentSelectedcat=0;
var filterList=filterListBoxTwo=keyWordsData='';
function doFilter(filterListResult)
{
}
var vIndex=0;
var vIndexDataTwo=0;
function filterData()
{
if(event.keyCode == 40 || event.keyCode == 38) {
return '';
}
var filterListData=filterList.split(',');
var data='<ul style="list-style:none">';
var v=document.getElementById('tags').value;
var j=vIndex=0;
for(var i=0;i<filterListData.length;i++)
{
if(filterListData[i].toLowerCase().match(v.toLowerCase()))
{
data+='<li id="index_'+j+'" onmouseover="clickElementFillField(\'tags\',\''+filterListData[i]+'\',\'filterList\')" class="filterListLable">'+filterListData[i]+'</li>';
j++;
}
}
data+='</ul>';
document.getElementById('filterList').innerHTML=data;
document.getElementById('filterList').style.top=document.getElementById('tags').offsetTop+25+'px';
document.getElementById('filterList').style.left=document.getElementById('tags').offsetLeft+'px';
document.getElementById('filterList').style.display='block';
}
/* fill selected value on the box*/
function clickElementFillField(filledValue,clickedValue,filterListLable)
{
document.getElementById(filledValue).value=clickedValue;
//document.getElementById(filterListLable).style.display='none';
//document.getElementById(filledValue).blur();
}
window.onkeydown = keydown;
function keydown() {
//closeCalendar() /* data one*/
if(document.getElementById('filterList'))
{
if(document.getElementById('filterList').style.display=='block')
{
if(event.keyCode == 40) {//up
if(vIndex<=0)
vIndex=0;
if((vIndex-1)>=0)
document.getElementById("index_"+(vIndex-1)).className='ddlHover';
document.getElementById("index_"+vIndex).className='ddlout';
vIndex++;
}
if(event.keyCode == 38) {//down
if(vIndex<=0)
vIndex=0;
document.getElementById("index_"+vIndex).className='filterList ddlHover';
if((vIndex)>=0)
document.getElementById("index_"+(vIndex-1)).className='filterList ddlout';
vIndex--;
}
if(event.keyCode == 13) {//enter
var cuurV=0;
if((vIndex-1)>0)
cuurV=(vIndex-1);
document.getElementById('tags').value=document.getElementById('index_'+cuurV).innerHTML;
document.getElementById('filterList').style.display='none';
document.getElementById('tags').blur();
}
if(event.keyCode == 27) {//escape
document.getElementById('tags').value='';
document.getElementById('filterList').style.display='none';
document.getElementById('tags').blur();
}
}
}
/* data two*/
if(document.getElementById('filterDataTwo'))
{
if(document.getElementById('filterDataTwo').style.display=='block')
{
if(event.keyCode == 40) {
if(vIndexDataTwo<=0)//up
vIndexDataTwo=0;
if((vIndexDataTwo-1)>=0)
document.getElementById("index_data_two_"+(vIndexDataTwo-1)).className='ddlHover';
document.getElementById("index_data_two_"+vIndexDataTwo).className='ddlout';
vIndexDataTwo++;
}
if(event.keyCode == 38) {///down
if(vIndexDataTwo<=0)
vIndexDataTwo=0;
document.getElementById("index_data_two_"+vIndexDataTwo).className='filterList ddlHover';
if((vIndexDataTwo)>=0)
document.getElementById("index_data_two_"+(vIndexDataTwo-1)).className='filterList ddlout';
vIndexDataTwo--;
}
if(event.keyCode == 13) {//enter
var cuurV=0;
if((vIndexDataTwo-1)>0)
cuurV=(vIndexDataTwo-1);
document.getElementById('tags2').value=document.getElementById('index_data_two_'+cuurV).innerHTML;
document.getElementById('filterDataTwo').style.display='none';
document.getElementById('tags2').blur();
}
if(event.keyCode == 27) {//escape
document.getElementById('tags2').value='';
document.getElementById('filterDataTwo').style.display='none';
document.getElementById('tags2').blur();
}
}
}
if(document.getElementById('filterListKeyWord'))
{
if(document.getElementById('filterListKeyWord').style.display=='block')
{
if(event.keyCode == 40) {//up
if(vIndexDataThree<=0)
vIndexDataThree=0;
if((vIndexDataThree-1)>=0)
document.getElementById("index_data_three_"+(vIndexDataThree-1)).className='ddlHover';
document.getElementById("index_data_three_"+vIndexDataThree).className='ddlout';
vIndexDataThree++;
}
if(event.keyCode == 38) {//down
if(vIndexDataThree<=0)
vIndexDataThree=0;
document.getElementById("index_data_three_"+vIndexDataThree).className='filterList ddlHover';
if((vIndexDataThree)>=0)
document.getElementById("index_data_three_"+(vIndexDataThree-1)).className='filterList ddlout';
vIndexDataThree--;
}
if(event.keyCode == 13) {//enter
var cuurV=0;
if((vIndexDataThree-1)>0)
cuurV=(vIndexDataThree-1);
document.getElementById('keywordValue').value=document.getElementById('index_data_three_'+cuurV).innerHTML;
document.getElementById('filterListKeyWord').style.display='none';
document.getElementById('keywordValue').blur();
}
if(event.keyCode == 27) {//escape
document.getElementById('keywordValue').value='';
document.getElementById('filterListKeyWord').style.display='none';
document.getElementById('keywordValue').blur();
}
}
}
}
/*
on key up do filter list
*/
function filterDataTwo()
{
if(event.keyCode == 40 || event.keyCode == 38) {
return '';
}
var filterListData=filterListBoxTwo.split(',');
var data='<ul style="list-style:none">';
var v=document.getElementById('tags2').value;
var j=vIndexDataTwo=0;
for(var i=0;i<filterListData.length;i++)
{
if(filterListData[i].toLowerCase().match(v.toLowerCase()))
{
data+='<li id="index_data_two_'+j+'" onmouseover="clickElementFillField(\'tags2\',\''+filterListData[i]+'\',\'filterDataTwo\')" class="filterListLable">'+filterListData[i]+'</li>';
j++;
}
}
data+='</ul>';
document.getElementById('filterDataTwo').innerHTML=data;
document.getElementById('filterDataTwo').style.top=document.getElementById('tags2').offsetTop+25+'px';
document.getElementById('filterDataTwo').style.left=document.getElementById('tags2').offsetLeft+'px';
document.getElementById('filterDataTwo').style.display='block';
}
/* get keyword data */
/* keyword filteration*/
function filterKeyWordData()
{
if(event.keyCode == 40 || event.keyCode == 38) {
return '';
}
var filterListDataKeyWord=keyWordsData.split(',');
var data='<ul style="list-style:none">';
var v=document.getElementById('keywordValue').value;
var j=vIndexDataThree=0;
for(var i=0;i<filterListDataKeyWord.length;i++)
{
if(filterListDataKeyWord[i].toLowerCase().match(v.toLowerCase()))
{
data+='<li id="index_data_three_'+j+'" onmouseover="clickElementFillField(\'keywordValue\',\''+filterListDataKeyWord[i]+'\',\'filterListKeyWord\')" class="filterListLable">'+filterListDataKeyWord[i]+'</li>';
j++;
}
}
data+='</ul>';
document.getElementById('filterListKeyWord').innerHTML=data;
document.getElementById('filterListKeyWord').style.top=document.getElementById('keywordValue').offsetTop+25+'px';
document.getElementById('filterListKeyWord').style.left=document.getElementById('keywordValue').offsetLeft+'px';
document.getElementById('filterListKeyWord').style.display='block';
}
function getKeywordsCategory(catId)
{
//-------------get sub cat list
$.ajax({
type: "POST",
url: "searchAjax.php",
data: "action=getKeywordsCategory&catId="+catId,
cache: false,
success: function(html){
keyWordsData=html;
}
});
///--------------
}
/*
build filter list box
*/
function getFilterList(searchCatList,secureSearchCatList,nextCat)
{
//-------------get sub cat list
$.ajax({
type: "POST",
url: "searchAjax.php",
data: "action=getSearchCatList&searchCatList="+searchCatList+"&secureSearchCatList="+secureSearchCatList+"&cat="+nextCat,
cache: false,
success: function(html){
filterList=html;
}
});
///--------------
}
function getFilterListDataTwo(table_for_sub_cat_box_2,table_for_sub_cat_box_2_secure,nextCat)
{
//-------------get sub cat list
$.ajax({
type: "POST",
url: "searchAjax.php",
data: "action=getFilterListDataTwo&searchCatList="+table_for_sub_cat_box_2+"&secureSearchCatList="+table_for_sub_cat_box_2_secure+"&cat="+nextCat,
cache: false,
success: function(html){
filterListBoxTwo=html;
}
});
///--------------
}
var previousCat='';
function showsearchBox(nextCat,secureCat,title,searchCatList,secureSearchCatList,table_for_sub_cat_box_2,table_for_sub_cat_box_2_secure,no_keyword_search,lable_one,lable_two,lable_three,lable_four,lable_five,lable_six,innerPage,lable_two_selected,lable_three_selected,lable_four_selected,lable_five_selected,lable_six_selected)
{
if(previousCat!='')
document.getElementById(previousCat).className='';
if(nextCat!=currentSelectedcat)
{
$( "#searchBox" ).slideUp();
previousCat=secureCat;
document.getElementById(secureCat).className='current';
currentSelectedcat=nextCat;
var disabledkeyword='';
if(no_keyword_search==1 || 1==1)
disabledkeyword='disabled=disabled';
var c='<div class="search">';
c+='<div class="thred"> <input type="text" value="'+lable_one+'" style="width:100%" class="inputStyle2" onfocus="emptyFiledKeepValue(\''+lable_one+'\',\'keywordValue\');getKeywordsCategory(\''+nextCat+'\')" onblur="checkFiledReturnValue(\'keywordValue\');hideElement(\'filterListKeyWord\')" id="keywordValue" onkeyup="filterKeyWordData()" /> </div>';
c+='<div class="thred" id="filterListKeyWord" class="filterDataBox" style="display:none;position: absolute;border: 1px solid;z-index: 2;background-color: #fff;list-style: none;"></div>';
c+='<div class="thred"> <input value="'+lable_two_selected+'" id="tags" type="text" style="width:100%" class="inputStyle2" onfocus="emptyFiledKeepValue(\''+lable_two+'\',\'tags\');getFilterList(\''+searchCatList+'\',\''+secureSearchCatList+'\',\''+nextCat+'\')" onkeyup="filterData()" onblur="checkFiledReturnValue(\'tags\');hideElement(\'filterList\')" /> </div>';
c+='<div class="thred" id="filterList" class="filterDataBox" style="display:none;position: absolute;border: 1px solid;z-index: 2;background-color: #fff;list-style: none;"></div>';
c+='<div class="thred"> <input value="'+lable_three_selected+'" name="" type="text" id="tags2" style="width:100%;display:block" class="inputStyle2" onfocus="emptyFiledKeepValue(\''+lable_three+'\',\'tags2\');getFilterListDataTwo(\''+table_for_sub_cat_box_2+'\',\''+table_for_sub_cat_box_2_secure+'\',\''+nextCat+'\')" onkeyup="filterDataTwo()" onblur="checkFiledReturnValue(\'tags2\');hideElement(\'filterDataTwo\')" /> </div>';
c+='<div class="thred" id="filterDataTwo" class="filterDataBox" style="display:none;position: absolute;border: 1px solid;z-index: 2;background-color: #fff;list-style: none;"></div>';
c+='<div class="thred DateThred"> <input type="text" style="width:100%" class="inputStyle2" id="inputFieldJS" name="inputFieldJS" value="'+lable_four_selected+'" onblur="" /> </div>';
c+='<div class="thred TimeThred"> <input name="" type="text" class="inputStyle2" id="fromTimeJs" value="'+lable_five_selected+'" />';
c+='<input type="text" style="width:48%; margin-left:-4px;display:none" class="inputStyle2" id="toTimeJs" value="'+lable_six_selected+'" /> </div>';
c+='<div class="thred" > <a href="javascript:" class="BlueBtn" onclick="buildSearchUrl(\''+nextCat+'\',\''+secureCat+'\',\''+lable_one+'\',\''+lable_two+'\',\''+lable_three+'\',\''+lable_four+'\',\''+lable_five+'\',\''+lable_six+'\')">Search '+title+' </a>';
/*if(innerPage!=nextCat)
c+='<a href="index.php?CategoryType='+title+'&catId='+nextCat+'&secureCat='+secureCat+'" class="goToPage BlueBtn"> Go to '+title+' page </a>';
c+='<a href="javascript:" onclick="hideSearchBox()" class="hideSearch">Hide<span ></span> </a> </div></div>';
*/
document.getElementById('searchBox').innerHTML=c;
$(function() {$('#fromTimeJs').timepicker({ 'step': 15 });$('#toTimeJs').timepicker({ 'step': 30 });});
$(function(){new JsDatePick({useMode:2, target:"inputFieldJS",dateFormat:"%d-%M-%Y"});});; //document.getElementById('searchBox').style.display='block';
$( "#searchBox" ).slideToggle();
doFilter(filterList);
}
}
/* build serach url for advance serach */
function buildSearchUrl(nextCat,secureCat,lable_one,lable_two,lable_three,lable_foure,lable_five,lable_six)
{
var url='advanceSearch.php?catId='+nextCat+'';
var goToPage=true;
if(document.getElementById('keywordValue').value!=lable_one)
{
url+='&keywordValue='+document.getElementById('keywordValue').value;
goToPage=false;
}
if(document.getElementById('tags').value!=lable_two)
{
url+='&tags='+document.getElementById('tags').value;;
goToPage=false;
}
if(document.getElementById('tags2').value!=lable_three)
{
url+='&tags2='+document.getElementById('tags2').value;;
goToPage=false;
}
if(document.getElementById('inputFieldJS').value!='' && document.getElementById('inputFieldJS').value!=lable_foure)
{
url+='&dateFilter='+document.getElementById('inputFieldJS').value;;
goToPage=false;
}
if(document.getElementById('fromTimeJs').value!='' && document.getElementById('fromTimeJs').value!=lable_five)
{
url+='&fromTime='+document.getElementById('fromTimeJs').value;;
goToPage=false;
}
if(document.getElementById('toTimeJs').value!='' && document.getElementById('toTimeJs').value!=lable_six)
{
url+='&toTime='+document.getElementById('toTimeJs').value;;
goToPage=false;
}
url+='&secureCat='+secureCat;;
if(goToPage==true)///if the user click serach with no any filter
window.location='index.php?CategoryType=Search&catId='+nextCat+'&secureCat='+secureCat;
else
window.location=url;
}
//-----------
var currentLable='';
function emptyFiledKeepValue(lable,id)
{
currentLable=lable;
document.getElementById(id).value='';
}
function checkFiledReturnValue(id)
{
if(document.getElementById(id).value=='')
document.getElementById(id).value=currentLable;
}
function hideSearchBox()
{
if(document.getElementById('searchBox').innerHTML!=' ')
{
$( "#searchBox" ).slideUp();
document.getElementById('searchBox').innerHTML=' ';
}
}
function hideElement(id)
{
setTimeout(hideNow(id),2000);
}
function hideNow(id)
{
document.getElementById(id).style.display='none';
}
/* search homepage fields*/
function filterSuggestedEvents()
{
getWhereFilterEvents=true;
lastScroll=0;
$(this).scrollTop(0);
document.getElementById('indexPage').value=1;
var dateValue=$( "#inputField" ).val();
var fromTime=$( "#fromTime" ).val();
var toTime=$( "#toTime" ).val();
var currentCat=parseInt($('#currentCat').val());
$.ajax({
type: "POST",
url: "searchAjax.php",
data: "action=filterSuggestedEvents&dateValue="+dateValue+"&fromTime="+fromTime+"&toTime="+toTime+"¤tCat="+currentCat,
cache: false,
success: function(html){
document.getElementById('SuggestedEvent').innerHTML=html;
}
});
}