WA = new function(){ this.init = function(){ if (WA.Voting.active) { WA.Voting.init(); WA.Voting.Facebook.init(); } // append non-voting text $j('.non-voting').parent().append('
[The voting period for this category has ended.]
'); } } WA.NomineeVoting = new function(){ this.more = function(){ window.open('/ontv/woodieawards/2009/nominee_voting/index.jhtml?categoryId=' + WA.Voting.categoryId, 'nominee_voting', 'height=532, width=749'); } } WA.Utils = new function(){ this.arrayContains = function(ar, val){ var contains = false; for(var i=0; i < ar.length; i++){ if(ar[i] == val) contains = true; } return contains; } } WA.Voting = new function(){ this.active = false; this.cogix = "polling-onair"; this.validator= "timestamp|votes"; this.authClass = "com.mtvnet.auth.dis.HashDigestInputStrategy1"; this.categoryId = ""; this.style = "list"; this.thanksWindowUrl = "/ontv/woodieawards/2009/scripts/ajax/thanks.jhtml"; this.loginWindowUrl = "/ontv/woodieawards/2009/scripts/ajax/not_logged_in.jhtml"; this.categoriesMap = { 'woty' : 'Woodie of the Year', 'video' : 'Best Video Woodie', 'breaking' : 'Breaking Woodie', 'left' : 'Left Field Woodie', 'performing' : 'Performing Woodie', 'good' : 'Good Woodie', 'radio' : 'College Radio Woodie', 'bmoc' : 'BMOC Woodie' }; this.init = function(){ $j(".vote-btn").each(function() { var targetId = this.id; var vars = targetId.split(":"); //get pollId and value var pollId = vars[0]; var value = vars[1]; var embedId = "voteButton" + value; var flashVars = ""; flashVars += "cogix=" + WA.Voting.cogix + "&"; flashVars += "validator=" + WA.Voting.validator + "&"; flashVars += "authClass=" + WA.Voting.authClass + "&"; flashVars += "pollid=" + pollId + "&"; flashVars += "answer=" + value + "&"; flashVars += "category=" + WA.Voting.categoryId; var src = "/ontv/woodieawards/2009/components/voteButton.swf"; var width = "140"; var height = "27"; if(WA.Voting.style=="grid"){ src = "/ontv/woodieawards/2009/components/voteButtonGrid.swf"; height = "130"; } var so = new SWFObject(src, embedId, width, height, "9", "#000000"); so.addParam("flashVars", flashVars); so.addParam("AllowScriptAccess", "sameDomain"); so.addParam("wmode", "transparent"); so.useExpressInstall('/sitewide/components/expressInstall/adobeExpressInstall.swf'); so.write(targetId); }); } this.preSubmit = function(){ return true; } this.postSubmit = function(){ var categories = [ 'woty','video','breaking','left','performing','good','radio','bmoc' ]; var category = WA.Voting.categoryId; var vauth = MTV.Utils.Cookies.read("vauth"); if (vauth == null) vauth = ""; var alreadyVoted = WA.Utils.arrayContains(vauth.split(","),WA.Voting.categoryId); if(!alreadyVoted) { vauth += category + ","; MTV.Utils.Cookies.create("vauth", vauth); } var index = $j.inArray(category, categories); if (index == categories.length-1) { index = 0; } else { index+=1; } var next_category = categories[index]; MTVN.UI.ModalWindow.open(WA.Voting.thanksWindowUrl + '?next=' + next_category + '&categoryId=' + category,null,"jquery"); } } WA.Voting.Facebook = new function(){ // if we're on live use MTV.com facebook app // otherwise use MTV Staging app this.api_key = window.location.host.match(/mtv\.com$/) ? 'c157800f4e792f57a516889f68306485' : '799d9bf64893d343a891f0b272870437'; this.template_bundle_id = window.location.host.match(/mtv\.com$/) ? '156219566493' : '139475496483'; this.channel_path = '/ontv/woodieawards/2009/scripts/xd_receiver.htm'; this.is_logged_in = false; this.debug = false; var self = this; this.init = function(){ FB.init(self.api_key, self.channel_path, {"ifUserConnected":self.onConnected, "ifUserNotConnected":self.onNotConnected}); } this.onConnected = function(user_id) { FB.FBDebug.isEnabled = true; FB.FBDebug.logLevel = 1; FB.FBDebug.dump('FB.FBDebug - init'); FB.Connect.get_status().waitUntilReady(function(status){ switch(status) { case FB.ConnectState.connected: self.is_logged_in = true; FB.FBDebug.dump("FB.FBDebug - connected"); break; case FB.ConnectState.appNotAuthorized: FB.Connect.requireSession(); FB.FBDebug.dump("FB.FBDebug - app not authorized"); break; case FB.ConnectState.userNotLoggedIn: self.is_logged_in = false; FB.FBDebug.dump("FB.FBDebug - user not logged in"); break; } }); $j('.fb-vote-dialog').live('click', function(){ var category = WA.Voting.categoriesMap[WA.Voting.categoryId]; // report click to CODA // http://confluence.mtvi.com/display/BUSTECH/CODA+Link+Events mtvn.btg.Controller.sendLinkEvent({ linkName : 'FB:WOODIES:SHAREVOTE:' + category, linkType : 'o' }); var template_data = { "category" : category, "images" : [{ "src" : "http://www.mtv.com/sitewide/css/charlie/themes/events/woodieawards/2009/woodies_logo_130x130.jpg", "href" : "http://woodies.mtv.com"}] }; FB.FBDebug.dump('FB.FBDebug - category: ' + category); FB.Connect.showFeedDialog( self.template_bundle_id, // template_bundle_id template_data, // template_data [], // target_id "", // body_general 2, // story_size FB.RequireConnect.doNotRequire, // require connect function(){ // callback *do nothing* } ); return false; }); } this.onNotConnected = function() { } } MTV.initArray.push(MTV.Player.init); MTV.initArray.push(WA.init); MTV.initArray.push(MTVN.UI.Overlay.init); var votingPreSubmit = WA.Voting.preSubmit; var revealThanks = WA.Voting.postSubmit;