Results 1 to 5 of 5

Thread: Help fix "missing sem-colon"

  1. #1
    Join Date
    Oct 2009
    Posts
    31
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Help fix "missing sem-colon"

    Hi, I keep getting a missing semi colon error in internet explorer and when i run several javascript debuggers.


    Heres my code:

    Code:
    /**
     * UploadProgressMeter.js - Upload progress Meter javascript code
     *
     * Copyright (C) 2005  Joshua Eichorn  This program is free software; you can
     * redistribute it and/or modify it under the terms of the GNU General Public
     * License as published by the Free Software Foundation; either version 2 of
     * the License, or (at your option) any later version.  This program is
     * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
     * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
     * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     * You should have received a copy of the GNU General Public License along
     * with this program; if not, write to the Free Software Foundation, Inc.,
     * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
     *
     *
     * @author       Joshua Eichorn <josh@bluga.net>
     * @copyright    Joshua Eichorn (c)2005
     * @link         http://bluga.net/projects/upload_progress_meter
     * @version      0.1
     */
    
    /**
     * Global list of ids that were updating progress for
     */
    var UploadProgressMeter_list = new Object();
    
    /**
     * List of Currently Active ids
     */
    var UploadProgressMeter_active = new Object();
    
    /**
     * Currently Active count
     */
    var UploadProgressMeter_count = 0;
    
    /**
     * Update interval for progress bars
     */
    var UploadProgressMeter_interval = 2000;
    
    /**
     * ID of the current interval
     */
    var UploadProgressMeter_intervalId = false;
    
    /**
     * Remote proxy object
     */
    var UploadProgressMeter_remote = false;
    
    /**
     * Handling starting up all progress bars when a form submits
     */
    function UploadProgressMeter_Start(form) {
    	// get an array of all the ids that need to be started, were only looking in the current form
    	
    	var idsToStart = new Array();
    
    	var divs = form.getElementsByTagName('div');
    
    	for(var i = 0; i < divs.length; i++) {
    		var id = divs[i].id;
    		if (UploadProgressMeter_list[id]) {
    			UploadProgressMeter_count++;
    			UploadProgressMeter_active[id] = UploadProgressMeter_list[id];
    			UploadProgressMeter_EnableProgress(id);
    		}
    	}
    
    	if (!UploadProgressMeter_intervalId) {
    		UploadProgressMeter_intervalId = setInterval(UploadProgressMeter_Update,UploadProgressMeter_interval);
    	}
    }
    
    /**
     * Register a file input by id
     */
    function UploadProgressMeter_Register(progressId,identifier) {
    	UploadProgressMeter_list[progressId] = identifier;
    }
    
    /**
     * Shows a progress bar and sets it to 0
     */
    function UploadProgressMeter_EnableProgress(progress_id) {
    	var progress = document.getElementById(progress_id);
    	progress.style.display = 'block';
    	progress.percent = 0;
    	progress.message = "Connecting";
    
    	progress.update = function() { this.getFirstDivByClass('bar').style.width = this.percent+'%'; this.getFirstDivByClass('message').innerHTML = this. message; }
    
    	progress.getFirstDivByClass = function(className) {
    		var nodes = this.getElementsByTagName('div');
    		for(var i = 0; i < nodes.length; i++) {
    			if (nodes[i].className == className) {
    				return nodes[i];
    			}
    		}
    	}
    
    	progress.update();
    }
    
    /**
     * Update the progress bars of all the current bars
     */
    function UploadProgressMeter_Update() {
    	if (UploadProgressMeter_count == 0) {
    		clearInterval(UploadProgressMeter_intervalId);
    		UploadProgressMeter_intervalId = false;
    		return;
    	}
    
    	if (UploadProgressMeter_remote == false) {
    		var callback = {
    			get_status: function(result) {
    				for(var prop in result) {
    					if (prop != "toString") {
    						document.getElementById(prop).percent = result[prop].percent;
    						document.getElementById(prop).message = result[prop].message;
    						document.getElementById(prop).update();
    
    						if (document.getElementById(prop).percent == 100) {
    							UploadProgressMeter_count--;
    							delete UploadProgressMeter_active[prop];
    						}
    					}
    				}
    			}
    		}
    		UploadProgressMeter_remote = new uploadprogressmeterstatus(callback);
    	}
    
    	UploadProgressMeter_remote.get_status(UploadProgressMeter_active);
    }
    jslint.com gives the line where the errors occur, but im not sure how to fix

    Appreciate all help.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Rather than having us debug all of that code, which line does it say is the problem? (Maybe post the three-four surrounding lines as well, in case the error is from those.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Oct 2009
    Posts
    31
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    I get this error:

    Code:
    [Server_Error] missing ; before statement while calling uploadprogressmeterstatus.get_status()
    Last edited by newbtophp; 02-05-2010 at 03:08 PM.

  4. #4
    Join Date
    Oct 2009
    Posts
    31
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Anyone can help? :9

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I don't think this is necessarily an error in the code above. That says there was an error while calling the function.
    First you define a function in the script section at the top of the page then later you call it to use the function-- either in the body of the page or somewhere later in the script section at the top. But since I don't see anything here, I am guessing that you are missing a semicolon when you call the script.
    For example:
    <element onClick=uploadprogressmeterstatus.get_status();">

    Though Javascript allows missing semicolons (unlike many other languages), it can make things much harder to debug and also confusing to read-- I'm guessing that IE is just wanting you to be completely correct, rather than relying on a questionable method of calling a function (skipping the semicolon). In general from what I've seen this won't hurt anything, but it looks like IE is going to give a warning. Did this mean that the script didn't function, or there was just a warning even though it did work?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

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