Skip to content

Instantly share code, notes, and snippets.

View stevez's full-sized avatar

Steve Zhang stevez

  • Markham, Ontario, Canada
View GitHub Profile
def writer = new FileWriter(".classpath")
groovy.xml.XmlUtil.serialize( classpath,writer )
def classpath = new XmlParser().parse('.classpath')
classpath.each {
println "${it.@kind} ${it.@path}"
}
def newEntry = new Node(classpath, 'classpathentry', [kind:'lib', path:'libs/abc.jar'])
println "after adding a new entry:"
classpath.each {
println "${it.@kind} ${it.@path}"
<classpathentry kind="lib" path="libs/abc.jar"/>
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
...
String r = pluginManager.exec(service, action, callbackId, message, async);
...
}
PhoneGap.exec = function(success, fail, service, action, args) {
...
var r = prompt(JSON.stringify(args), "gap:"+JSON.stringify([service, action, callbackId, true]));
...
};
// Get acceleration
PhoneGap.exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
var myObject = {
value: 0,
increment: function() {
value +=1;
return value;
}
}
myObject.increment(); // => ERROR
var myObject = {
value: 0,
increment: function() {
value +=1;
return value;
}
}
myObject.increment(); // => ERROR
var myObject = {
value: 0,
increment: function() {
this.value +=1;
return this.value;
}
}
myObject.increment(); // => 1
//call before function foo is defined
foo(); // will fail, because foo() is not defined.
var foo = function () {
alert("foo");
}
//call after function foo is defined
foo(); //=> alert("foo");