CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript programming (http://www.codingforums.com/forumdisplay.php?f=2)
-   -   Complex JS Assigment (http://www.codingforums.com/showthread.php?t=276093)

cmulletman 10-11-2012 04:41 AM

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:

Quote:

== 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!

xelawho 10-11-2012 04:54 AM

so, can we help you cheat and if that requires some effort you'll throw some change at us?

love the optimism...

cmulletman 10-11-2012 04:55 AM

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.

xelawho 10-11-2012 05:54 AM

Quote:

Originally Posted by cmulletman (Post 1278657)
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.

Old Pedant 10-11-2012 08:57 PM

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.

cmulletman 10-12-2012 01:52 AM

Quote:

Originally Posted by Old Pedant (Post 1278892)
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?

Philip M 10-12-2012 08:15 AM

Quote:

Originally Posted by cmulletman (Post 1278973)
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?

cmulletman 10-12-2012 05:33 PM

Quote:

Originally Posted by Philip M (Post 1279040)
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.

Old Pedant 10-12-2012 08:54 PM

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.

Old Pedant 10-12-2012 08:55 PM

p.s.: getElementsByClassName() is not available on older MSIE, but I can't see how that would matter for an assignment.


All times are GMT +1. The time now is 05:03 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.