Created
June 10, 2013 19:40
-
-
Save will-in-wi/5751599 to your computer and use it in GitHub Desktop.
An attempt to create a jquery plugin for async OAS usage. Unused.
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
(function($){ | |
// Properties is an object with the following keys: | |
// listpos (required) A comma delimited list (no spaces) of the used positions on this page. | |
// sitepage (optional) The page to be sent for the ad server. Defaults to the current page. | |
// | |
// Position is defined by the data-oas-pos attribute. The ad will be inserted inside. | |
$.fn.oas = function(properties) { | |
// Set default properties and fail on required properties. | |
if (typeof(properties.sitepage) === 'undefined') { | |
properties.sitepage = window.location.hostname + window.location.pathname; | |
} | |
if (typeof(properties.listpos) === 'undefined') { | |
throw "jQuery.oas: You need to pass a listpos property."; | |
} | |
return this.each(function(){ | |
var pos = $(this).attr('data-oas-pos'); | |
if (pos) { | |
$(this).load('http://youroasdomain/RealMedia/ads/adstream_sx.ads/' + properties.sitepage + '/1' + String(Math.random()).substring (2, 11) + '@' + properties.listpos + '!' + pos); | |
} | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment