Anyone seen a Javascript interpreter in Python?

Brian Kelley bkelley at wi.mit.edu
Wed Dec 11 09:05:08 EST 2002


> probably, but what exactly does java_script_function contain?
> 
Here was the original java script

function advanceProgress()
{
  var progressMeter = document.getElementById("normal");
  if(progressMeter.getAttribute('value') <= 100) {
    var newvalue = parseInt(progressMeter.getAttribute('value')) + 10;
    progressMeter.setAttribute('value', newvalue);
    setTimeout("advanceProgress()", 100);
  }
  else {
    progressMeter.setAttribute('value', 0);
    setTimeout("advanceProgress()", 100);
  }
}

This was the automatically transformed python code

def advanceProgress()
  progressMeter = document.getElementById("normal")
  if(progressMeter.getAttribute('value') <= 100):
    newvalue = parseInt(progressMeter.getAttribute('value')) + 10
    progressMeter.setAttribute('value', newvalue)
    setTimeout("advanceProgress()", 100)
  else:
    progressMeter.setAttribute('value', 0)
    setTimeout("advanceProgress()", 100)

I had to supply the parseInt (this is equivalent to int)
I don't handle for loops yet but the other conversions are there.

In this case, "document" was global in the execution environment.

> sorry, i am a bit lost.
> 
> regards,
> 
>     holger
> 





More information about the Python-list mailing list