Skip to content

Instantly share code, notes, and snippets.

@imbcmdth
Created June 20, 2012 08:18

Revisions

  1. imbcmdth revised this gist Jun 20, 2012. 1 changed file with 11 additions and 11 deletions.
    22 changes: 11 additions & 11 deletions LoadIIFE.js
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,22 @@
    var appSpace = (function (global) {
    (function (global) {

    'use strict';

    var x = 10,
    button = document.getElementById('idButton'),
    output = document.getElementById('idOutput');

    global.appSum = function (y) {
    return x + y;
    };


    button.addEventListener("click", function () {
    output.innerHTML = x++;
    });

    return {
    global.appSpace = {
    z : 0,


    appSum: function (y) {
    return x + y;
    },

    appMult: function (y) {
    return x * y;
    },
    @@ -30,7 +30,7 @@ var appSpace = (function (global) {
    }
    };

    }(window));
    })(window);

    appSpace.getOutput().innerHTML = appSpace.appMult(5) + '<br />';
    appSpace.getOutput().innerHTML += appSum(5);
    appSpace.getOutput().innerHTML += appSpace.appSum(5);
  2. Scott Sanbar created this gist Jun 20, 2012.
    11 changes: 11 additions & 0 deletions LoadIIFE.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    <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>
    36 changes: 36 additions & 0 deletions LoadIIFE.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    var appSpace = (function (global) {

    'use strict';

    var x = 10,
    button = document.getElementById('idButton'),
    output = document.getElementById('idOutput');

    global.appSum = function (y) {
    return x + y;
    };

    button.addEventListener("click", function () {
    output.innerHTML = x++;
    });

    return {
    z : 0,

    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 += appSum(5);