Ooo err... :-\
A Pen by Keili Olsen on CodePen.
/** | |
* This doesn't pretend to be a proper, or fully-featured templating library | |
* it's merely a light-weight one used for rapid prototyping. | |
* Anti-Features: | |
* - no precompilation | |
* - no fancy iteration or repeats | |
* - pretty much nothing except string replacement | |
* - basic filters | |
* | |
* https://gist.github.com/pentaphobe/7955994 |
/** | |
* This seems like a problem which can be solved more elegantly, but I needed this code today | |
* so despite a strong urge to sit down with pen and paper and relive my Godel, Escher, Bach days | |
* I must instead move along for now. | |
* | |
* | |
*/ | |
!function() { | |
Ooo err... :-\
A Pen by Keili Olsen on CodePen.
/** | |
* Handy for checking for event spamming | |
* @returns {Object} A map of event name to number of occurances. | |
*/ | |
function getEventCounts() { | |
var eventCounts = {}; | |
function incrementEventCounter( eventName ) { | |
eventCounts[eventName] || ( eventCounts[eventName] = 0 ); |
callLog = []; | |
/* set up an override for the Function call prototype | |
* @param func the new function wrapper | |
*/ | |
function registerOverride(func) { | |
oldCall = Function.prototype.call; | |
Function.prototype.call = func; | |
} |
var f=function () { var photoUrl = document.getElementById("photo_src"); photoUrl.name="external_urls[]"; photoNode = photoUrl.cloneNode(false); photoNode.id = "photo_extra"; photoNode.removeAttribute("onkeydown"); var counter = 1; var linker = document.createElement("a");linker.setAttribute("onclick", "javascript:addUrl()"); linker.innerHTML = '+'; console.log(linker); photoUrl.parentNode.insertBefore(linker, photoUrl); addUrl = function() { var newEntry = photoNode.cloneNode(false); newEntry.id += counter; counter += 1; photoUrl.parentNode.insertBefore(newEntry, photoUrl); }; console.log(photoUrl); console.log(photoNode); console.log(linker); };f() |