/* WAFF - Redesign 2015 - custom.js */ // story feed backup image var stationBackupImage = 'http://raycom.images.worldnow.com/images/6128805_G.jpg'; // Page Variables var pageVar = { clienttype: /[\?|&]clienttype=/i.test(document.location.search), frametop: /[\?|&]config=frametop/i.test(document.location.search) }; var MostPopularStoriesCategoryNumber = "188031"; var MostPopularVideosCategoryNumber = "188032"; var MostPopularNumberOfItems = "15"; var VideoLandingPage = "/video?autoStart=true&clipId="; var FeaturedVideoFormat = false; var MPslideshowURL = "/category/212742/more-slideshows"; // member center links var memberLink = [ ["/link/725722/registration?function=manageprofile&mode=login&referrer=http%3A//www.kltv.com/link/725722/registration%3Ffunction%3Dmanageprofile%26mode%3Dcreate%26referrer%3Dhttp%253A//www.kltv.com", "Log In"], ["/link/725722/registration?function=manageprofile&mode=create&referrer=http%3A//www.kltv.com", "Sign Up"] ]; // subscribe links var textHTML = '
'; var fb = ''; var twit = ''; var rss = ''; /** * MEGA DROPDOWN *---------------------------------------*/ function csDropdownAds() { var linksPlusItems = []; linksPlusItems[0] = ''; // Home linksPlusItems[1] = ''; // News linksPlusItems[2] = ''; // Video linksPlusItems[3] = ''; // Weather linksPlusItems[4] = ''; // Sports linksPlusItems[5] = ''; // Community var overlay = $wn('.csMenuOverlay'); $wn.each(overlay, function (i) { $wn(overlay[i]).append(linksPlusItems[i]); }); } function csSetupNav() { // menu (li's) ID and feed URL's // if menu changes/doesn't work check ID #'s csBindCustomMenu('62_1-C4210', 'http://www.waff.com/global/interface/customxml/category_279894_stories.xml'); // Home csBindCustomMenu('62_2-C14421', 'http://www.waff.com/global/interface/customxml/category_279895_stories.xml'); // News csBindCustomMenu('62_3-C308445', 'http://www.waff.com/global/interface/customxml/category_279900_stories.xml'); // Community csBindCustomMenu('62_4-C4211', 'http://www.waff.com/global/interface/customxml/category_279897_stories.xml'); // Weather csBindCustomMenu('62_5-C4213', 'http://www.waff.com/global/interface/customxml/category_279898_stories.xml'); // Sports csBindCustomMenu('62_6-C240201', 'http://www.waff.com/global/interface/customxml/category_279896_clips.xml'); // Video csBindCustomMenu('62_7-C7010', 'http://www.waff.com/global/interface/customxml/category_279899_stories.xml'); // TV csBindCustomMenu('62_8-C310939', 'http://www.waff.com/global/interface/customxml/category_310911_stories.xml'); // Events csBindCustomMenu('62_9-L688873', 'http://www.waff.com/global/interface/customxml/category_279904_stories.xml'); // Deals csBindCustomMenu('62_10-C5261', 'http://www.waff.com/global/interface/customxml/category_279902_stories.xml'); // About Us // csBindCustomMenu('62_10-C242037', 'http://www.waff.com/global/interface/customxml/category_279904_stories.xml'); // Connections } function csBindCustomMenu(menuId, feedUrl) { // Change to edit behavior of Dropdown var maxStories = 2; var linksPerColumn = 5; if (menuId === '62_6-C240201') { maxStories = 4; } if (menuId === '62_3-C308445') { maxStories = 3; } if (menuId === '62_8-C310939') { maxStories = 3; } // Magic stories var magicStories = { '24907708': { headlineHref: '/category/5265/live-stormtracker-doppler', headlineText: 'StormTracker Doppler', graphicSrc: 'http://files.waff.com/doppler.jpg' }, '24907720': { headlineHref: '/link/401277/you-track-storms', headlineText: 'Interactive Radar', graphicSrc: 'http://weather.wdtinc.com/clients/waff/staticMaps/12168.gif' }, '24907729': { headlineHref: '/global/weatheralerts.asp', headlineText: 'Watches and Warnings', graphicSrc: 'http://weather.wdtinc.com/clients/waff/staticMaps/13496.png ' }, '24907766': { headlineHref: '/category/279763/waff-48-news-mobile-app', headlineText: 'StormTeam Weather App', graphicSrc: 'http://waff.images.worldnow.com/images/2050091_G.png' }, '24907770': { headlineHref: '/category/118144/huntsville-camera', headlineText: 'Alfa Cams', graphicSrc: 'http://ftpcontent4.worldnow.com/raycom/alphacam/waff/huntsville.jpg' }, '4254761': { headlineHref: '/story/4254761/your-forecast', headlineText: 'Your Forecast', graphicSrc: 'http://ftpcontent4.worldnow.com/waff/weather/7day.jpg' }, '24907555': { headlineHref: '/category/20228/you-saw-it-on-waff', headlineText: 'You Saw It', graphicSrc: 'http://waff.images.worldnow.com/images/3360428_G.jpg' }, '24907607': { headlineHref: '/category/279763/waff-48-news-mobile-apps', headlineText: 'Download our apps', graphicSrc: 'http://waff.images.worldnow.com/images/3355142_G.jpg' }, '24907618': { headlineHref: '/category/266993/waff-investigates', headlineText: 'WAFF Investigates', graphicSrc: 'http://waff.images.worldnow.com/images/3360427_G.JPG' } } if ($wn('li#menu' + menuId).length < 1) { return; } WNHttpRequestManager.makeRequest(feedUrl, { onSuccess: function () { var storyTemplate = '' + ''; // Load API stories var $data = $wn(this.response.responseXML); var storyData = $data.find('story, clip').wnAPIStoryExtract(); storyData = storyData['-7'] || []; //use Full Horizontal - Col 2 if (storyData.length < 1) { // Checking for submenu items if story data not present if ($wn('ul#submenu' + menuId + ' li a').length < 1) { return; } } // Build a new overlay DIV var $overlay = $wn(''); $wn('li#menu' + menuId).append($overlay); if (storyData.length > 0) { // Split feed into two arrays var csFeatureData = storyData.slice(0, maxStories); // Add stories to the menu $wn.each(csFeatureData, function (i) { if (i >= maxStories) { return false; } if (this.isClip) { // regex for extracting clipId from stories var clipId = this.clipId; this.headlineHref = '/clip/' + clipId + '/' + this.pageURL; //this.headlineHref = '/category/151816/video-central?clipId=' + clipId + '&autostart=true'; } // Find the ID# of this story, for "magic story" support var storyId = (function (href) { var matches = href.match(/^.*\/story\/(\d+)\/.*$/i) || []; return matches[1] || ''; })(this.headlineHref); // If 'magicStories' has an entry for this story's ID, replace properties on // 'this' with whatever is defined in 'magicStories' if (magicStories[storyId]) { $wn.extend(this, magicStories[storyId]); } if (!this.graphicSrc) { this.graphicSrc = 'http://placehold.it/324x189'; } $overlay.csFormatterAppend(storyTemplate, this); }); } // Move menu links into the menu var $menuWrapper = ''; $wn('ul#submenu' + menuId + ' li a').each(function (i) { if (i >= 15) { return false; } if (i % linksPerColumn === 0) { $overlay.append($menuWrapper); $menuWrapper = $wn(''); } $menuWrapper.append(this); }); $overlay.append($menuWrapper); $wn('ul#submenu' + menuId).empty(); csDropdownAds(menuId); // Hide first and last borders var menus = $wn('.csMenuOverlay'), tempTop = $wn('ul.wnLevel1 li:first').outerHeight() + $wn('ul.wnLevel1:first li:first').offset().top; if ($wn('#WNAd41').length > 0 || $wn('#WNAd46').length > 0) { tempTop = tempTop + 100; } $wn.each(menus, function (i) { $(this).find('.csMenuCell').first().addClass('first'); $(this).find('.csMenuCell').last().addClass('last'); // Only allow 3 headlines in the last column $(this).find('.csNavCell').eq(2).addClass('adColumn'); $(this).find('.adColumn a:gt(2)').hide(); }); // Position this menu overlay where it needs to be during each hover $wn('li#menu' + menuId).bind('mouseenter', function () { var cssPos = $wn('ul.wnLevel1 li:first').offset(); if ($wn('#WNMenuCol1').hasClass('sticky')) { cssPos.top = $wn('.wnMainMenu').height(); } else { cssPos.top = parseInt($wn(this).find('.wnLevel2').css('top'), 10) || tempTop; } $overlay.css(cssPos); $overlay.find('.csMenuCell.csStoryBox span, .csMenuCell.csStoryBox a.csHeadline').dotdotdot(); }); } }); } var CDEVWAFF = { options: { }, loadHelper: function () { document.write(''); }, brandingWeather: function () { var $container, radarURL = '/category/5265/live-stormtracker-doppler', radarPath = 'http://ftpcontent4.worldnow.com/waff/weather/radar/doppler.jpg', wxHTML = '', cityNames = [ 'Huntsville', 'Cullman', 'Decatur', 'Florence', 'Fort Payne', 'Fayetteville', 'Guntersville', 'Moulton', 'Russellville', 'Scottsboro', 'Albertville', 'Athens' ]; $wn('#WNBranding').addClass('cdev-branding-weather'); $container = $wn('.cdev-branding-weather'); wxHTML += ''; wxHTML += ''; wxHTML += ''; wxHTML += ''; wxHTML += ''; wxHTML += ''; wxHTML += 'FULL FORECAST'; $container.append('