Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Complex JS Assigment

    Hi there everyone!

    I have a couple things I need help with and I'm very new to javascript as I'm taking a class on this right now. We have an extra credit assignment that I'd really like to have. It's meant to be fairly vague and open for interpretation. Here's what it says:

    == Write a jQuery plugin that serves as a DOMElement factory with supporting HTML/CSS
    You have a web application that adds orders to carts. Items in the cart can be displayed on a dedicated cart page, in a modal/dialog with cart contents, and in an expandable menu from a fixed footer (open to interpretation). These item lists should be detailed, somewhat informative, and summarized (respectively and based on context, so the 'expandable menu' should be minimal while the dedicated 'cart page' should have the most detail). The jQuery plugin should use the same method(s) to add items to each instance of the cart contents without the use of parameters that identify the context of the list that the item is being added to. HTML/CSS can be minimal and only needs to support displaying the items in a rudimentary (but functional) way.

    == Write a small Javascript application that does not expose any logic to the end user
    While there is no such thing as "secure Javascript", adding objects to the global namespace is typically a Bad Idea. However, sometimes scope presents problems interfacing with objects outside of that scope. Create a Javascript object/context that does not expose itself globally but is still able to be interacted with by other objects out of scope (open to interpretation) while maintaining application integrity.

    == Create a simple HTML page that saves state
    Sometimes a page requires a lot of application logic that changes the contents or functionality of the page drastically from its initial state. In this instance, instead of needing to reproduce steps to achieve the same results on subsequent pageloads, the page should effectively save its state so that reloading the page will not have an adverse effect on its contents or functionality. Page contents are arbitrary and left up to you.

    We only have to do 2 out of the three options. Ideally I'd like to combine at least 2 of them into one document and make it an awesome assignment. If there's a way to combine all 3 that'd be even more awesome. Can you guys point to resources that ideally already have most of this created so I just have to merge it together and maybe make some of my own little markup? Or would it take very long for someone here to do 2 of these for me really quick? If the latter is an option, I'm willing to pay a little bit of money for your time.

    Thanks!

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,883
    Thanks
    56
    Thanked 539 Times in 536 Posts
    so, can we help you cheat and if that requires some effort you'll throw some change at us?

    love the optimism...

  • #3
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Honestly yes, but I do actually learn faster and more efficiently if I look at other people's code. So it does actually help me out in the long run as far as actually learning it goes.

  • #4
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,883
    Thanks
    56
    Thanked 539 Times in 536 Posts
    Quote Originally Posted by cmulletman View Post
    I do actually learn faster and more efficiently if I look at other people's code.
    Believe me, you don't. The way you learn to write code is by writing code.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,028
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    The second and third ones there aren't really all that complex or hard.

    For the second one, you just use the standard self-invoking anonymous function and you allow HTML elements to interact with it by specifying (for example) dummy class names, where the class name(s) tell your JS code what to do.

    The third one is truly simple: cookies. And you could implement it with the same self-invoking anonymous function used in the second answer, so it's easy to combine those two.

    In fact, you can easily fulfill both those by, for example. using a class name on various form fields or other user choices to indicate a value that needs to be stored in the cookie and then restored on page load.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    The second and third ones there aren't really all that complex or hard.

    For the second one, you just use the standard self-invoking anonymous function and you allow HTML elements to interact with it by specifying (for example) dummy class names, where the class name(s) tell your JS code what to do.

    The third one is truly simple: cookies. And you could implement it with the same self-invoking anonymous function used in the second answer, so it's easy to combine those two.

    In fact, you can easily fulfill both those by, for example. using a class name on various form fields or other user choices to indicate a value that needs to be stored in the cookie and then restored on page load.
    Thank you for this help and not berating me over asking for help. Do you have any specific resources that you think might be helpful for me to do this?

  • #7
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,898
    Thanks
    203
    Thanked 2,530 Times in 2,508 Posts
    Quote Originally Posted by cmulletman View Post
    Thank you for this help and not berating me over asking for help. Do you have any specific resources that you think might be helpful for me to do this?
    I have that idea that people here were offended by your offer of money to do your homework for you. That is, cheat. You should know that it is not really in your best interests that others do your all or most homework for you.

    The assignment you post seems to me too advanced and inappropriate for someone who claims to be "very new to Javascript".

    Resources - what is wrong with your course tutorial meterials?

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #8
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    I have that idea that people here were offended by your offer of money to do your homework for you. That is, cheat. You should know that it is not really in your best interests that others do your all or most homework for you.

    The assignment you post seems to me too advanced and inappropriate for someone who claims to be "very new to Javascript".

    Resources - what is wrong with your course tutorial meterials?
    I understand that, but I also asked for resources first and foremost. I was only offering money if someone wanted to do it for me. Yes, I'd love to have resources and do it all myself and actually learn it, but I'm don't always put off the opportunity to see someone else's code and learn from how they do something. Like I said before, this is an extra credit assignment so it's meant to be harder to achieve. We also have people in the class that are a bit more advanced in Javascript than I am so it'll be easier for them to do it. This is a general web development class that hasn't yet provided specific resources for something like this so my class resources aren't much help in this sense.

  • #9
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,028
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    Here is a VERY stripped down version of some code you could use. You can find setCookie and getCookie scripts all over the web, for example, so I leave them to you.

    Code:
    <html>
    <body>
    <form action="someOtherPage.php" method="POST">
       What is your name? <input class="SAVE" name="username" />
       <br/>
       What is your age? <input class="SAVE" name="age" />
       <br/>
       <input class="SAVETRIGGER" type="button" value="Save my entries" />
    </form>
    
    <script type="text/javascript">
    (
      function( )
      {
          var toSave = document.getElementsByClassName("SAVE");
          for ( var t = 0; t < toSave.length; ++t )
          {
              var field = toSave[t];
              field.value = getCookie(  field.name );
          }
    
          var triggers = document.getElementsByClassName("SAVETRIGGER");
          for ( var t = 0; t < triggers.length; ++t )
          {
              triggers[t].onclick = saveData;
          }
    
          function saveData( )
          {
              for ( var t = 0; t < toSave.length; ++t )
              {
                  var field = toSave[t];
                  setCookie( field.value, field.name );
              }
          
          }
    
          function setCookie( name, value ) { ...you write.. }
          function getCookie( name ) { ...you write... }
      }
    )( );
    </script>
    </body>
    </html>
    That is truly bare bones, but it does demonstrate the features requested in the second and third requirements. You need to flesh it out a *LOT* more. I would suggest, for example, that you provide at least two and better more HTML pages showing auto-remembering of values across pages, etc., etc. Or maybe auto-remembering that takes into account the URL of the pages, even better.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,028
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    p.s.: getElementsByClassName() is not available on older MSIE, but I can't see how that would matter for an assignment.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •