diff --git a/js/addnavbar.js b/js/addnavbar.js new file mode 100644 index 0000000..31c17b9 --- /dev/null +++ b/js/addnavbar.js @@ -0,0 +1,87 @@ +(function(funcName, baseObj) { + "use strict"; + // The public function name defaults to window.docReady + // but you can modify the last line of this function to pass in a different object or method name + // if you want to put them in a different namespace and those will be used instead of + // window.docReady(...) + funcName = funcName || "docReady"; + baseObj = baseObj || window; + var readyList = []; + var readyFired = false; + var readyEventHandlersInstalled = false; + + // call this when the document is ready + // this function protects itself against being called more than once + function ready() { + if (!readyFired) { + // this must be set to true before we start calling callbacks + readyFired = true; + for (var i = 0; i < readyList.length; i++) { + // if a callback here happens to add new ready handlers, + // the docReady() function will see that it already fired + // and will schedule the callback to run right after + // this event loop finishes so all handlers will still execute + // in order and no new ones will be added to the readyList + // while we are processing the list + readyList[i].fn.call(window, readyList[i].ctx); + } + // allow any closures held by these functions to free + readyList = []; + } + } + + function readyStateChange() { + if ( document.readyState === "complete" ) { + ready(); + } + } + + // This is the one public interface + // docReady(fn, context); + // the context argument is optional - if present, it will be passed + // as an argument to the callback + baseObj[funcName] = function(callback, context) { + if (typeof callback !== "function") { + throw new TypeError("callback for docReady(fn) must be a function"); + } + // if ready has already fired, then just schedule the callback + // to fire asynchronously, but right away + if (readyFired) { + setTimeout(function() {callback(context);}, 1); + return; + } else { + // add the function and context to the list + readyList.push({fn: callback, ctx: context}); + } + // if document already ready to go, schedule the ready function to run + // IE only safe when readyState is "complete", others safe when readyState is "interactive" + if (document.readyState === "complete" || (!document.attachEvent && document.readyState === "interactive")) { + setTimeout(ready, 1); + } else if (!readyEventHandlersInstalled) { + // otherwise if we don't have event handlers installed, install them + if (document.addEventListener) { + // first choice is DOMContentLoaded event + document.addEventListener("DOMContentLoaded", ready, false); + // backup is window load event + window.addEventListener("load", ready, false); + } else { + // must be IE + document.attachEvent("onreadystatechange", readyStateChange); + window.attachEvent("onload", ready); + } + readyEventHandlersInstalled = true; + } + } +})("docReady", window); + +const navbar = `` + +function addnavbar() { + document.body.innerHTML = navbar + document.body.innerHTML +} + +window.docReady(addnavbar) diff --git a/views/changePW.html b/views/changePW.html index 4aa3858..43afabf 100644 --- a/views/changePW.html +++ b/views/changePW.html @@ -7,14 +7,10 @@ Change Password + -

Current User: USER

diff --git a/views/index.html b/views/index.html index d05367d..7a66cbb 100644 --- a/views/index.html +++ b/views/index.html @@ -4,14 +4,10 @@ + -

IPost

diff --git a/views/login.html b/views/login.html index c14c133..df92b35 100644 --- a/views/login.html +++ b/views/login.html @@ -1,13 +1,14 @@ - + + diff --git a/views/otheruser.html b/views/otheruser.html index 2deb937..a10b84d 100644 --- a/views/otheruser.html +++ b/views/otheruser.html @@ -7,14 +7,9 @@ USERS Page + - -

USER

diff --git a/views/posts.html b/views/posts.html index 865b7df..05251e6 100644 --- a/views/posts.html +++ b/views/posts.html @@ -7,14 +7,9 @@ - + -
Username:
diff --git a/views/register.html b/views/register.html index 68094a6..dc07ef2 100644 --- a/views/register.html +++ b/views/register.html @@ -8,6 +8,7 @@ const pw = document.getElementById("pass").value } + diff --git a/views/user.html b/views/user.html index 6250e55..5748a02 100644 --- a/views/user.html +++ b/views/user.html @@ -7,15 +7,11 @@ Logged In + -

Welcome Back!