Java Scripts

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by dumidu1424, May 31, 2011.

  1. dumidu1424

    dumidu1424 New Member

    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    Post java scripts here...

    ---------- Post added at 04:52 PM ---------- Previous post was at 04:45 PM ----------

    Div style for title..

    <div style="border:2px solid#001000"><div style="border:2px solid#002000"><div style="border:2px solid#003000"><div style="border:2px solid#004000"><div style="border:2px solid#005000"><div style="border:2px solid#006000"><div style="border:2px solid#007000"><div style="border:2px solid#008000"><div style="border:2px solid#009000"><center>Your text</center></div></div></div></div></div></div></div></div></div>

    ---------- Post added at 04:55 PM ---------- Previous post was at 04:52 PM ----------

    Div style for title..

    <div style="border:2px solid#002200"><div style="border:2px solid#003300"><div style="border:2px solid#004400"><div style="border:2px solid#005500"><div style="border:2px solid#002200"><div style="border:2px solid#003300"><div style="border:2px solid#004400"><div style="border:2px solid#005500"><center>Your text</center></div></div></div></div></div></div></div></div>

    ---------- Post added at 04:58 PM ---------- Previous post was at 04:55 PM ----------

    Div style for title..

    <div style="border:1px solid#ffffff;solid;margin=1px;padding:1px"><div style="border:1px solid#ffffff;solid;margin=1px;padding:1px"><div style="background-color:black;border-style:ridge;border-width:2px;border-color:red;margin:2px"><div style='background-color:black;border-style:ridge;border-width:2px;border-color:silver;margin:2px;padding:2px'><table align='center' width='100%' border='2px'><tr><td align='center' bgcolor='black' background="http://URL GAMBAR">Your text here</td></tr></table></div></div></div></div></div></div>

    ---------- Post added at 05:10 PM ---------- Previous post was at 04:58 PM ----------

    Text input code

    <input type="text" name="text1" size="25" maxlength="30" value="YourText">
     
    Last edited: Jun 1, 2011
  2. vv.bbcc19

    vv.bbcc19 Community Advocate Community Support

    Messages:
    1,524
    Likes Received:
    92
    Trophy Points:
    48
    Kindly put a description of what the code does too..this will help people comprehend the script easily.
    Nice thread with a good start.
     
  3. dumidu1424

    dumidu1424 New Member

    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    Date And Time

    <font color="blue"><b><small><script>document.write (Date()+ ".")</script></b></small></font></br>

    ---------- Post added at 10:28 AM ---------- Previous post was at 10:24 AM ----------

    Goole Serch

    <b><i><font color="blue">G</font><font color="red">o</font><font color="yellow">o</font><font color="blue">g</font><font color="green">l</font><font color="red">e</font></i></b></br><form method"get" action="http://www.google.co.id/xhtml"> <p> <input type="text" name="q" maxlength="2048" size="15" value=""/><input type="hidden" name="hl" value="id"/><input type="hidden" name="Ir" value="http://www.google.co.id/xhtml"/><input type="hidden" name="ie" value="Iso-8859-1"/><br/> <input type="submit" name="Submit" value="Search"/><br/> <input type="radio" name="site" value="search" checked="checked"/>Web<br/> <input type="radio" name="site" value="images"/>Image<br/> <input type="radio" name="site" value="mobile"/>Mobile<br/>

    ---------- Post added at 10:37 AM ---------- Previous post was at 10:28 AM ----------

    Online Calculator

    <form name="Calc">
    <input type="hidden" name="PHPSESSID" value="50806ec01522c5e900c9cf932340f1cc" />
    <center>
    <input disabled="disabled" type="text" style="font-weight: bolder; font-size: large;" name="Input"/>
    <input type="hidden" name="PHPSESSID" value="6be315796135a9d9627813b4af5fb2ad" />
    </center>
    <table>
    <tr>
    <th>
    <input type="button" name="one" value=" 1 " OnClick="Calc.Input.value += '1'"/>
    </th>
    <th>
    <input type="button" name="two" value=" 2 " OnCLick="Calc.Input.value += '2'"/>
    </th>
    <th>
    <input type="button" name="three" value=" 3 " OnClick="Calc.Input.value += '3'"/>
    </th>
    <th>
    <input type="button" name="plus" value=" + " OnClick="Calc.Input.value += ' + '"/>
    </th>
    </tr>
    <tr>
    <th>
    <input type="button" name="four" value=" 4 " OnClick="Calc.Input.value += '4'"/>
    </th>
    <th>
    <input type="button" name="five" value=" 5 " OnCLick="Calc.Input.value += '5'"/>
    </th>
    <th>
    <input type="button" name="six" value=" 6 " OnClick="Calc.Input.value += '6'"/>
    </th>
    <th>
    <input type="button" name="minus" value=" - " OnClick="Calc.Input.value += ' - '"/>
    </th>
    </tr>
    <tr>
    <th>
    <input type="button" name="seven" value=" 7 " OnClick="Calc.Input.value += '7'"/>
    </th>
    <th>
    <input type="button" name="eight" value=" 8 " OnCLick="Calc.Input.value += '8'"/>
    </th>
    <th>
    <input type="button" name="nine" value=" 9 " OnClick="Calc.Input.value += '9'"/>
    </th>
    <th>
    <input type="button" name="times" value=" * " OnClick="Calc.Input.value += ' * '"/>
    </th>
    </tr>
    <tr>
    <th>
    <input type="button" name="zerozero" value="00" OnClick="Calc.Input.value += '00'"/>
    </th>
    <th>
    <input type="button" name="zero" value=" 0 " OnClick="Calc.Input.value += '0'"/>
    </th>
    <th>
    <input type="button" name="point" value=" . " OnClick="Calc.Input.value += '.'"/>
    </th>
    <th>
    <input type="button" name="div" value=" / " OnClick="Calc.Input.value += ' / '"/>
    </th>
    </tr>
    </table>
    <table>
    <tr>
    <th>
    <input type="button" name="clear" value=" Clear " OnClick="Calc.Input.value = ''"/>
    </th>
    <th>
    <input type="button" name="DoIt" value=" Total " OnClick="Calc.Input.value = eval(Calc.Input.value)"/>
    </th>
    </tr>
    <tr>
    </tr>
    </table>
    </form>


    ---------- Post added at 10:42 AM ---------- Previous post was at 10:37 AM ----------

    Color background table

    <table width="100%" border="3">
    <tr>
    <td>MENU 1</td>
    <td>MENU 2</td>
    <td>MENU 3</td>
    <br />
    <tr>
    <td>MENU 4</td>
    <td>MENU 5</td>
    <td>MENU 6</td>
    </tr>
    <tr>
    <td>MENU 7</td>
    <td>MENU 8</td>
    <td>MENU 9</td>
    </tr>
    </table>


    ---------- Post added at 10:46 AM ---------- Previous post was at 10:42 AM ----------

    Rainbow Div

    <div align="center"><div style="border:1px solid #002222"><div style="border:1px solid #003333"><div style="border:1px solid #004444"><div style="border:1px solid #005555"><div style="border:1px solid #006666"><div style="border:1px solid #007777"><div style="border:2px dotted lime"><div style="border:1px dotted lime"><div style="border:1px solid #007777"><div style="border:1px solid #006666"><div style="border:1px solid #005555"><div style="border:1px solid #004444"><div style="border:1px solid #003333"><div style="border:1px solid #002222"><div style="border:1px solid #001111"><div style="border:1px solid #004444"><div style="border:1px solid #003333"><div style="border:1px solid #002222"><div style="border:1px solid #001111"><div style="background-image:url(http://clickmaster.xtgem.com/Background/1.gif)"><font color="lime"><b>SLCHAT.TK™</b></font></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
     
  4. misson

    misson Community Paragon Community Support

    Messages:
    2,572
    Likes Received:
    72
    Trophy Points:
    48
    I see only one Javascript script, and no Java at all.

    Tables used for layout, presentational HTML, inline CSS, massive numbers of elements used non-structurally. No thanks.
     
  5. dumidu1424

    dumidu1424 New Member

    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    Which java scripts you want?
     
  6. dumidu1424

    dumidu1424 New Member

    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    disco color change background

    <body onload="disco()"><script language="JavaScript">
    <!--
    //slchat
    r=255;
    g=255;
    b=255;
    flag=0;
    t=new Array;
    o=new Array;
    d=new Array;

    function hex(a,c)
    {
    t[a]=Math.floor(c/16)
    o[a]=c%16
    switch (t[a])
    {
    case 10:
    t[a]='A';
    break;
    case 11:
    t[a]='B';
    break;
    case 12:
    t[a]='C';
    break;
    case 13:
    t[a]='D';
    break;
    case 14:
    t[a]='E';
    break;
    case 15:
    t[a]='F';
    break;
    default:
    break;
    }
    switch (o[a])
    {
    case 10:
    o[a]='A';
    break;
    case 11:
    o[a]='B';
    break;
    case 12:
    o[a]='C';
    break;
    case 13:
    o[a]='D';
    break;
    case 14:
    o[a]='E';
    break;
    case 15:
    o[a]='F';
    break;
    default:
    break;
    }
    }

    function ran(a,c)
    {
    if ((Math.random()>2/3||c==0)&&c<255)
    {
    c++
    d[a]=2;
    }
    else
    {
    if ((Math.random()<=1/2||c==255)&&c>0)
    {
    c--
    d[a]=1;
    }
    else d[a]=0;
    }
    return c
    }
    function do_it(a,c)
    {
    if ((d[a]==2&&c<255)||c==0)
    {
    c++
    d[a]=2
    }
    else
    if ((d[a]==1&&c>0)||c==255)
    {
    c--;
    d[a]=1;
    }
    if (a==3)
    {
    if (d[1]==0&&d[2]==0&&d[3]==0)
    flag=1
    }
    return c
    }
    function disco()
    {
    if (flag==0)
    {
    r=ran(1, r);
    g=ran(2, g);
    b=ran(3, b);
    hex(1,r)
    hex(2,g)
    hex(3,b)
    document.body.style.background="#"+t[1]+o[1]+t[2]+o[2]+t[3]+o[3]
    flag=50
    }
    else
    {
    r=do_it(1, r)
    g=do_it(2,g)
    b=do_it(3,b)
    hex(1,r)
    hex(2,g)
    hex(3,b)
    document.body.style.background="#"+t[1]+o[1]+t[2]+o[2]+t[3]+o[3]
    flag--
    }

    setTimeout('disco()',50)
    }
    //-->
    </script>
     
  7. dumidu1424

    dumidu1424 New Member

    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    did you test this script

    ---------- Post added at 02:21 AM ---------- Previous post was at 02:10 AM ----------

    Forward Button

    <a href="javascript:history.forward(1)">FORWARD</a>

    ---------- Post added at 02:22 AM ---------- Previous post was at 02:21 AM ----------

    Refresh Button

    <form action="#"><div><input type="button" value="REFRESH" onClick="window.location.reload()"></input></div></form>

    ---------- Post added at 02:24 AM ---------- Previous post was at 02:22 AM ----------

    Page ending Lines

    <hrcolor="aqua"width="80%
    "size="2"><hr
    color="aqua"width="70%
    "size="2"><hr
    color="aqua"width="60%
    "size="2"><hr
    color="aqua"width="50%
    "size="2"><hr
    color="aqua"width="40%
    "size="2">
     
  8. maitreebhatt54

    maitreebhatt54 New Member

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
  9. misson

    misson Community Paragon Community Support

    Messages:
    2,572
    Likes Received:
    72
    Trophy Points:
    48
    You don't really need to write a function to convert a number to hexadecimal. Number.toString will do that for you.

    The disco script should be placed within an anonymous function so the global namespace isn't polluted.

    Functions are first class data. Rather than having two branches in disco that are almost exactly the same, assign a function to a variable and use it outside the branches.

    Variable names should be descriptive. If you want a minified script, pass it through a minifier when publishing, but not before. The original source should be unminified so it can be read, updated & debugged.

    Arrays are indexed starting with 0, not 1 in JS. It's time to start counting like a programmer. Better still, use object properties.

    Magic numbers should be replaced with symbolic "constants" (JS doesn't have constants, so a variable will have to do).

    Code:
    (function () {
        var state_incr=2, state_decr=1, state_nochange=0;
        var r=255,g=255,b=255,
            counter=0,state={}, /* 'state' replaces 'd' */
            defaultPeriod=50, discoInterval;
    
        function first_step(name, value) {
            ...
        }
        function step(name,value) {
            if ((state[name]==state_incr && value<255) || value==0) {
                ++value;
                state[name]=state_incr;
            } else if ((state[name]==state_decr && value>0) || value==255) {
                --value;
                state[name]=state_decr;
            }
            return value;
        }
        function unstick() {
            if (state.r + state.g + state.b == state_nochange) {
                counter=0;
            }
        }
        function disco() {
            var delta, done, color;
            if (counter==0) {
                delta=first_step;
                done=function() {}
                counter=50;
            } else {
                delta=step;
                done=unstick;
                counter--;
            }
            r=delta('r', r);
            g=delta('g', g);
            b=delta('b', b);
            done();
            color = (r << 16 | g << 8 | b).toString(16);
            document.body.style.background="#"+color;
        }
        window.startDisco = function(period) {
            if (!period) {
                period = defaultPeriod;
            }
            if (! discoInterval) {
                discoInterval = setInterval(disco, period);
            }
        };
        window.stopDisco = function() {
            clearInterval(discoInterval);
            discoInterval=0;
        }
        
        startDisco();
    })();
    
    Of coures, the best improvement is simply to discard the whole script. From a graphic design perspective, it's a terrible idea.

    Note
    Code:
     tags make code more readable. For PHP and HTML, there's [php] and [html] tags, respectively.
     
    Last edited: Jun 26, 2011
  10. vol7ron

    vol7ron New Member

    Messages:
    434
    Likes Received:
    0
    Trophy Points:
    0
    @mission: I don't think that works
     
  11. active.king.hacker47

    active.king.hacker47 New Member

    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    0
  12. essellar

    essellar Community Advocate Community Support

    Messages:
    3,295
    Likes Received:
    227
    Trophy Points:
    63
    No, they're not (although Misson's use of bitwise left shifts and bitwise OR to generate the colours in his rewrite of the original Disco abomination is cool and worth trying to understand, as is the function passing).
     
  13. vekou

    vekou Member

    Messages:
    197
    Likes Received:
    1
    Trophy Points:
    18
    the javascript functions here feels like functions from Javascript websites from a decade ago, where you browse the site searching for cool javascript effects then copy paste the code to your page with the instructions like "Copy this code to the <head> part of your html".
     
  14. misson

    misson Community Paragon Community Support

    Messages:
    2,572
    Likes Received:
    72
    Trophy Points:
    48
    When it comes to bit twiddling, Sean Eron Anderson's collection of bit twiddling hacks is more enlightening. There's the classics, such as swapping two bit fields without using a temporary, and the classics, such as bit counting.

    Here's one way of computing the floor of the base-2 logarithm of a number (i.e. the position of the MSB). Other implementations are faster in wall time but not the complexity (O(log(n)), and (more importantly) this illustrates a widely-applicable technique. If you see what it is, don't post it yet; give others the chance to figure it out.

    Code:
    function floorlg(n) {
      if (n <= 0) 
        return -1;
    
      var msb_left = 31, msb_right = 0;
      var msb = msb_left >>> 1;
      var i;
      
      while ((i = n >>> msb) != 1) {
        if (i) {
          msb_right = msb + 1;
        } else {
          msb_left = msb - 1;
        }
        msb = (msb_right + msb_left) >>> 1;
      }
      return msb;
    }
     
  15. dumidu1424

    dumidu1424 New Member

    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    Google Wap Serch

    <form action="http://google.com/m/search"><input type="text" name="q" size="30%" maxlength="2048" value="" /><input type="hidden" name="as_sitesearch" value="slchat.tk"/><input type="submit" value="Search" /></form>
     
  16. memory2007us48

    memory2007us48 New Member

    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
  17. dumidu1424

    dumidu1424 New Member

    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    Page Footer

    <hrcolor="aqua"width="80%
    "size="2"><hr
    color="aqua"width="70%
    "size="2"><hr
    color="aqua"width="60%
    "size="2"><hr
    color="aqua"width="50%
    "size="2"><hr
    color="aqua"width="40%
    "size="2">
     
  18. dumidu1424

    dumidu1424 New Member

    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    Div box for logo

    <table width="100%" border="4"><tr><td width="100%" bgcolor="cyan" align="">CeylonWap</td></tr></table></script></br></div>
     
  19. misson

    misson Community Paragon Community Support

    Messages:
    2,572
    Likes Received:
    72
    Trophy Points:
    48
    That's not what tables are for.

    And that's still not JavaScript. You'd better stay on topic.
     

Share This Page