// ======= BEGIN WIDGET API ======================================================================= // displays the widget and handles page parameters widgetShow = function() {widgetClearspringEmbed();} //adds a recipe to the widget user's recipe box widget_addToRecipeBox = function(id) {if(id) direct_widget('addRecipeBox=' + id);} //begins the process of adding a recipe to the widget user's planner widget_addToMealPlan = function(id) {if(id) direct_widget('addMealPlan=' + id);} // adds a recipe to the user's shopping list widget_addRecipeToShopList = function(id) {if(id) direct_widget('addRecShopList=' + id);} // adds an ingredient to the user's shopping list widget_addIngredientToShopList = function(id) {if(id) direct_widget('addIngredShopList=' + id);} //shows a recipe detail page in the widget widget_recipeDetail = function(id) {if(id) direct_widget('recipe=' + id);} // shows a recipe search page in the widget widget_recipeSearch = function(str) {if(str && str.length > 0) direct_widget('search=' + escape(str));} // shows the promotions landing page in the widget widget_showCoupons = function() {direct_widget('show=coupons');} // shows a promotion detail page in the widget widget_couponDetail = function(id) {if(id) direct_widget('coupon=' + id);} // shows the results from recipe landing search in the widget widget_recipeLanding = function(name) {if(name) direct_widget('recipeGroup=' + name);} // shows results of recipes for a promotion in the widget widget_recipesForPromotion = function(id) {if(id) direct_widget('recipePromotion=' + id);} // adds a planner group to the widget widget_addPlannerGroup = function(id) {if(id) direct_widget('planner=' + id);} // ======= END WIDGET API ======================================================================= var _sessionId = '21DB5387C4DFE17696CEE86C0B594DC1.tomcat1'; //this function will create an iframe with the widget using any "deep link" params on the current url. function widgetIFrames() { var url = ""; var urlPg = '' + document.location; var endFile = urlPg.indexOf("?"); var prms = 'widget.jsp;jsessionid=' + _sessionId + (endFile > 0? urlPg.substr(endFile) : ''); try {url = widget_url + '/' + prms;} catch(x) {} if(url) { var s = '
' + '' + widgetDirectorFrame() + '
'; document.write(s); } } //this function will embed the widget from clearspring using any "deep link" params on the current url. //allows the loading of deep links into the context page with clearspring widget. function widgetClearspringEmbed() { var urlPg = '' + document.location; var endFile = urlPg.indexOf("?"); var params = endFile > 0? urlPg.substr(endFile+1) : ""; var csStr = "jsessionid/" + _sessionId + "/"; var nvPairs = params.split("&"); for(i=0; i < nvPairs.length; i++) { var nvPair = nvPairs[i]? nvPairs[i].split("=") : null; if(nvPair != null && nvPair[0].length > 0) csStr += nvPair[0] + "/" + nvPair[1] + "/"; } var url = null; try {url = ''+clearspring_url;} catch(x) {}; if(url != null && url.length > 0) { url = url.replace("widget.js", csStr+"widget.js"); var s = "
" + widgetDirectorFrame(); document.write(s); } } // helper function - do not edit function widgetDirectorFrame() { return ''; } // helper function to manipulate the widget - do not edit function direct_widget(url) { var dir_frame = document.getElementById('fl-director'); if(dir_frame) dir_frame.src = widget_url + '/' + 'widgetDirector.jsp?' + url; } function getWidgetFrame() { var widget_frame = document.getElementById('widget_iframe'); if(!widget_frame) widget_frame = document.getElementById(clearspring_iframe); }