Results 1 to 17 of 17

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Banned stalin_sssr's Avatar
    Join Date: Jun:2005
    Location:
    Posts: 607

    Question javascript | ?

    ,

    javascript, , . , ..

    ( , )..

    Code:
    		
    function getvalue(a){
    	inputNumber = Number(a)
    	slideit()
    }
    var step=0;
    function slideit(){
    	if(!document.images){
    	return;
    }
    else{
    	if(step<10){
    	document.images.slide.src=imgArray[step].src
    	step++
    	setTimeout("slideit()", Number(inputNumber))
    }
    else{
    	step=0
    	slideit()
    }				
    }	
    }

    Code:
    				<input id="number" type="text" value="1000" name="textfield">
    				<input id="button" type="button" value="GO!" name="gobutton" onClick="getvalue(document.getElementById('number').value)">
    				<img src="img/my-wallpaper1.jpg" onClick="slideit()" name="slide">

  2. #2
    Registered User genn's Avatar
    Join Date: Feb:2003
    Location:
    Posts: 1,215
    ...

    Live:
    http://jsbin.com/uvewuq/6/

    Code:
    (function(){
    
      var step = 0;
      var maxSteps = 10;
      var delay = 1000;
      
      var isRunning = false;
      
      var domContainer = document.getElementById( 'container' );
      
      function SlideIt()
      {
        isRunning = true;
        domContainer.innerHTML = domContainer.innerHTML + 'Change pic '+ step + ' with delay '+ delay +'<br/>';
        
        if( step < maxSteps )
        {
          step++;
          setTimeout( SlideIt, delay );
        }
        else
        {
          step = 0;
          isRunning = false;
        }
      }
      
      document.getElementById( 'button' ).onclick = function(){
        delay = parseInt( document.getElementById( 'number' ).value );
        
        if( !isRunning )
        {
          SlideIt();
        }
        
      };
      
        
     SlideIt();
    })();
    , .
    Javascript, :
    1. , ... - Javascript. function scope, block scope, , (function(){...})() .
    2. Number() ... , parseInt().
    new String, new Number, new Array, new Object... etc... ...
    new javascript ....

  3. #3

    Join Date: Apr:2006
    Location:
    Posts: 8,666
    Quote Originally Posted by genn View Post
    new String, new Number, new Array, new Object... etc... ...
    new javascript ....
    ?

  4. #4
    Registered User genn's Avatar
    Join Date: Feb:2003
    Location:
    Posts: 1,215
    Douglas Crockford... JS, .
    new JS... . / / youtube, .
    - new "" , JS, ...

    @@ :

    function Person( name )
    {
    this.name = name;
    ....
    ....
    ...
    }

    var p = new Person( 'Johny' );

    .
    ... JS , Crockgford

    "JS - "

  5. #5
    Pesho's Avatar
    Join Date: Nov:2001
    Location: Sofia
    Posts: 5,169
    Quote Originally Posted by genn View Post
    Crockford
    Crockford . , . prototypal inheritance ( new). , - .
    , !

  6. #6
    Registered User genn's Avatar
    Join Date: Feb:2003
    Location:
    Posts: 1,215
    Quote Originally Posted by Pesho View Post
    Crockford . , .
    [OFF]
    - , .

  7. #7
    Registered User tedych's Avatar
    Join Date: Nov:2003
    Location:
    Posts: 17,654
    Quote Originally Posted by genn View Post
    @@ :

    function Person( name )
    {
    this.name = name;
    ....
    ....
    ...
    }

    var p = new Person( 'Johny' );

    .
    , , name , ?

    Quote Originally Posted by _ShadoW_ View Post
    , .
    , , , - , ..
    . .
    "" , , .
    - , ... ""..., , , , , , .

  8. #8
    Registered User genn's Avatar
    Join Date: Feb:2003
    Location:
    Posts: 1,215
    , .
    ?
    mixins, module pattern + abstract factory => JS.
    "" - . global space- , ...
    API- Yahoo .
    , API, , collisions . , , - .
    JS , -"native" .
    new JS , - , .

    @_Shadow_: - => window space-a , . ( ) , window space-a .

  9. #9
    Registered User
    Join Date: Jul:2005
    Location: Sofiq
    Posts: 2,798
    Quote Originally Posted by genn View Post
    new String, new Number, new Array, new Object... etc... ...
    new javascript ....
    - .

    Code:
    function TestClass() {
        if(arguments.length > 0) {
            this.prop1 = arguments[0];
        }
    
        this.method = function () {
            console.log(this.prop1);
        }
        
        return this;
    }
    
    var a = TestClass(1),
        b = new TestClass(2),
        c = TestClass(3),
        d = TestClass.apply(TestClass, [4]),
        e = TestClass.call(TestClass, 5);
    
    a.method();
    console.log(a);
    
    b.method();
    console.log(b);
    
    c.method();
    console.log(c);
    
    d.method();
    console.log(d);
    
    e.method();
    console.log(e);
    console.log(a); Window
    console.log(b); TestClass

    new Window . , .

    Edit: new.

    :
    Code:
    3
    Window 
    
    2
    TestClass { prop1= 2, method=function()}
    
    3
    Window 
    
    5
    TestClass()
    
    5
    TestClass()

    :

    slideit
    Code:
    function slideit(step){				
    	if(!document.images){
    		return;
    	}
    	else{
    		
    		if(step<10){
    			document.images.slide.src=imgArray[step].src;
    			step++;
    			setTimeout(function () { slideit(step)}, Number(inputNumber));
    		}
    		else{
    			slideit(0);
    		}				
    	}			
    }
    Last edited by _ShadoW_; 20th December 2012 at 14:10.

Posting Permissions

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

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |