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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Dec 2002
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb Code Challenge! v2.0

    Welcome to version 2.0 of beetle's Code Challenge!

    Hang onto your keyboards, this'll be a wild one...

    The Challenge --------------
    Create a function that rewrites HTML code as a JavaScript "clientlet" (I coined this term to emulate the concept of how Java servlets produce HTML). My HTML() bookmarklet library allows a clientlet to produce HTML. Your function will take HTML and produce a clientlet.

    Code:
    function html2js(html){
    	/*your code here*/
    	return clientlet
    }
    Three types of clientlet functions must be returned by your function:
    1. Attributes
    Code:
    TYPE('submit')
    produces
    Code:
     type="submit"
    there's a very important leading space before the word "type".
    2. Tags
    Code:
    INPUT(TYPE('submit')+VALUE('ok'))
    (TYPE+VALUE is INPUT pararm)
    produces
    Code:
    <input type="submit" value="ok">
    3. Containers
    Code:
    INPUT(TYPE('submit')).FORM(ACTION('mailto:'))
    produces
    Code:
    <form action="mailto:"><input type="submit"></form>
    Keep this in mind...

    The HTML input can contain:
    1. embedded JavaScripts,
    2. containers (like A B I U),
    3. tags (like IMG or INPUT), and
    4. text (including new lines and HTML entities).

    Hints/suggestions: Code the content of embedded JavaScripts as literal text. Code container contents recursively. Try regular expressions.

    You may assume that the HTML input is valid: Containers will be nested properly, and tag attributes will be quoted...
    But not necessarily standardized: Tag/attribute names can be upper/lower/mixed case. Whitespace may include new lines (even inside tags!).

    Bonus points if you allow for escaped quote characters inside of string literals! Extra credit if your code is bookmarklet-ready (no quotes)!

    The Rules --------------
    Violation of these rules will result in disqualification.

    Submissions must be 100% ECMAscript compliant. Code must be self-contained and run error-free on IE5, NS6 (or NS7), and MZ1.

    Once you've submitted your code, you're done. Your submitted post cannot be edited, and any resubmissions will be ignored (well, unless it involves one character or less!).

    Grading
    Submitted code will be graded on a scale from 1 to 10. Attention will be paid to the functionality, efficiency, simplicity, and brevity of your approach. Although shorthand is allowed, multiple assignments are discouraged. The winner of this contest will receive the dubious honor of presenting the next one! Also, I'd like to include the winner's function (citing your authorship!) in an upcoming suite of HTML() bookmarklet library utilities.

    The deadline for this challenge is extended to Sunday, January 26, at 9pm Pacific time.

    Good luck!
    Last edited by ca_redwards; 01-14-2003 at 06:26 PM.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do not think there will be any submissions to this one...
    The challenge should be such that it would not require more than 10-20 lines of code, and there is no obvious approach to the problem. Asking people to re-write a library that you already have is too much IMHO...
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #3
    Regular Coder
    Join Date
    Dec 2002
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy You were right. How about something simpler...

    Care to write a little utility to return the Pig Latin version of a string? I suppose that it might seem like a "trivial exercise" in writing regular expressions, I guess that short scripts might turn out to be little else.

    I don't know if it would be too long a script, but how about creating a bookmarklet that displays (in separate window) a nicely formatted inventory of the current window's form elements?

    Most browsers can work with bookmarklets of nearly 2K in size, however, IE6 users have found that they are limited to just 508 bytes!

    Originally posted by Vladdy
    I do not think there will be any submissions to this one...
    The challenge should be such that it would not require more than 10-20 lines of code, and there is no obvious approach to the problem. Asking people to re-write a library that you already have is too much IMHO...
    I was actually looking to un-write its results back into what could be its original JavaScript code. And while I do not profit by it monitarily, I suppose that it does boost my future developments (as well as all the others who use it too).

    But your point is well taken. (nor were you alone in your opinion!)


  •  

    Posting Permissions

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