Created
June 20, 2012 08:18
-
-
Save imbcmdth/2958774 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
<html> | |
<head> | |
<title>IIFE App</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
</head> | |
<body> | |
<input type="button" id="idButton" value="Click Me!"> | |
<div id="idOutput"></div> | |
<script type="text/javascript" src="LoadIIFE.js"></script> | |
</body> | |
</html> |
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 (global) { | |
'use strict'; | |
var x = 10, | |
button = document.getElementById('idButton'), | |
output = document.getElementById('idOutput'); | |
button.addEventListener("click", function () { | |
output.innerHTML = x++; | |
}); | |
global.appSpace = { | |
z : 0, | |
appSum: function (y) { | |
return x + y; | |
}, | |
appMult: function (y) { | |
return x * y; | |
}, | |
setX: function (y) { | |
x = y; | |
}, | |
getOutput: function () { | |
return output; | |
} | |
}; | |
})(window); | |
appSpace.getOutput().innerHTML = appSpace.appMult(5) + '<br />'; | |
appSpace.getOutput().innerHTML += appSpace.appSum(5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment