Skip to content

Instantly share code, notes, and snippets.

@will-in-wi
Created June 10, 2013 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save will-in-wi/5751599 to your computer and use it in GitHub Desktop.
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.
(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