Created
May 10, 2016 18:18
-
-
Save AramZS/076318a12c617be3db1406affc3fe455 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ******************************************************************** | |
// This class is part of the Sizmek DCO HTML5 TEMPLATE (AUTO_300X250) | |
// ALL RIGHTS RESERVED TO � 2014 Sizmek, Inc. | |
// ********************************************************************* | |
// ********************************************************************* | |
sizmek_Html5Template_728x90 = function() { | |
// Establish Method Name | |
this.name = 'DCO Html5 Template'; | |
// Establish Script Details | |
this.script = { name: 'dco_advanced_block.js', version: '1.0.0' }; | |
// Track and Check Block Version - Version, Id, Title | |
this.blocks_init(1, '6175', 'HTML5 DCO Template Block'); | |
//Initializing button text variable | |
var buttonText = ''; | |
// Call Init Method | |
adkit.onReady(this.init.bind(this)); | |
}; | |
sizmek_Html5Template_728x90.prototype = { | |
// Function That Creates Element Var | |
d: function(id) { return document.getElementById(id); }, | |
// Handle Blocks Version Check and Tracking | |
blocks_init: function (ver, id, title) { | |
// Define Blocks API link and Block id | |
var url = 'https://platform.mediamind.com/Eyeblaster.ACM.Web/Creative/Workshop/Blocks/VersionCheck.aspx?ID=' + id; | |
// Create img tag | |
var img = document.createElement('img'); | |
// Set img src to Block API link | |
//img.src = url; | |
}, | |
// Initialize DCO HTML5 template | |
init: function() { | |
// initializing all variables | |
// First check the values from the config.js file and then check the default values | |
//Initializing Heading Style Css | |
//Initializing all config value | |
//VARIABLES NEEDED FOR JSON TO EQUATE | |
this.Region = adkit.getSVData("Region"); | |
this.Region_Name = adkit.getSVData("Region_Name"); | |
this.Model = adkit.getSVData("Model"); | |
this.CPO = adkit.getSVData("CPO"); | |
//VARIABLES COMING FROM SV | |
this.Offer_Type = adkit.getSVData("Offer_Type"); | |
this.frame1_headline = adkit.getSVData("frame1_headline"); | |
this.frame1_image = adkit.getSVData("frame1_image"); | |
/*this.frame2_headline = adkit.getSVData("frame2_headline");*/ | |
this.frame2_messaging_text = adkit.getSVData("frame2_messaging_text"); | |
this.frame2_messaging_image = adkit.getSVData("frame2_messaging_image"); | |
this.frame3_headline = adkit.getSVData("frame3_headline"); | |
this.frame3_image = adkit.getSVData("frame3_image"); | |
this.frame4_messaging = adkit.getSVData("frame4_messaging"); | |
this.frame4_messaging_image = adkit.getSVData("frame4_messaging_image"); | |
this.frame5_headline = adkit.getSVData("frame5_headline"); | |
this.frame5_image = adkit.getSVData("frame5_image"); | |
this.apr_offer = adkit.getSVData("apr_offer"); | |
this.msrp_offer = adkit.getSVData("msrp_offer"); | |
this.lease_offer = adkit.getSVData("lease_offer"); | |
this.secondary_messaging_image = adkit.getSVData("secondary_messaging_image"); | |
this.t1_cta = adkit.getSVData("t1_cta"); | |
this.cta_placement = adkit.getSVData("cta_placement"); | |
this.cta_color = adkit.getSVData("cta_color"); | |
this.apr_legal = adkit.getSVData("apr_legal"); | |
this.lease_legal = adkit.getSVData("lease_legal"); | |
this.creative_legal_rollover = adkit.getSVData("creative_legal_rollover"); | |
this.offer_legal_rollover = adkit.getSVData("offer_legal_rollover"); | |
//GET THE IMG PATH | |
this.img1Path = EB.getAssetUrl('', this.frame1_image); | |
this.img2Path = EB.getAssetUrl('', this.frame2_messaging_image); | |
this.img3Path = EB.getAssetUrl('', this.frame3_image); | |
this.img4Path = EB.getAssetUrl('', this.frame4_messaging_image); | |
this.img5Path = EB.getAssetUrl('', this.frame5_image); | |
this.img6Path = EB.getAssetUrl('', this.secondary_messaging_image); | |
console.log(this.type); | |
//if false then set variables and start animation | |
this.SetVariables(); | |
// this.bannerAnimation(); | |
// Establish Reference to this | |
var me = this; | |
var JagPath; | |
// PULLING JSON VALUE and SERVING to the AD if values from SV Match | |
switch(me.Model) { | |
case "RRE": | |
JagPath = "https://stripe-s.pointroll.com/api/data/get/538?model=RRE"; | |
console.log(JagPath); | |
break; | |
case "RRS": | |
JagPath = "https://stripe-s.pointroll.com/api/data/get/538?model=RRS"; | |
console.log(JagPath); | |
break; | |
case "RR": | |
JagPath = "https://stripe-s.pointroll.com/api/data/get/538?model=RR"; | |
console.log(JagPath); | |
break; | |
case "DS": | |
JagPath = "https://stripe-s.pointroll.com/api/data/get/538?model=DS"; | |
console.log(JagPath); | |
break; | |
case "LR2": | |
JagPath = "https://stripe-s.pointroll.com/api/data/get/538?model=LR2"; | |
console.log(JagPath); | |
break; | |
case "LR4": | |
JagPath = "https://stripe-s.pointroll.com/api/data/get/538?model=LR4"; | |
console.log(JagPath); | |
break; | |
default: | |
JagPath = "https://stripe-s.pointroll.com/api/data/get/538"; | |
} | |
$.getJSON(JagPath, function (data) { | |
//console.log(data); | |
//console.log(data.Offers.length); | |
for(var i = 0;i<=data.Offers.length;i++){ | |
var jag = data.Offers[i]; | |
try{var jRegion = jag["Region"].toUpperCase() || "";} catch(e){} | |
try{var jModel = jag["MODEL"];} catch(e){} | |
try{var jOfferType = jag["Offer TYPE"].toUpperCase();} catch(e){} | |
try{var jOffer = jag["OFFER COPY"];} catch(e){} | |
try{var jEndLegal = jag["ENDFRAME LEGAL"];} catch(e){} | |
try{var jOfferLegal = jag["LEGAL OVERLAY OFFER DISCLAIMER COPY"];} catch(e){} | |
var tempModel = me.Model; | |
if(jModel == undefined || jModel == null || jModel == ""){ | |
}else{ | |
//if(jRegion == me.Region && jOfferType == me.Offer_Type && jModel == me.Model){ | |
if(jRegion == me.Region && jOfferType == me.Offer_Type && jModel == tempModel){ | |
$('#price div').html('<strong>' + jOffer + '</strong>' + jEndLegal).show(); | |
$('#legal #content #offer_legal #legal_copy').html(jOfferLegal).show(); | |
console.log("IM IM IM"); | |
} | |
} | |
} | |
}); | |
$("#mainClick").click(function() { | |
//me.setUpAd(); | |
clicktheHandler(); | |
}); | |
}, | |
SetVariables: function() { | |
/*Frame 1*/ | |
$('#model-frame1 div').html('<h2 class="DCO">' + this.frame1_headline + '</h2>').show(); | |
$('#frame1 #img').html('<img id="img1" src="' + this.img1Path + '" alt="img1" />').show(); | |
/*Frame 2*/ | |
$('#model-frame2 div').html('<h2>' + this.frame3_headline + '</h2>').show(); | |
if(this.img2Path == ""){ | |
$('#frame1 .headline div').html('<h2 class="DCO">' + this.frame2_messaging_text + '</h2>').show(); | |
}else{ | |
$('#frame1 .headline div').html('<h2 class="DCO">' + this.frame2_messaging_text + '</h2><img src="' + this.img2Path + '" />').show(); | |
} | |
/*Frame 3*/ | |
$('#model-frame3 div').html('<h2>' + this.frame3_headline + '</h2>').show(); | |
$('#frame2 #imgs').html('<img id="img2" src="' + this.img3Path + '" alt="img2" />').show(); | |
/*Frame 4*/ | |
if(this.img4Path == ""){ | |
$('#frame2 .headline div').html('<h2 class="DCO">' + this.frame4_messaging + '</h2>').show(); | |
}else{ | |
$('#frame2 .headline div').html('<h2 class="DCO">' + this.frame4_messaging + '</h2><img src="' + this.img4Path + '" />').show(); | |
} | |
/*Frame 5*/ | |
if(this.frame5_headline != ""){ | |
$('#model-frame3 div').html('<h2>' + this.frame5_headline + '</h2>').show(); | |
}else{ | |
$('#model-frame3 div').html('<h2>' + this.frame3_headline + '</h2>').show(); | |
} | |
$('#frame3 div').html('<img id="img3" src="' + this.img5Path + '" alt="img3" />').show(); | |
if(this.Offer_Type == "APR"){ | |
if(this.img6Path == ""){ | |
$('#price div').html(this.apr_offer+''+this.apr_legal).show(); | |
}else{ | |
$('#price div').html('<img src="' + this.img6Path + '" />').show(); | |
} | |
$('#btn_legal').show(); | |
$('#legal #content #creative_legal #legal_copy').html(this.creative_legal_rollover).show(); | |
$('#legal #content #offer_legal #legal_copy').html(this.offer_legal_rollover).show(); | |
} | |
if(this.Offer_Type == "MSRP"){ | |
if(this.img6Path == ""){ | |
$('#price div').html(this.msrp_offer).show(); | |
}else{ | |
$('#price div').html('<img src="' + this.img6Path + '" />').show(); | |
} | |
$('#btn_legal').show(); | |
$('#legal #content #creative_legal #legal_copy').html(this.creative_legal_rollover).show(); | |
$('#legal #content #offer_legal #legal_copy').html(this.offer_legal_rollover).show(); | |
} | |
if(this.Offer_Type == "LEASE"){ | |
if(this.img6Path == ""){ | |
$('#price div').html(this.lease_offer+''+this.lease_legal).show(); | |
}else{ | |
$('#price div').html('<img src="' + this.img6Path + '" />').show(); | |
} | |
$('#btn_legal').show(); | |
$('#legal #content #creative_legal #legal_copy').html(this.creative_legal_rollover).show(); | |
$('#legal #content #offer_legal #legal_copy').html(this.offer_legal_rollover).show(); | |
} | |
$('#cta #ctaTxt').html(this.t1_cta).show(); | |
/*CTA Placement*/ | |
if(this.cta_placement == "option2"){ | |
$('#ad #header #cta.top').css({'top':'65px', 'left':'-110px'}); | |
}else{ | |
$('#ad #header #cta.top').css({'top':'65px'}); | |
} | |
/*CTA Color*/ | |
if(this.cta_color == "dark"){ | |
$('#ad #header #cta').css({'color':'#0c121c'}); | |
}else if(this.cta_color == "light"){ | |
$('#ad #header #cta').css({'color':'#FFF'}); | |
}else{ | |
$('#ad #header #cta').css({'color':'#0c121c'}); | |
} | |
/*Hover Events*/ | |
$("#clickthrough-button").hover(function() { | |
$('#ad #header #cta').css({'color':'#0c121c'}); | |
}, function(){ | |
if(this.cta_color == "dark"){ | |
$('#ad #header #cta').css({'color':'#0c121c'}); | |
}else if(this.cta_color == "light"){ | |
$('#ad #header #cta').css({'color':'#FFF'}); | |
}else{ | |
$('#ad #header #cta').css({'color':'#0c121c'}); | |
} | |
}); | |
}, | |
} | |
function clicktheHandler() { | |
EB.clickthrough(); | |
console.log("clickthrough"); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment