/g, ">"); s = s.replace(/\"/g, '"'); s = s.replace(/\'/g, '''); return s; } return s; }; if (isOninputSupported($('#place-input').get(0))) { $('#place-input').get(0).oninput = function () { suggest(); }; } else { $('#place-input').keyup(function () { suggest(); }); } var suggest = function () { $('#place-list').empty(); var oriQ = $('#place-input').val(); var q = oriQ.replace(/(^\s+)|(\s+$)/g, ''); if (q === '') { return; } var key = encodeURIComponent(q); if (placeCache[key]) { renderPlaceSuggestion(placeCache[key]); return; } var params = { 'q': q, 'limit': 20, 'lang': "en_US" }; var jqxhr = $.get( 'https://macauapi.com/v0/places/suggest', params, function (res) { if (res.ok === true && res.data) { var data = res.data; } else { return; } placeCache[key] = data; if (oriQ === $('#place-input').val()) { renderPlaceSuggestion(placeCache[key]); } }, 'jsonp' ); }; var renderPlaceSuggestion = function (data) { $('#place-list').empty(); var typeMap = { 'building': "Building", 'stop': "Bus Stop", 'street': "Street", 'other': "Other" }; for (var i = 0, l = data.length; i < l; i++) { var d = data[i]; var name = escapeHTML(d.name); var lat = escapeHTML(d.lat); var lng = escapeHTML(d.lng); var type = escapeHTML(d.type) || 'other'; var locality = escapeHTML(d.locality); var description = typeMap[type]; if (type === 'business' && d.cat && d.cat.length > 0) { description = d.cat.join(', '); } if (locality !== '') { if (description.length > 0) { description += ' @ ' + locality; } else { description += locality; } } var link = $('' + '' + name + '
' + '' + description + '
' + ''); link.click(function (e) { e.preventDefault(); var attr = $(this).attr('data-attr'); var name = attr.split('|')[0]; var geo = attr.split('|')[1]; $('#place-name').html(name); $('#search-pn').val(name); $('#search-pg').val(geo); setCookie('pn', name, 7); setCookie('pg', geo, 7); if ($('#search-input').val()) { $('#search-form').submit(); } else { $('#place-clear-link').css('display', 'inline-block'); $('body').removeClass('no-scroll'); $('#place-overlay').hide(); $('.search-link').each(function () { var href = $(this).attr('href'); href = href.replace(/&pn(.*)$/, ''); href += '&pn=' + encodeURIComponent(name); href += '&pg=' + encodeURIComponent(geo); $(this).attr('href', href); }); } }); $('
').append(link) .addClass('place-item') .appendTo($('#place-list')); } }; $('#feedback').submit(function () { var txt = $('#feedback-body').val(); txt = txt.replace(/(^\s+)|(\s+$)/g, ''); if (txt) { $('#feedback-message').html(''); $.post( 'https://www.mlocal.biz/contact/send', {'body': txt}, function (data) { $('#feedback-body').val(''); $('#feedback-message').html("Thanks for your message!"); } ); } return false; }); if ($('#map-container').length > 0) { var mapContainer = $('#map-container'); var mapOverview = $('#map-overview'); var map = $('#map'); if (window.devicePixelRatio && window.devicePixelRatio > 1 ) { var da = mapOverview.attr('data-attr'); da = da.replace('scale=1', 'scale=2'); mapOverview.attr('data-attr', da); var da = map.attr('data-attr'); da = da.replace('scale=1', 'scale=2'); map.attr('data-attr', da); $('.zl').each(function () { var self = $(this); var da = self.attr('data-attr'); da = da.replace('scale=1', 'scale=2'); self.attr('data-attr', da); }); } mapOverview.attr('src', mapOverview.attr('data-attr')); map.attr('src', map.attr('data-attr')); map.load(function () { mapContainer.css('display', 'block'); }); $('.zl').click(function (e) { e.preventDefault(); var self = $(this); var da = self.attr('data-attr'); map.attr('src', da); map.load(function () { $('.zl').removeClass('zl-selected'); self.addClass('zl-selected'); }); map.error(function () { console.log('error'); mapContainer.css('display', 'none'); }); }); } $('.related-biz-toggle-link').click(function () { if ($(this).attr('data-attr') === 'hidden') { $(this).html("−Less"); $(this).attr('data-attr', 'shown'); $('li.more-biz').css('display', 'list-item'); } else { $(this).html("+More"); $(this).attr('data-attr', 'hidden'); $('li.more-biz').css('display', 'none'); } });});