“;
$(“.ui-autocomplete”).append(“
“);
}
else {
var no_result_found = “
CLICK HERE FOR MORE RESULTS
“;
response([{ label: no_result_found, val: -1}]);
}
}
});
},
search: function(){
$(this).addClass(“header-search-autocomplete-loading”);
$(“.ui-autocomplete”).remove(“li.autocomplete-response-text”);
},
minLength: 1,
select: function( event, ui ) {
self.location = ui.item.link
},
open: function(event, ui){
$(‘.ui-autocomplete’).css(‘width’, “310px”);
$(‘.ui-autocomplete’).css(‘height’, ‘300px’);
$(‘.ui-autocomplete’).css(‘overflow-y’, ‘scroll’);
$(‘.ui-autocomplete’).css(‘z-index’, ‘10000’);
$(this).removeClass(“header-search-autocomplete-loading”);
}
})
.data(“ui-autocomplete”)._renderItem = function (ul, item) {
var sub = “http://e27.co/”;
var html = “http://e27.co/”;
if (item.category) {
var li;
if ( item.category != currentCategory ) {
ul.append( “
” + item.category + “
” );
currentCategory = item.category;
}
}
if(item.icon) {
var html = ‘‘;
html += ‘‘;
html += ‘‘;
}
html += ‘
html += ‘
‘+item.label+’
‘;
if(item.location){
html += ‘
‘+item.location+’
‘;
}
html += ‘
‘;
return $(“
.data(“ui-autocomplete-item”, item)
.append(html)
.appendTo($(ul).addClass(“navbar-search-list”));
};
$(“.new-mobile-header-search”).autocomplete({
source: function(request, response) {
$.ajax({
url: “https://e27.co/index/main_search_new”,
//url: “http://e27beta.co/index/main_search_new”,
//url: “http://e27beta.co/_html/header_search.json”,
dataType: “json”,
data: {
q : request.term
},
success: function(data) {
//console.log(“search”);
$(“#statssaver”).attr(“src”, “https://e27.co/stats/log”);
try{
ga(‘send’, ‘pageview’, “/index/main_search_new?q=”+searchq);
}
catch(e){
}
if(data.length > 0){
response(data);
var footer = “
CLICK HERE FOR MORE RESULTS
“;
$(“.ui-autocomplete”).append(“
“);
}
else {
var no_result_found = “
CLICK HERE FOR MORE RESULTS
“;
response([{ label: no_result_found, val: -1}]);
}
}
});
},
search: function(){
$(this).addClass(“header-search-autocomplete-loading”);
$(“.ui-autocomplete”).remove(“li.autocomplete-response-text”);
},
minLength: 1,
select: function( event, ui ) {
self.location = ui.item.link
},
open: function(event, ui){
$(‘.ui-autocomplete’).css(‘width’, “100%”);
$(‘.ui-autocomplete’).css(‘height’, ‘300px’);
$(‘.ui-autocomplete’).css(‘overflow-y’, ‘scroll’);
$(‘.ui-autocomplete’).css(‘z-index’, ‘10000’);
$(this).removeClass(“header-search-autocomplete-loading”);
}
})
.data(“ui-autocomplete”)._renderItem = function (ul, item) {
var sub = “http://e27.co/”;
var html = “http://e27.co/”;
if (item.category) {
var li;
if ( item.category != currentCategory ) {
ul.append( “
” + item.category + “
” );
currentCategory = item.category;
}
}
if(item.icon) {
var html = ‘‘;
html += ‘‘;
html += ‘‘;
}
html += ‘
html += ‘
‘+item.label+’
‘;
if(item.location){
html += ‘
‘+item.location+’
‘;
}
html += ‘
‘;
return $(“
.data(“ui-autocomplete-item”, item)
.append(html)
.appendTo($(ul).addClass(“navbar-search-list”));
};
});
GlobalJS.onLoad(function(){
$(‘.navbar-mobile > .dropdown > .dropdown-menu’).click(function(e){
e.stopPropagation();
});
$(‘.navbar-click a’).click(function(e){
var ulElem = $(this).parent().find(‘ul’);
if (ulElem.hasClass(‘navbar-open’)){
ulElem.removeClass(‘navbar-open’).addClass(‘navbar-close’);
}
else{
ulElem.removeClass(‘navbar-close’).addClass(‘navbar-open’);
}
});
});
function viewAnnoucement(){
jQuery.ajax({
url: “https://e27.co/api/announcement/viewed/37”,
type: “GET”,
contentType: false,
processData: false,
success: function (response) {
console.log(“viewed”);
},
error: function(jqXHR, textStatus, errorThrown) {
}
});
}