Am i over using modular pattern here?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












I am trying to learn modular pattern in javascript right now i am refactoring my previous side project a tasks app from jquery to plain js. I wish to know if what i'm doing here is right because i feel like i am over using the pattern here



(function()
const nameSetBtn = document.querySelector('#name-setting-btn');
const nameSetModalParent = document.querySelector('.modal-parent');
const nameSetModalMain = document.querySelector('.modal');
const nameSetModalInput = document.querySelector('#name-setting-input');
const mainInterface = document.querySelector('.main-interface');
const createSetBtn = document.querySelector('#create-set-btn');

const NameSetting = (function()
function animateModal()
nameSetModalMain.style.width = '30%';
nameSetModalMain.style.opacity = '0';
nameSetModalParent.style.opacity = '0';
delayHide = setTimeout(function()
nameSetModalParent.style.display = 'none';
, 500)
MainUI.setUI();

return
validate : function() nameLength < 5)
alert("You're name should be at least 5 characters to 10 characters long");
else if(nameLength > 10)
alert("You're name must only be at least 10 characters long");
else
localStorage.setItem('username', nameValue);
console.log(this)
return animateModal();


;
)();

const MainUI = (function()
function show()
const greeting = document.querySelector('#greet');
greeting.innerText = 'Welcome!, ' + localStorage.getItem('username');
mainInterface.style.display = 'block';

return
checkUser : function()
if(localStorage.getItem('username'))
nameSetModalParent.style.display = 'none';
this.setUI();

,
setUI : function()
const currentDate = new Date();
const dateStringHolder = document.querySelector('#date-string');
dateStringHolder.innerText = currentDate.toDateString();
const dateTimeHolder = document.querySelector('#date-time');
const tickTime = setInterval(function ()
dateTimeHolder.innerText = new Date().toLocaleTimeString();
, 1000)

return show();


)();

// The tasks model not done yet
function SetModel(setName)
this.setName = setName;
this.tasks = ;



SetModel.prototype.nameOfSet = function()
console.log(this.setName);


createSetBtn.addEventListener('click', () =>
const newset = new SetModel('Name this set');

)



MainUI.checkUser();
nameSetBtn.addEventListener('click', () =>
NameSetting.validate();
)

)();






share|improve this question

























    up vote
    1
    down vote

    favorite












    I am trying to learn modular pattern in javascript right now i am refactoring my previous side project a tasks app from jquery to plain js. I wish to know if what i'm doing here is right because i feel like i am over using the pattern here



    (function()
    const nameSetBtn = document.querySelector('#name-setting-btn');
    const nameSetModalParent = document.querySelector('.modal-parent');
    const nameSetModalMain = document.querySelector('.modal');
    const nameSetModalInput = document.querySelector('#name-setting-input');
    const mainInterface = document.querySelector('.main-interface');
    const createSetBtn = document.querySelector('#create-set-btn');

    const NameSetting = (function()
    function animateModal()
    nameSetModalMain.style.width = '30%';
    nameSetModalMain.style.opacity = '0';
    nameSetModalParent.style.opacity = '0';
    delayHide = setTimeout(function()
    nameSetModalParent.style.display = 'none';
    , 500)
    MainUI.setUI();

    return
    validate : function() nameLength < 5)
    alert("You're name should be at least 5 characters to 10 characters long");
    else if(nameLength > 10)
    alert("You're name must only be at least 10 characters long");
    else
    localStorage.setItem('username', nameValue);
    console.log(this)
    return animateModal();


    ;
    )();

    const MainUI = (function()
    function show()
    const greeting = document.querySelector('#greet');
    greeting.innerText = 'Welcome!, ' + localStorage.getItem('username');
    mainInterface.style.display = 'block';

    return
    checkUser : function()
    if(localStorage.getItem('username'))
    nameSetModalParent.style.display = 'none';
    this.setUI();

    ,
    setUI : function()
    const currentDate = new Date();
    const dateStringHolder = document.querySelector('#date-string');
    dateStringHolder.innerText = currentDate.toDateString();
    const dateTimeHolder = document.querySelector('#date-time');
    const tickTime = setInterval(function ()
    dateTimeHolder.innerText = new Date().toLocaleTimeString();
    , 1000)

    return show();


    )();

    // The tasks model not done yet
    function SetModel(setName)
    this.setName = setName;
    this.tasks = ;



    SetModel.prototype.nameOfSet = function()
    console.log(this.setName);


    createSetBtn.addEventListener('click', () =>
    const newset = new SetModel('Name this set');

    )



    MainUI.checkUser();
    nameSetBtn.addEventListener('click', () =>
    NameSetting.validate();
    )

    )();






    share|improve this question





















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I am trying to learn modular pattern in javascript right now i am refactoring my previous side project a tasks app from jquery to plain js. I wish to know if what i'm doing here is right because i feel like i am over using the pattern here



      (function()
      const nameSetBtn = document.querySelector('#name-setting-btn');
      const nameSetModalParent = document.querySelector('.modal-parent');
      const nameSetModalMain = document.querySelector('.modal');
      const nameSetModalInput = document.querySelector('#name-setting-input');
      const mainInterface = document.querySelector('.main-interface');
      const createSetBtn = document.querySelector('#create-set-btn');

      const NameSetting = (function()
      function animateModal()
      nameSetModalMain.style.width = '30%';
      nameSetModalMain.style.opacity = '0';
      nameSetModalParent.style.opacity = '0';
      delayHide = setTimeout(function()
      nameSetModalParent.style.display = 'none';
      , 500)
      MainUI.setUI();

      return
      validate : function() nameLength < 5)
      alert("You're name should be at least 5 characters to 10 characters long");
      else if(nameLength > 10)
      alert("You're name must only be at least 10 characters long");
      else
      localStorage.setItem('username', nameValue);
      console.log(this)
      return animateModal();


      ;
      )();

      const MainUI = (function()
      function show()
      const greeting = document.querySelector('#greet');
      greeting.innerText = 'Welcome!, ' + localStorage.getItem('username');
      mainInterface.style.display = 'block';

      return
      checkUser : function()
      if(localStorage.getItem('username'))
      nameSetModalParent.style.display = 'none';
      this.setUI();

      ,
      setUI : function()
      const currentDate = new Date();
      const dateStringHolder = document.querySelector('#date-string');
      dateStringHolder.innerText = currentDate.toDateString();
      const dateTimeHolder = document.querySelector('#date-time');
      const tickTime = setInterval(function ()
      dateTimeHolder.innerText = new Date().toLocaleTimeString();
      , 1000)

      return show();


      )();

      // The tasks model not done yet
      function SetModel(setName)
      this.setName = setName;
      this.tasks = ;



      SetModel.prototype.nameOfSet = function()
      console.log(this.setName);


      createSetBtn.addEventListener('click', () =>
      const newset = new SetModel('Name this set');

      )



      MainUI.checkUser();
      nameSetBtn.addEventListener('click', () =>
      NameSetting.validate();
      )

      )();






      share|improve this question











      I am trying to learn modular pattern in javascript right now i am refactoring my previous side project a tasks app from jquery to plain js. I wish to know if what i'm doing here is right because i feel like i am over using the pattern here



      (function()
      const nameSetBtn = document.querySelector('#name-setting-btn');
      const nameSetModalParent = document.querySelector('.modal-parent');
      const nameSetModalMain = document.querySelector('.modal');
      const nameSetModalInput = document.querySelector('#name-setting-input');
      const mainInterface = document.querySelector('.main-interface');
      const createSetBtn = document.querySelector('#create-set-btn');

      const NameSetting = (function()
      function animateModal()
      nameSetModalMain.style.width = '30%';
      nameSetModalMain.style.opacity = '0';
      nameSetModalParent.style.opacity = '0';
      delayHide = setTimeout(function()
      nameSetModalParent.style.display = 'none';
      , 500)
      MainUI.setUI();

      return
      validate : function() nameLength < 5)
      alert("You're name should be at least 5 characters to 10 characters long");
      else if(nameLength > 10)
      alert("You're name must only be at least 10 characters long");
      else
      localStorage.setItem('username', nameValue);
      console.log(this)
      return animateModal();


      ;
      )();

      const MainUI = (function()
      function show()
      const greeting = document.querySelector('#greet');
      greeting.innerText = 'Welcome!, ' + localStorage.getItem('username');
      mainInterface.style.display = 'block';

      return
      checkUser : function()
      if(localStorage.getItem('username'))
      nameSetModalParent.style.display = 'none';
      this.setUI();

      ,
      setUI : function()
      const currentDate = new Date();
      const dateStringHolder = document.querySelector('#date-string');
      dateStringHolder.innerText = currentDate.toDateString();
      const dateTimeHolder = document.querySelector('#date-time');
      const tickTime = setInterval(function ()
      dateTimeHolder.innerText = new Date().toLocaleTimeString();
      , 1000)

      return show();


      )();

      // The tasks model not done yet
      function SetModel(setName)
      this.setName = setName;
      this.tasks = ;



      SetModel.prototype.nameOfSet = function()
      console.log(this.setName);


      createSetBtn.addEventListener('click', () =>
      const newset = new SetModel('Name this set');

      )



      MainUI.checkUser();
      nameSetBtn.addEventListener('click', () =>
      NameSetting.validate();
      )

      )();








      share|improve this question










      share|improve this question




      share|improve this question









      asked Feb 27 at 9:25









      Megs

      61




      61

























          active

          oldest

          votes











          Your Answer




          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "196"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f188430%2fam-i-over-using-modular-pattern-here%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes










           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f188430%2fam-i-over-using-modular-pattern-here%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Greedy Best First Search implementation in Rust

          Function to Return a JSON Like Objects Using VBA Collections and Arrays

          C++11 CLH Lock Implementation