Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
var ids = (ids) ? ids : {}; /** * Contains methods for getting, setting, and detecting cookies. */ ids.cookie = { get: function(name) { var cookies = document.cookie.split(';'); for (var i = 0, c; c = cookies[i]; i++) { c = c.replace(/^\s+/, ""); //trim the front of the string if (c.indexOf(name) == 0) return c.substring(name.length + 1, c.length); } return null; }, set: function(name, value, options) { var options = options || {}, value = value || "", expires = options.expires || ''; if (options.expires) { date = new Date(); date.setTime(date.getTime() + (expires * 24 * 60 * 60 * 1000)); expires = '; expires=' + date.toGMTString(); // use expires attribute, max-age is not supported by IE } var path = options.path ? '; path=' + options.path : '; path=/', domain = options.domain ? '; domain=' + options.domain : ''; document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain].join(''); return decodeURIComponent(value); }, isSupported: function() { if ( (this.set('check', '1') != '') && (document.cookie != '') ) { this.set('check', '1', {expires: -1}); // delete cookie; return true; } return false; } } /** * Contains common functions we use for detecting flash, and replacing content */ ids.flash = { fo : [], pluginType : "", getVersion : function(){ // ie try { try { // avoid fp6 minor version lookup issues // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); try { axo.AllowScriptAccess = 'always'; } catch(e) { this.pluginType = "ax"; return '6,0,0'; } } catch(e) {} this.pluginType = "ax"; return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1].split(','); // other browsers } catch(e) { try { if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){ this.pluginType = "na"; return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1].split(','); } } catch(e) {} } this.pluginType = null; return null; }, replace : function (id, opts) { var elm = document.getElementById(id), html = elm.innerHTML, // store the html in a var. majorVersion = "", optional = ["play", "loop", "menu", "quality", "scale", "salign", "wmode", "bgcolor", "base", "flashvars"], object; elm.innerHTML = ""; if(ids.cookie.isSupported()) { if (ids.cookie.get("flashVersion") && ids.cookie.get("pluginType")) { majorVersion = parseInt(ids.cookie.get("flashVersion")); this.pluginType = ids.cookie.get("pluginType"); } else { majorVersion = parseInt(ids.cookie.set("flashVersion", this.getVersion()[0], {domain: window.location.hostname}) ); ids.cookie.set("pluginType", this.pluginType, {domain: window.location.hostname}); } } else { majorVersion = parseInt(this.getVersion()[0]); } if (majorVersion < opts.version) return elm.innerHTML = html; // put the html back. if (this.pluginType == "ax") { // var object = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + opts.width + '" height="' + opts.height + '" id="' + opts.id + '" name="' + opts.name + '">'; object = object + '\n\t <param name="movie" value="' + opts.movie + '" />'; for (var i=0, opt; opt = optional[i]; i++) { if(typeof opts[opt] != "undefined") { object = object + '\n\t <param name="' + opt + '" value="' + opts[opt] + '" />'; } } object = object + '\n<\/object>'; } else if (this.pluginType == "na"){ object = document.createElement("object"); // create object element. object.setAttribute("width", opts.width); object.setAttribute("height", opts.height); object.setAttribute("type", "application/x-shockwave-flash"); object.setAttribute("data", opts.movie); if (opts.id) object.setAttribute("id", opts.id); if (opts.name) object.setAttribute("name", opts.name); for (var i=0, opt; opt = optional[i]; i++) { if(typeof opts[opt] != "undefined") { var p = document.createElement("param"); p.setAttribute("name", opt); p.setAttribute("value", opts[opt]); object.appendChild(p); } } } if (opts.className) elm.className = opts.className; if (this.pluginType == "ax") { elm.innerHTML = object; } else { elm.appendChild(object); } return object; }, add : function (id, opts) { this.fo[this.fo.length] = [id, opts]; }, replaceAll : function () { for (var i=0; i < this.fo.length; i++){ this.replace(this.fo[i][0], this.fo[i][1]); } }, has : function () { return (this.getVersion()) ? true : false; } }
This paste will be private.
From the Design Piracy series on my blog: