diff --git a/Solutions/1. Tier 1 - Begineer Projects/1. Bin2Dec/Web/dom-is-ready.js b/Solutions/1. Tier 1 - Begineer Projects/1. Bin2Dec/Web/dom-is-ready.js new file mode 100644 index 00000000..5d59faa9 --- /dev/null +++ b/Solutions/1. Tier 1 - Begineer Projects/1. Bin2Dec/Web/dom-is-ready.js @@ -0,0 +1,25 @@ +var domIsReady = (function (domIsReady) { + var isBrowserIeOrNot = function () { + return (!document.attachEvent || typeof document.attachEvent === "undefined" ? 'not-ie' : 'ie'); + } + + domIsReady = function (callback) { + if (callback && typeof callback === 'function') { + if (isBrowserIeOrNot() !== 'ie') { + document.addEventListener("DOMContentLoaded", function () { + return callback(); + }); + } else { + document.attachEvent("onreadystatechange", function () { + if (document.readyState === "complete") { + return callback(); + } + }); + } + } else { + console.error('The callback is not a function!'); + } + } + + return domIsReady; +})(domIsReady || {}); \ No newline at end of file diff --git a/Solutions/1. Tier 1 - Begineer Projects/1. Bin2Dec/Web/index.html b/Solutions/1. Tier 1 - Begineer Projects/1. Bin2Dec/Web/index.html index ecc648f0..339603de 100644 --- a/Solutions/1. Tier 1 - Begineer Projects/1. Bin2Dec/Web/index.html +++ b/Solutions/1. Tier 1 - Begineer Projects/1. Bin2Dec/Web/index.html @@ -7,6 +7,13 @@ Bin2Dec Converter - +
+
+ +
+ +
+ + \ No newline at end of file diff --git a/Solutions/1. Tier 1 - Begineer Projects/1. Bin2Dec/Web/index.js b/Solutions/1. Tier 1 - Begineer Projects/1. Bin2Dec/Web/index.js index e69de29b..593df709 100644 --- a/Solutions/1. Tier 1 - Begineer Projects/1. Bin2Dec/Web/index.js +++ b/Solutions/1. Tier 1 - Begineer Projects/1. Bin2Dec/Web/index.js @@ -0,0 +1,6 @@ +(function (document, window, domIsReady, undefined) { + domIsReady(function () { + console.log('My DOM is ready peeps!'); + + }); +})(document, window, domIsReady); \ No newline at end of file