Modify JS code to use service name rather than class name.

This commit is contained in:
Bryce Curtis 2010-09-10 15:13:53 -05:00
parent fb281ddc9f
commit 040a3d7d43
3 changed files with 10 additions and 30 deletions

View File

@ -1,25 +1,15 @@
com.phonegap.CryptoHandlerProxy = function() {
this.className = "com.phonegap.CryptoHandler";
};
com.phonegap.CryptoHandlerProxy.prototype.encrypt = function(pass, text) {
return PhoneGap.exec(this.className, "encrypt", [pass, text]);
};
com.phonegap.CryptoHandlerProxy.prototype.decrypt = function(pass, text) {
return PhoneGap.exec(this.className, "decrypt", [pass, text]);
};
com.phonegap.CryptoHandler = new com.phonegap.CryptoHandlerProxy();
var Crypto = function() { var Crypto = function() {
}; };
Crypto.prototype.encrypt = function(seed, string, callback) { Crypto.prototype.encrypt = function(seed, string, callback) {
com.phonegap.CryptoHandler.encrypt(seed, string);
this.encryptWin = callback; this.encryptWin = callback;
PhoneGap.execAsync(null, null, "Crypto", "encrypt", [seed, string]);
}; };
Crypto.prototype.decrypt = function(seed, string, callback) { Crypto.prototype.decrypt = function(seed, string, callback) {
com.phonegap.CryptoHandler.decrypt(seed, string);
this.decryptWin = callback; this.decryptWin = callback;
PhoneGap.execAsync(null, null, "Crypto", "decrypt", [seed, string]);
}; };
Crypto.prototype.gotCryptedString = function(string) { Crypto.prototype.gotCryptedString = function(string) {

View File

@ -135,21 +135,21 @@ MediaError.MEDIA_ERR_NONE_SUPPORTED = 4;
* Start or resume playing audio file. * Start or resume playing audio file.
*/ */
Media.prototype.play = function() { Media.prototype.play = function() {
PhoneGap.execAsync(null, null, "com.phonegap.AudioHandler", "startPlayingAudio", [this.id, this.src]); PhoneGap.execAsync(null, null, "Media", "startPlayingAudio", [this.id, this.src]);
}; };
/** /**
* Stop playing audio file. * Stop playing audio file.
*/ */
Media.prototype.stop = function() { Media.prototype.stop = function() {
return PhoneGap.execAsync(null, null, "com.phonegap.AudioHandler", "stopPlayingAudio", [this.id]); return PhoneGap.execAsync(null, null, "Media", "stopPlayingAudio", [this.id]);
}; };
/** /**
* Pause playing audio file. * Pause playing audio file.
*/ */
Media.prototype.pause = function() { Media.prototype.pause = function() {
PhoneGap.execAsync(null, null, "com.phonegap.AudioHandler", "pausePlayingAudio", [this.id]); PhoneGap.execAsync(null, null, "Media", "pausePlayingAudio", [this.id]);
}; };
/** /**
@ -168,20 +168,20 @@ Media.prototype.getDuration = function() {
* @return * @return
*/ */
Media.prototype.getCurrentPosition = function(success, fail) { Media.prototype.getCurrentPosition = function(success, fail) {
PhoneGap.execAsync(success, fail, "com.phonegap.AudioHandler", "getCurrentPositionAudio", [this.id]); PhoneGap.execAsync(success, fail, "Media", "getCurrentPositionAudio", [this.id]);
}; };
/** /**
* Start recording audio file. * Start recording audio file.
*/ */
Media.prototype.startRecord = function() { Media.prototype.startRecord = function() {
PhoneGap.execAsync(null, null, "com.phonegap.AudioHandler", "startRecordingAudio", [this.id, this.src]); PhoneGap.execAsync(null, null, "Media", "startRecordingAudio", [this.id, this.src]);
}; };
/** /**
* Stop recording audio file. * Stop recording audio file.
*/ */
Media.prototype.stopRecord = function() { Media.prototype.stopRecord = function() {
PhoneGap.execAsync(null, null, "com.phonegap.AudioHandler", "stopRecordingAudio", [this.id]); PhoneGap.execAsync(null, null, "Media", "stopRecordingAudio", [this.id]);
}; };

View File

@ -1,13 +1,3 @@
com.phonegap.StorageProxy = function() {
this.className = "com.phonegap.Storage";
};
com.phonegap.StorageProxy.prototype.executeSql = function(query, params, id) {
return PhoneGap.exec(this.className, "executeSql", [query, params, id]);
};
com.phonegap.StorageProxy.prototype.openDatabase = function(name, version, display_name, size) {
return PhoneGap.exec(this.className, "openDatabase", [name, version, display_name, size]);
};
com.phonegap.Storage = new com.phonegap.StorageProxy();
/* /*
* This is purely for the Android 1.5/1.6 HTML 5 Storage * This is purely for the Android 1.5/1.6 HTML 5 Storage
@ -53,7 +43,7 @@ var Tx = function() {
}; };
Tx.prototype.executeSql = function(query, params, win, fail) { Tx.prototype.executeSql = function(query, params, win, fail) {
com.phonegap.Storage.executeSql(query, params, this.id); PhoneGap.execAsync(null, null, "Storage", "executeSql", [query, params, this.id]);
tx.win = win; tx.win = win;
tx.fail = fail; tx.fail = fail;
}; };
@ -72,7 +62,7 @@ Rows.prototype.item = function(row_id) {
}; };
var dbSetup = function(name, version, display_name, size) { var dbSetup = function(name, version, display_name, size) {
com.phonegap.Storage.openDatabase(name, version, display_name, size) PhoneGap.execAsync(null, null, "Storage", "openDatabase", [name, version, display_name, size]);
db_object = new DatabaseShell(); db_object = new DatabaseShell();
return db_object; return db_object;
}; };