// The next line adds a reference to an intellisense file for JQuery /// $(document).ready(function() { // Set search box change events $("select#searchRegion").change(ReloadSearchBoxes); $("select#searchFood").change(ReloadSearchBoxes); $("select#searchVenue").change(ReloadSearchBoxes); // Recent docs var recentUrl = GetWsUrl("/Documents/Recent/"); var listingsUrl = GetWsUrl("/Listings/GetAllRestaurants/"); $.get(recentUrl, { websiteId: $("#WebsiteId").val(), mode: "viewed" }, function(j) { try { $("div#recentlyViewed").html(j); $("div#recentlyViewed").show(); } catch (e) { }; // silence callback errors }); // Recently starred ShowRecentlyStarred(); // All Restaurants $.getJSON(listingsUrl, { websiteId: $("#WebsiteId").val(), ajax: 'true' }, function(j) { var options = ""; $.each(j, function() { options += ''; }); $("select#searchListing").html(options); }); }) // globals var timerHandle3 = 0; var currentMenu = ""; // methods function ShowRecentlyStarred() { var recentUrl = GetWsUrl("/Documents/Recent/"); // Recently Starred $.get(recentUrl, { websiteId: $("#WebsiteId").val(), mode: "starred" }, function(j) { try { $("div#recentlyStarred").html(j); $("div#recentlyStarred").show(); } catch (e) { }; // silence callback errors }); } function GetWsUrl(url) { // Preview systems don't use proxy and may have different method names switch (document.location.host) { case "localhost:4885": url = "http://localhost:4885" + url; break; case "www.eatoutadmin.com": url = "http://www.eatoutadmin.com" + url; break; case "test.eatoutadmin.com": url = "http://test.eatoutadmin.com" + url; break; default: // map url to proxy scripts switch (url) { case "/Documents/Recent/": url = "/_php/Recent.php"; break; case "/Documents/Star/": url = "/_php/Star.php"; break; case "/Documents/Starred/": url = "/_php/Starred.php"; break; case "/Listings/GetAllRestaurants/": url = "/_php/GetAllRestaurants.php"; break; case "/Listings/Comment/": url = "/_php/Comment.php"; break; case "/Listings/Comments/": url = "/_php/Comments.php"; break; case "/Listings/Enquiry/": url = "/_php/Enquiry.php"; break; case "/Listings/NeedCaptcha/": url = "/_php/NeedCaptcha.php"; break; default: return null; break; } break; } return url; } function UseProxy() { // Preview systems don't use proxy and may have different method names var useProxy; switch (document.location.host) { case "localhost:4885": useProxy = false; break; case "www.eatoutadmin.com": useProxy = false; break; default: useProxy = true; break; } return useProxy; } function StarListings() { // Ajaxes a list of listings that have been starred by this user and changes the saved buttons to "saved" var useProxy = false; var url = GetWsUrl("/Documents/Starred/"); $.getJSON(url, { "documentId": $("#DocumentId").val() }, function(j) { $.each(j, function() { $("#Star" + this)[0].src = "/_images/saved.gif"; }); }); } function StarListing(e, listingId) { var starUrl = GetWsUrl("/Documents/Star/"); $.get(starUrl, { websiteId: $("#WebsiteId").val(), listingId: listingId }, function() { ShowRecentlyStarred(); }); if ($(e).children()[0].src.search("/_images/save.gif") >= 0) $(e).children()[0].src = "/_images/saved.gif"; else $(e).children()[0].src = "/_images/save.gif"; } function ReloadSearchBoxes() { var regionId = jQuery("select#searchRegion").val(); var foodTypeId = jQuery("select#searchFood").val(); var venueTypeId = jQuery("select#searchVenue").val(); var url = "/Xml/ListingsMatrix/?"; foodTypeId = parseInt(foodTypeId); venueTypeId = parseInt(venueTypeId); regionId = parseInt(regionId); if (!isNaN(regionId)) url += "RegionId=" + regionId + "&"; if (!isNaN(foodTypeId)) url += "FoodTypeId=" + foodTypeId + "&"; if (!isNaN(venueTypeId)) url += "VenueTypeId=" + venueTypeId + "&"; // if this is not the dropdown that was changed, disable the onchange event, reload, and re-enable onchange once finished loading if (this.id != "searchRegion") { $("select#searchRegion")[0].onchange = null; $("select#searchRegion")[0].disabled = true; jQuery("select#searchRegion").load(url + "type=Region", null, function() { $("select#searchRegion")[0].disabled = false; $("select#searchRegion").change(ReloadSearchBoxes); }); } if (this.id != "searchFood") { $("select#searchFood")[0].onchange = null; $("select#searchFood")[0].disabled = true; jQuery("select#searchFood").load(url + "type=FoodType", null, function() { $("select#searchFood")[0].disabled = false; $("select#searchFood").change(ReloadSearchBoxes); }); } if (this.id != "searchVenue") { $("select#searchVenue")[0].onchange = null; $("select#searchVenue")[0].disabled = true; jQuery("select#searchVenue").load(url + "type=VenueType", null, function() { $("select#searchVenue")[0].disabled = false; $("select#searchVenue").change(ReloadSearchBoxes); }); } } // event handlers function ShowMore() { jQuery("#more").slideDown("slow"); jQuery("body").click(function() { jQuery("#more").hide(); this.onclick = null; }); } function ShowMoreCloud() { jQuery("#morecloud").slideDown("slow"); jQuery("body").click(function() { jQuery("#morecloud").hide(); this.onclick = null; }); }