Created
June 20, 2012 08:16
-
-
Save imbcmdth/2958767 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
var appSpace = (function () { | |
'use strict'; | |
var x = 10, | |
button = document.getElementById('idButton'), | |
output = document.getElementById('idOutput'); | |
button.addEventListener("click", function () { | |
output.innerHTML = x++; | |
}); | |
return { | |
z : 0, | |
appSum: function (y) { | |
return x + y; | |
}, | |
appMult: function (y) { | |
return x * y; | |
}, | |
setX: function (y) { | |
x = y; | |
}, | |
getOutput: function () { | |
return output; | |
} | |
}; | |
})(); | |
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