www.webdeveloper.com
Results 1 to 4 of 4

Thread: parseInt in countdown

  1. #1
    Join Date
    Mar 2012
    Posts
    3

    Unhappy parseInt in countdown

    I'm trying to do this userscript that do something when a countdown is near to 0. the countdown is like hh:mm:ss and i got:

    Code:
    var remaining = parseInt(document.getElementById('counter_index_page').innerHTML.slice(6,8),10);
    if(parseInt(remaining) < parseInt(some_time_near_to_cero) )
    I added the ",10" later, when I googled and found the properties of parseInt but still not working.

    the script do what it have to do but in the wrong time.
    PS: the countdown starts in 30s every time, so only seconds are important.

    Thanks!!

  2. #2
    Join Date
    Mar 2012
    Posts
    3
    please help ?

  3. #3
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,432

    Lightbulb

    You don't have much code there to help with.

    What is the format of the .innerHTML that you are trying to slice?

    What are the results of the variable 'remaining'? You can use an alert(remaining) or write it to a page element.

    What is the value of 'some_time_near_to_cero' and what is it supposed to do in the { } block that is missing?

    Are you using the error console in the FF or Chrome browsers? What errors are you getting?

  4. #4
    Join Date
    Mar 2012
    Posts
    3
    AAAAAAAAAAAAAAAAAAAAAAAhhh!!!... I give up, javascript is not for me I think, this is the code i was trying to write, and below the @match.
    I was trying that the script would bid each time the countdown reaches 2 seconds (e.g.)
    Code:
    // ==UserScript==
    // @match http://www.subastaslocas.com.ar/Auctions/View.aspx?*
    // ==/UserScript==
    
    
    var timespaceing = 1;
    var tiempominimo = 3; 
    //alert('checkeando subasta en ' + timespaceing + ' segundos');
    var AuctionID = getParameterByName('AuctionID');
    var campo = document.getElementById('counter_index_page_' + AuctionID);
    var winner = document.getElementById('winner_index_page_' + AuctionID);
    
    setTimeout(checksubasta, 7000);
    
    
    function checksubasta()
    {
    	if (campo==null)
    	{
    		//alert('no se encontro campo de subasta');
    		//setTimeout(checksubasta, timespaceing * 1000);
    	}
    	else
    	{
    		var tiemporestante = parseInt(document.getElementById('counter_index_page_' + AuctionID).innerHTML.slice(6,8),10);
    
    		if(tiemporestante < tiempominimo)
    		{
    			//alert('tiemporestante: ' + tiemporestante +'' | tiempominimo: " + tiempominimo);
    			subastar();
    		}
    		else
    		{
    			setTimeout(checksubasta, timespaceing * 1000);
    		}
    	}
    }
    
    function subastar()
    {
    	//alert('subastar!');
    	var script = document.createElement('script');
    	script.setAttribute("type", "application/javascript");
    	script.textContent = 'BidAuction(' + AuctionID + ')();';
    	document.body.appendChild(script); // run the script
    	document.body.removeChild(script); // clean up
    	setTimeout(checksubasta, 10000);
    }
    
    
    
    function getParameterByName(name) {
    
        var match = RegExp('[?&]' + name + '=([^&]*)')
                        .exec(window.location.search);
    
        return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
    
    }
    product e.g. : http://www.subastaslocas.com.ar/Auct...AuctionID=8837

    url of interest:
    http://www.subastaslocas.com.ar/Desk...CMS/JS/main.js


    if some kind soul offered to fix it would be really great!

    Thanks a lot

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles