View RSS Feed

keyboard

  1. Messing with Javascript

    Hey all,
    I've been fiddling with JavaScript and decided to share a neat little thing (its completely useless).

    Finished Code
    Code:
    console.log(+[[-~[]<<~[]][+[]]+[]][+[]][++[[]][+[]]+[+[]]]); //Prints 8
    Now for the break down -

    Pre-note - I use this function while playing with variables. It outputs the value and type of a variable. (The counter is to force the developer console to display each seperately)
    Code:
    var counter = 0;
    ...
    Categories
    JavaScript & Ajax
  2. Scroll to Top Script

    Here's my alternative to the ddscript Jquery Scroll to Top Control V1.1

    scroll_to_top.js

    Code:
    $.fn.scroll_to_top = function(userOptions) {
    	var check_scroll = 0;
        var defaultOptions = {
    		image : 'jump_to_top.png',
    		image_height : '6%',
    		image_width : '3%',
    		scroll_distance : 200,
    		scroll_location : 0,
    		scroll_speed : 600,
    		button_animate_speed : 200,
    		button_animate_type : 'fade',
    ...
  3. Show plain text in a password field

    I was browsing the internet and came across this tecnique and thought it was rather cool.

    To make plain text show in a password field, you need the following form -

    HTML Code:
     <form>
     <input type="text" name="passwordPlain" id="passwordPlain" value="Password" onfocus="swapPasswordBoxes('click')" style="display:none;"/>
     <input type="password" name="password" id="password"
    ...

    Updated 06-08-2012 at 10:23 PM by keyboard (swapped onclick for onfocus)

    Categories
    Post a JavaScript
  4. document.getElementById shortcut

    I'm amazed at how many people don't use a very simple shortcut for document.getElementById. This is for all the people who don't use a javascript library like jQuery.

    All you have to do is include this code somewhere on your page

    Code:
    function $(element) {
    return document.getElementById(element);
    }
    Then when you want to use document.getElementById('id'); just type $('id'); instead.

    Example

    Code:
    <html>
    ...
    Categories
    JavaScript & Ajax