cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From za...@apache.org
Subject [09/12] spec commit: Manual tests fixed
Date Tue, 10 Jun 2014 10:01:01 GMT
Manual tests fixed

Removing inline scripts from mobile-spec to make it compatible with FFOS priveleged type apps (i.e. using contacts)

added addListenerToClass function which is used to connect buttons with test functions.

Please check it on all platforms and r+ if working.

moved test initialization to JS file (for DRY and privileged apps compatibility)


Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/0de5e956
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/0de5e956
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/0de5e956

Branch: refs/heads/master
Commit: 0de5e956d2f677d5ea770bb97ae6b9a1ed10c33b
Parents: 508f29f
Author: Piotr Zalewa <piotr@zalewa.info>
Authored: Wed Apr 30 15:14:04 2014 +0200
Committer: Piotr Zalewa <piotr@zalewa.info>
Committed: Wed May 14 15:53:27 2014 +0200

----------------------------------------------------------------------
 accelerometer/index.html                  | 120 +-------
 accelerometer/index.js                    | 111 ++++++++
 audio/index.html                          | 370 +------------------------
 audio/index.js                            | 356 ++++++++++++++++++++++++
 autotest/index.html                       |   3 +-
 autotest/index.js                         |   4 +
 autotest/pages/accelerometer.html         |  20 +-
 autotest/pages/all.html                   |  47 +---
 autotest/pages/all.js                     |  46 +++
 autotest/pages/battery.html               |  19 +-
 autotest/pages/bridge.html                |  20 +-
 autotest/pages/camera.html                |  20 +-
 autotest/pages/capture.html               |  20 +-
 autotest/pages/compass.html               |  20 +-
 autotest/pages/contacts.html              |  19 +-
 autotest/pages/datauri.html               |  18 +-
 autotest/pages/device.html                |  20 +-
 autotest/pages/file.html                  |  41 +--
 autotest/pages/file.js                    |  39 +++
 autotest/pages/filetransfer.html          |  41 +--
 autotest/pages/geolocation.html           |  20 +-
 autotest/pages/globalization.html         |  20 +-
 autotest/pages/localXHR.html              |  20 +-
 autotest/pages/media.html                 |  20 +-
 autotest/pages/network.html               |  20 +-
 autotest/pages/notification.html          |  20 +-
 autotest/pages/platform.html              |  20 +-
 autotest/pages/run-tests.js               |  18 ++
 autotest/pages/splashscreen.html          |  20 +-
 autotest/pages/storage.html               |  20 +-
 autotest/pages/vibration.html             |  20 +-
 autotest/pages/whitelist.html             |  20 +-
 battery/index.html                        |  83 +-----
 battery/index.js                          |  72 +++++
 camera/index.html                         | 361 +-----------------------
 camera/index.js                           | 344 +++++++++++++++++++++++
 capture/index.html                        | 147 +---------
 capture/index.js                          | 137 +++++++++
 compass/index.html                        | 114 +-------
 compass/index.js                          | 104 +++++++
 contacts/index.html                       |  99 +------
 contacts/index.js                         |  90 ++++++
 cordova-incl.js                           |  22 ++
 events/index.html                         |  86 ++----
 events/index.js                           |  94 +++++++
 file/index.html                           | 158 +----------
 file/index.js                             | 153 ++++++++++
 inappbrowser/index.html                   | 266 ++++--------------
 inappbrowser/index.js                     | 242 ++++++++++++++++
 index.html                                |   2 +-
 keyboard/index.html                       |  68 +----
 keyboard/index.js                         |  69 +++++
 keyboard/window-onerror.js                |   1 +
 lazyloadjs/do-not-write-cordova-script.js |   1 +
 lazyloadjs/index.html                     |  20 +-
 lazyloadjs/index.js                       |  16 ++
 location/index.html                       | 143 +---------
 location/index.js                         | 128 +++++++++
 main.js                                   |   2 +
 misc/index.html                           |  35 +--
 misc/index.js                             |  30 ++
 misc/page2.html                           |  14 +-
 misc/page2.js                             |  12 +
 misc/page3.html                           |  30 +-
 misc/page3A.js                            |  27 ++
 network/index.html                        |  45 +--
 network/index.js                          |  38 +++
 notification/index.html                   | 110 +-------
 notification/index.js                     | 100 +++++++
 sql/index.html                            | 137 +--------
 sql/index.js                              | 125 +++++++++
 storage/index.html                        |  37 +--
 storage/index.js                          |  27 ++
 vibration/index.html                      |  39 +--
 vibration/index.js                        |  31 +++
 75 files changed, 2687 insertions(+), 2764 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/accelerometer/index.html
----------------------------------------------------------------------
diff --git a/accelerometer/index.html b/accelerometer/index.html
index bbec57f..71000b8 100644
--- a/accelerometer/index.html
+++ b/accelerometer/index.html
@@ -27,118 +27,10 @@
     <title>Cordova Mobile Spec</title>
     <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
     <script type="text/javascript" charset="utf-8" src="../cordova-incl.js"></script>      
-
-      
-<script type="text/javascript" charset="utf-8">
-
-    var deviceReady = false;
-
-    function roundNumber(num) {
-        var dec = 3;
-        var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
-        return result;
-    }
-
-    //-------------------------------------------------------------------------
-    // Acceleration
-    //-------------------------------------------------------------------------
-    var watchAccelId = null;
-    
-    /**
-     * Start watching acceleration
-     */
-    var watchAccel = function() {
-        console.log("watchAccel()");
-
-        // Success callback
-        var success = function(a){
-            document.getElementById('x').innerHTML = roundNumber(a.x);
-            document.getElementById('y').innerHTML = roundNumber(a.y);
-            document.getElementById('z').innerHTML = roundNumber(a.z);
-            console.log("watchAccel success callback");
-        };
-
-        // Fail callback
-        var fail = function(e){
-            console.log("watchAccel fail callback with error code "+e);
-            stopAccel();
-            setAccelStatus(Accelerometer.ERROR_MSG[e]);
-        };
-
-        // Update acceleration every 1 sec
-        var opt = {};
-        opt.frequency = 1000;
-        watchAccelId = navigator.accelerometer.watchAcceleration(success, fail, opt);
-
-        setAccelStatus("Running");
-    };
-
-    /**
-     * Stop watching the acceleration
-     */
-    var stopAccel = function() {
-    	console.log("stopAccel()");
-        setAccelStatus("Stopped");
-        if (watchAccelId) {
-            navigator.accelerometer.clearWatch(watchAccelId);
-            watchAccelId = null;
-        }
-    };
-
-    /**
-     * Get current acceleration
-     */
-    var getAccel = function() {
-        console.log("getAccel()");
-
-        // Stop accel if running
-        stopAccel();
-
-        // Success callback
-        var success = function(a){
-            document.getElementById('x').innerHTML = roundNumber(a.x);
-            document.getElementById('y').innerHTML = roundNumber(a.y);
-            document.getElementById('z').innerHTML = roundNumber(a.z);
-        };
-
-        // Fail callback
-        var fail = function(e){
-            console.log("getAccel fail callback with error code "+e);
-            setAccelStatus(Accelerometer.ERROR_MSG[e]);
-        };
-
-        // Make call
-        var opt = {};
-        navigator.accelerometer.getCurrentAcceleration(success, fail, opt);
-    };
-
-    /**
-     * Set accelerometer status
-     */
-    var setAccelStatus = function(status) {
-        document.getElementById('accel_status').innerHTML = status;
-    };
-    
-    /**
-     * Function called when page has finished loading.
-     */
-    function init() {
-        console.log("accelerometer.init()");
-        document.addEventListener("deviceready", function() {
-                deviceReady = true;
-                console.log("Device="+device.platform+" "+device.version);
-            }, false);
-        window.setTimeout(function() {
-        	if (!deviceReady) {
-        		alert("Error: Apache Cordova did not initialize.  Demo will not run correctly.");
-        	}
-        },1000);
-    }
-
-</script>
+    <script type="text/javascript" charset="utf-8" src="./index.js"></script>      
 
   </head>
-  <body onload="init();" id="stage" class="theme">
+  <body id="stage" class="theme">
   
     <h1>Acceleration</h1>
     <div id="info">
@@ -151,9 +43,9 @@
     </div>
 
     <h2>Action</h2>
-    <div class="btn large" onclick="getAccel();">Get Acceleration</div>
-    <div class="btn large" onclick="watchAccel();">Start Watch</div>
-    <div class="btn large" onclick="stopAccel();">Clear Watch</div>
-    <h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
+    <div class="btn large getAccel">Get Acceleration</div>
+    <div class="btn large watchAccel">Start Watch</div>
+    <div class="btn large stopAccel">Clear Watch</div>
+    <h2> </h2><div class="backBtn">Back</div>
   </body>
 </html>      

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/accelerometer/index.js
----------------------------------------------------------------------
diff --git a/accelerometer/index.js b/accelerometer/index.js
new file mode 100644
index 0000000..946cfe2
--- /dev/null
+++ b/accelerometer/index.js
@@ -0,0 +1,111 @@
+var deviceReady = false;
+
+function roundNumber(num) {
+    var dec = 3;
+    var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
+    return result;
+}
+
+//-------------------------------------------------------------------------
+// Acceleration
+//-------------------------------------------------------------------------
+var watchAccelId = null;
+
+/**
+ * Start watching acceleration
+ */
+var watchAccel = function() {
+    console.log("watchAccel()");
+
+    // Success callback
+    var success = function(a){
+        document.getElementById('x').innerHTML = roundNumber(a.x);
+        document.getElementById('y').innerHTML = roundNumber(a.y);
+        document.getElementById('z').innerHTML = roundNumber(a.z);
+        console.log("watchAccel success callback");
+    };
+
+    // Fail callback
+    var fail = function(e){
+        console.log("watchAccel fail callback with error code "+e);
+        stopAccel();
+        setAccelStatus(Accelerometer.ERROR_MSG[e]);
+    };
+
+    // Update acceleration every 1 sec
+    var opt = {};
+    opt.frequency = 1000;
+    watchAccelId = navigator.accelerometer.watchAcceleration(success, fail, opt);
+
+    setAccelStatus("Running");
+};
+
+/**
+ * Stop watching the acceleration
+ */
+var stopAccel = function() {
+	console.log("stopAccel()");
+    setAccelStatus("Stopped");
+    if (watchAccelId) {
+        navigator.accelerometer.clearWatch(watchAccelId);
+        watchAccelId = null;
+    }
+};
+
+/**
+ * Get current acceleration
+ */
+var getAccel = function() {
+    console.log("getAccel()");
+
+    // Stop accel if running
+    stopAccel();
+
+    // Success callback
+    var success = function(a){
+        document.getElementById('x').innerHTML = roundNumber(a.x);
+        document.getElementById('y').innerHTML = roundNumber(a.y);
+        document.getElementById('z').innerHTML = roundNumber(a.z);
+    };
+
+    // Fail callback
+    var fail = function(e){
+        console.log("getAccel fail callback with error code "+e);
+        setAccelStatus(Accelerometer.ERROR_MSG[e]);
+    };
+
+    // Make call
+    var opt = {};
+    navigator.accelerometer.getCurrentAcceleration(success, fail, opt);
+};
+
+/**
+ * Set accelerometer status
+ */
+var setAccelStatus = function(status) {
+    document.getElementById('accel_status').innerHTML = status;
+};
+
+/**
+ * Function called when page has finished loading.
+ */
+function init() {
+    console.log("accelerometer.init()");
+    document.addEventListener("deviceready", function() {
+            deviceReady = true;
+            console.log("Device="+device.platform+" "+device.version);
+        }, false);
+    window.setTimeout(function() {
+    	if (!deviceReady) {
+    		alert("Error: Apache Cordova did not initialize.  Demo will not run correctly.");
+    	}
+    },1000);
+}
+
+window.onload = function() {
+  addListenerToClass('getAccel', getAccel);
+  addListenerToClass('watchAccel', watchAccel);
+  addListenerToClass('stopAccel', stopAccel);
+  addListenerToClass('backBtn', backHome);
+  init();
+}

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/audio/index.html
----------------------------------------------------------------------
diff --git a/audio/index.html b/audio/index.html
index a0286d0..a05ea04 100644
--- a/audio/index.html
+++ b/audio/index.html
@@ -28,354 +28,10 @@
     <title>Cordova Audio Tests</title>
     <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8"/>
     <script type="text/javascript" charset="utf-8" src="../cordova-incl.js"></script>      
-
-      
-<script type="text/javascript" charset="utf-8">
-
-	 var defaultaudio = "http://cordova.apache.org/downloads/BlueZedEx.mp3";
-    var deviceReady = false;
-
-    //-------------------------------------------------------------------------
-    // Audio player
-    //-------------------------------------------------------------------------
-    var media1 = null;
-    var media1Timer = null;
-    var audioSrc = null;
-    var recordSrc = "myRecording.mp3";
-
-    /**
-     * Play audio
-     */
-    function playAudio(url) {
-        console.log("playAudio()");
-        console.log(" -- media="+media1);
-
-	    var src = defaultaudio;
-        
-        if (url) {
-            src = url;
-        }
-
-        // Stop playing if src is different from currently playing source
-        if (src != audioSrc) {
-            if (media1 != null) {
-                stopAudio();
-                media1 = null;
-            }
-        }
-
-        if (media1 == null) {
-
-
-            // TEST STREAMING AUDIO PLAYBACK
-            //var src = "http://nunzioweb.com/misc/Bon_Jovi-Crush_Mystery_Train.mp3";   // works
-            //var src = "http://nunzioweb.com/misc/Bon_Jovi-Crush_Mystery_Train.m3u"; // doesn't work
-            //var src = "http://www.wav-sounds.com/cartoon/bugsbunny1.wav"; // works
-            //var src = "http://www.angelfire.com/fl5/html-tutorial/a/couldyou.mid"; // doesn't work
-            //var src = "MusicSearch/mp3/train.mp3";    // works
-            //var src = "bryce.mp3";  // works
-            //var src = "/android_asset/www/bryce.mp3"; // works
-
-            media1 = new Media(src,
-                function() {
-                    console.log("playAudio():Audio Success");
-                },
-                function(err) {
-                    console.log("playAudio():Audio Error: "+err.code);
-                    setAudioStatus("Error: " + err.code);
-                },
-                function(status) {
-                    console.log("playAudio():Audio Status: "+status);
-                    setAudioStatus(Media.MEDIA_MSG[status]);
-
-                    // If stopped, then stop getting current position
-                    if (Media.MEDIA_STOPPED == status) {
-                        clearInterval(media1Timer);
-                        media1Timer = null;
-                        setAudioPosition("0 sec");
-                    }
-                });
-        }
-        audioSrc = src;
-        document.getElementById('audio_duration').innerHTML = "";
-        // Play audio
-        media1.play();
-        if (media1Timer == null && media1.getCurrentPosition) {
-            media1Timer = setInterval(
-                function() {
-                    media1.getCurrentPosition(
-                        function(position) {
-                            console.log("Pos="+position);
-                            if (position >= 0.0) {
-                                setAudioPosition(position+" sec");
-                            }
-                        },
-                        function(e) {
-                            console.log("Error getting pos="+e);
-                            setAudioPosition("Error: "+e);
-                        }
-                    );
-                },
-                1000
-            );
-        }
-
-        // Get duration
-        var counter = 0;
-        var timerDur = setInterval(
-            function() {
-                counter = counter + 100;
-                if (counter > 2000) {
-                    clearInterval(timerDur);
-                }
-                var dur = media1.getDuration();
-                if (dur > 0) {
-                    clearInterval(timerDur);
-                    document.getElementById('audio_duration').innerHTML = dur + " sec";
-                }
-            }, 100);
-    }
-
-    /**
-     * Pause audio playback
-     */
-    function pauseAudio() {
-        console.log("pauseAudio()");
-        if (media1) {
-            media1.pause();
-        }
-    }
-
-    /**
-     * Stop audio
-     */
-    function stopAudio() {
-        console.log("stopAudio()");
-        if (media1) {
-            media1.stop();
-        }
-        clearInterval(media1Timer);
-        media1Timer = null;
-    }
-    
-    /**
-     * Release audio
-     */
-	function releaseAudio() {
-	    console.log("releaseAudio()");
-	    if (media1) {
-	    	media1.stop(); //imlied stop of playback, resets timer
-	    	media1.release();
-	    }
-	}
-	
-    /**
-     * Set audio status
-     */
-    var setAudioStatus = function(status) {
-        document.getElementById('audio_status').innerHTML = status;
-    };
-
-    /**
-     * Set audio position
-     */
-    var setAudioPosition = function(position) {
-        document.getElementById('audio_position').innerHTML = position;
-    };
-
-    //-------------------------------------------------------------------------
-    // Audio recorder
-    //-------------------------------------------------------------------------
-    var mediaRec = null;
-    var recTime = 0;
-
-    /**
-     * Record audio
-     */
-    function recordAudio() {
-        console.log("recordAudio()");
-        console.log(" -- media="+mediaRec);
-        if (mediaRec == null) {
-
-            var src = recordSrc;
-            mediaRec = new Media(src,
-                    function() {
-                        console.log("recordAudio():Audio Success");
-                    },
-                    function(err) {
-                        console.log("recordAudio():Audio Error: "+err.code);
-                        setAudioStatus("Error: " + err.code);
-                    },
-                    function(status) {
-                        console.log("recordAudio():Audio Status: "+status);
-                        setAudioStatus(Media.MEDIA_MSG[status]);
-                    }
-                );
-        }
-
-        navigator.notification.beep(1);
-
-        // Record audio
-        mediaRec.startRecord();
-
-        // Stop recording after 10 sec
-        recTime = 0;
-        var recInterval = setInterval(function() {
-            recTime = recTime + 1;
-            setAudioPosition(recTime+" sec");
-            if (recTime >= 10) {
-                clearInterval(recInterval);
-                if (mediaRec.stopAudioRecord){
-                    mediaRec.stopAudioRecord();
-                } else {
-                    mediaRec.stopRecord();
-                }
-                console.log("recordAudio(): stop");
-                navigator.notification.beep(1);
-            }
-        }, 1000);
-    }
-
-    /**
-     * Play back recorded audio
-     */
-    function playRecording() {
-        playAudio(recordSrc);
-    }
-    
-    /**
-     * Function to create a file for iOS recording
-     */
-    function getRecordSrc() {
-        var fsFail = function(error) {
-            console.log("error creating file for iOS recording");
-        };
-        var gotFile = function(file) {
-            recordSrc = file.fullPath;
-            //console.log("recording Src: " + recordSrc);
-        };
-        var gotFS = function(fileSystem) {
-            fileSystem.root.getFile("iOSRecording.wav", {create: true}, gotFile, fsFail);
-        };
-        window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, gotFS, fsFail);
-    }
-    
-    /**
-     * Function to create a file for BB recording
-     */
-    function getRecordSrcBB() {
-        var fsFail = function(error) {
-            console.log("error creating file for BB recording");
-        };
-        var gotFile = function(file) {
-            recordSrc = file.fullPath;
-        };
-        var gotFS = function(fileSystem) {
-            fileSystem.root.getFile("BBRecording.amr", {create: true}, gotFile, fsFail);
-        };
-        window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, gotFS, fsFail);
-    }
-
-    /**
-     * Function called when page has finished loading.
-     */
-    function init() {
-        document.addEventListener("deviceready", function() {
-                deviceReady = true;
-                if (device.platform.indexOf("iOS") !=-1)
-                {
-                     getRecordSrc();
-                } else if (typeof blackberry !== 'undefined') {
-                    getRecordSrcBB();
-                }
-                console.log("Device="+device.platform+" "+device.version);
-            }, false);
-        window.setTimeout(function() {
-        	if (!deviceReady) {
-        		alert("Error: Apache Cordova did not initialize.  Demo will not run correctly.");
-        	}
-        },1000);
-    }
-    
-    /**
-     * for forced updates of position after a successful seek
-     */
-    function updatePosition() {
-        media1.getCurrentPosition(
-            function(position) {
-                console.log("Pos="+position);
-                if (position >= 0.0) {
-                    setAudioPosition(position+" sec");
-                }
-            },
-            function(e) {
-                console.log("Error getting pos="+e);
-                setAudioPosition("Error: "+e);
-            });
-    }
-
-    /**
-     *
-     */
-    function seekAudio(mode) {
-        var time = document.getElementById("seekinput").value;
-        if (time == "") {
-            time = 5000;
-        } else {
-            time = time * 1000; //we expect the input to be in seconds
-        }
-        if (media1 == null) {
-            console.log("seekTo requested while media1 is null");
-            if (audioSrc == null) {
-                audioSrc = defaultaudio;
-            }
-            media1 = new Media(audioSrc,
-                function() {
-                    console.log("seekToAudio():Audio Success");
-                },
-                function(err) {
-                    console.log("seekAudio():Audio Error: "+err.code);
-                    setAudioStatus("Error: " + err.code);
-                },
-                function(status) {
-                    console.log("seekAudio():Audio Status: "+status);
-                    setAudioStatus(Media.MEDIA_MSG[status]);
-
-                    // If stopped, then stop getting current position
-                    if (Media.MEDIA_STOPPED == status) {
-                        clearInterval(media1Timer);
-                        media1Timer = null;
-                        setAudioPosition("0 sec");
-                    }
-                });
-        }
-        
-        media1.getCurrentPosition(
-            function (position) {
-                var deltat = time;
-                if (mode == "by") {
-                    deltat = time + position * 1000;   
-                }
-                media1.seekTo(deltat,
-                    function () {
-                        console.log("seekAudioTo():Audio Success");
-                        //force an update on the position display
-                        updatePosition();
-                    },
-                    function (err) {
-                        console.log("seekAudioTo():Audio Error: " + err.code);
-                    });
-            },
-            function(e) {
-                console.log("Error getting pos="+e);
-                setAudioPosition("Error: "+e);
-            });
-    }
-    
-</script>
+    <script type="text/javascript" charset="utf-8" src="./index.js"></script>      
 
   </head>
-  <body onload="init();" id="stage" class="theme">
+  <body id="stage" class="theme">
   
     <h1>Audio</h1>  
     <div id="info">
@@ -391,19 +47,19 @@
             <th colspan=3>Play Sample Audio</th>
         </tr>
         <tr>
-            <td><div class="btn wide" onclick="playAudio();">Play</div></td>
-            <td><div class="btn wide" onclick="pauseAudio();">Pause</div></td>
+            <td><div class="btn wide playAudio">Play</div></td>
+            <td><div class="btn wide pauseAudio">Pause</div></td>
         </tr>
         <tr>
-            <td><div class="btn wide" onclick="stopAudio();">Stop</div></td>
-            <td><div class="btn wide" onclick="releaseAudio();">Release</div></td>
+            <td><div class="btn wide stopAudio">Stop</div></td>
+            <td><div class="btn wide releaseAudio">Release</div></td>
         </tr>
     </table>
     
     <table style="width:80%;">
         <tr>
-            <td><div class="btn wide" onclick="seekAudio('by');">Seek By</div></td>
-            <td><div class="btn wide" onclick="seekAudio('to');">Seek To</div></td>
+            <td><div class="btn wide seekAudioBy">Seek By</div></td>
+            <td><div class="btn wide seekAudioTo">Seek To</div></td>
             <td>
                 <div>
                     <input class="input numeric" type="number" id="seekinput" value="in seconds">
@@ -417,16 +73,16 @@
             <th colspan=3><br><br>Record Audio</th>
         </tr>
         <tr>
-            <td colspan=3><div class="btn wide" onclick="recordAudio();">Record Audio for 10 sec</a></td>
+            <td colspan=3><div class="btn wide recordAudio">Record Audio for 10 sec</a></td>
         </tr>
         <tr>
-            <td><div class="btn wide" onclick="playRecording();">Play</div></td>
-            <td><div class="btn wide" onclick="pauseAudio();">Pause</div></td>
-            <td><div class="btn wide" onclick="stopAudio();">Stop</div></td>
+            <td><div class="btn wide playRecording">Play</div></td>
+            <td><div class="btn wide pauseAudio">Pause</div></td>
+            <td><div class="btn wide stopAudio">Stop</div></td>
         </tr>
     </table>
     
-    <h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
+    <h2> </h2><div class="backBtn">Back</div>
     
   </body>
 </html>      

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/audio/index.js
----------------------------------------------------------------------
diff --git a/audio/index.js b/audio/index.js
new file mode 100644
index 0000000..e7ca9b6
--- /dev/null
+++ b/audio/index.js
@@ -0,0 +1,356 @@
+var defaultaudio = "http://cordova.apache.org/downloads/BlueZedEx.mp3";
+var deviceReady = false;
+
+//-------------------------------------------------------------------------
+// Audio player
+//-------------------------------------------------------------------------
+var media1 = null;
+var media1Timer = null;
+var audioSrc = null;
+var recordSrc = "myRecording.mp3";
+
+/**
+ * Play audio
+ */
+function playAudio(url) {
+    console.log("playAudio()");
+    console.log(" -- media="+media1);
+
+  var src = defaultaudio;
+    
+    if (url) {
+        src = url;
+    }
+
+    // Stop playing if src is different from currently playing source
+    if (src != audioSrc) {
+        if (media1 != null) {
+            stopAudio();
+            media1 = null;
+        }
+    }
+
+    if (media1 == null) {
+
+
+        // TEST STREAMING AUDIO PLAYBACK
+        //var src = "http://nunzioweb.com/misc/Bon_Jovi-Crush_Mystery_Train.mp3";   // works
+        //var src = "http://nunzioweb.com/misc/Bon_Jovi-Crush_Mystery_Train.m3u"; // doesn't work
+        //var src = "http://www.wav-sounds.com/cartoon/bugsbunny1.wav"; // works
+        //var src = "http://www.angelfire.com/fl5/html-tutorial/a/couldyou.mid"; // doesn't work
+        //var src = "MusicSearch/mp3/train.mp3";    // works
+        //var src = "bryce.mp3";  // works
+        //var src = "/android_asset/www/bryce.mp3"; // works
+
+        media1 = new Media(src,
+            function() {
+                console.log("playAudio():Audio Success");
+            },
+            function(err) {
+                console.log("playAudio():Audio Error: "+err.code);
+                setAudioStatus("Error: " + err.code);
+            },
+            function(status) {
+                console.log("playAudio():Audio Status: "+status);
+                setAudioStatus(Media.MEDIA_MSG[status]);
+
+                // If stopped, then stop getting current position
+                if (Media.MEDIA_STOPPED == status) {
+                    clearInterval(media1Timer);
+                    media1Timer = null;
+                    setAudioPosition("0 sec");
+                }
+            });
+    }
+    audioSrc = src;
+    document.getElementById('audio_duration').innerHTML = "";
+    // Play audio
+    media1.play();
+    if (media1Timer == null && media1.getCurrentPosition) {
+        media1Timer = setInterval(
+            function() {
+                media1.getCurrentPosition(
+                    function(position) {
+                        console.log("Pos="+position);
+                        if (position >= 0.0) {
+                            setAudioPosition(position+" sec");
+                        }
+                    },
+                    function(e) {
+                        console.log("Error getting pos="+e);
+                        setAudioPosition("Error: "+e);
+                    }
+                );
+            },
+            1000
+        );
+    }
+
+    // Get duration
+    var counter = 0;
+    var timerDur = setInterval(
+        function() {
+            counter = counter + 100;
+            if (counter > 2000) {
+                clearInterval(timerDur);
+            }
+            var dur = media1.getDuration();
+            if (dur > 0) {
+                clearInterval(timerDur);
+                document.getElementById('audio_duration').innerHTML = dur + " sec";
+            }
+        }, 100);
+}
+
+/**
+ * Pause audio playback
+ */
+function pauseAudio() {
+    console.log("pauseAudio()");
+    if (media1) {
+        media1.pause();
+    }
+}
+
+/**
+ * Stop audio
+ */
+function stopAudio() {
+    console.log("stopAudio()");
+    if (media1) {
+        media1.stop();
+    }
+    clearInterval(media1Timer);
+    media1Timer = null;
+}
+
+/**
+ * Release audio
+ */
+function releaseAudio() {
+  console.log("releaseAudio()");
+  if (media1) {
+  	media1.stop(); //imlied stop of playback, resets timer
+  	media1.release();
+  }
+}
+
+
+/**
+ * Set audio status
+ */
+function setAudioStatus(status) {
+    document.getElementById('audio_status').innerHTML = status;
+};
+
+/**
+ * Set audio position
+ */
+function setAudioPosition(position) {
+    document.getElementById('audio_position').innerHTML = position;
+};
+
+//-------------------------------------------------------------------------
+// Audio recorder
+//-------------------------------------------------------------------------
+var mediaRec = null;
+var recTime = 0;
+
+/**
+ * Record audio
+ */
+function recordAudio() {
+    console.log("recordAudio()");
+    console.log(" -- media="+mediaRec);
+    if (mediaRec == null) {
+
+        var src = recordSrc;
+        mediaRec = new Media(src,
+                function() {
+                    console.log("recordAudio():Audio Success");
+                },
+                function(err) {
+                    console.log("recordAudio():Audio Error: "+err.code);
+                    setAudioStatus("Error: " + err.code);
+                },
+                function(status) {
+                    console.log("recordAudio():Audio Status: "+status);
+                    setAudioStatus(Media.MEDIA_MSG[status]);
+                }
+            );
+    }
+
+    navigator.notification.beep(1);
+
+    // Record audio
+    mediaRec.startRecord();
+
+    // Stop recording after 10 sec
+    recTime = 0;
+    var recInterval = setInterval(function() {
+        recTime = recTime + 1;
+        setAudioPosition(recTime+" sec");
+        if (recTime >= 10) {
+            clearInterval(recInterval);
+            if (mediaRec.stopAudioRecord){
+                mediaRec.stopAudioRecord();
+            } else {
+                mediaRec.stopRecord();
+            }
+            console.log("recordAudio(): stop");
+            navigator.notification.beep(1);
+        }
+    }, 1000);
+}
+
+/**
+ * Play back recorded audio
+ */
+function playRecording() {
+    playAudio(recordSrc);
+}
+
+/**
+ * Function to create a file for iOS recording
+ */
+function getRecordSrc() {
+    var fsFail = function(error) {
+        console.log("error creating file for iOS recording");
+    };
+    var gotFile = function(file) {
+        recordSrc = file.fullPath;
+        //console.log("recording Src: " + recordSrc);
+    };
+    var gotFS = function(fileSystem) {
+        fileSystem.root.getFile("iOSRecording.wav", {create: true}, gotFile, fsFail);
+    };
+    window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, gotFS, fsFail);
+}
+
+/**
+ * Function to create a file for BB recording
+ */
+function getRecordSrcBB() {
+    var fsFail = function(error) {
+        console.log("error creating file for BB recording");
+    };
+    var gotFile = function(file) {
+        recordSrc = file.fullPath;
+    };
+    var gotFS = function(fileSystem) {
+        fileSystem.root.getFile("BBRecording.amr", {create: true}, gotFile, fsFail);
+    };
+    window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, gotFS, fsFail);
+}
+
+/**
+ * Function called when page has finished loading.
+ */
+function init() {
+    document.addEventListener("deviceready", function() {
+            deviceReady = true;
+            if (device.platform.indexOf("iOS") !=-1)
+            {
+                 getRecordSrc();
+            } else if (typeof blackberry !== 'undefined') {
+                getRecordSrcBB();
+            }
+            console.log("Device="+device.platform+" "+device.version);
+        }, false);
+    window.setTimeout(function() {
+    	if (!deviceReady) {
+    		alert("Error: Apache Cordova did not initialize.  Demo will not run correctly.");
+    	}
+    },1000);
+}
+
+/**
+ * for forced updates of position after a successful seek
+ */
+function updatePosition() {
+    media1.getCurrentPosition(
+        function(position) {
+            console.log("Pos="+position);
+            if (position >= 0.0) {
+                setAudioPosition(position+" sec");
+            }
+        },
+        function(e) {
+            console.log("Error getting pos="+e);
+            setAudioPosition("Error: "+e);
+        });
+}
+
+/**
+ *
+ */
+function seekAudio(mode) {
+    var time = document.getElementById("seekinput").value;
+    if (time == "") {
+        time = 5000;
+    } else {
+        time = time * 1000; //we expect the input to be in seconds
+    }
+    if (media1 == null) {
+        console.log("seekTo requested while media1 is null");
+        if (audioSrc == null) {
+            audioSrc = defaultaudio;
+        }
+        media1 = new Media(audioSrc,
+            function() {
+                console.log("seekToAudio():Audio Success");
+            },
+            function(err) {
+                console.log("seekAudio():Audio Error: "+err.code);
+                setAudioStatus("Error: " + err.code);
+            },
+            function(status) {
+                console.log("seekAudio():Audio Status: "+status);
+                setAudioStatus(Media.MEDIA_MSG[status]);
+
+                // If stopped, then stop getting current position
+                if (Media.MEDIA_STOPPED == status) {
+                    clearInterval(media1Timer);
+                    media1Timer = null;
+                    setAudioPosition("0 sec");
+                }
+            });
+    }
+    
+    media1.getCurrentPosition(
+        function (position) {
+            var deltat = time;
+            if (mode == "by") {
+                deltat = time + position * 1000;   
+            }
+            media1.seekTo(deltat,
+                function () {
+                    console.log("seekAudioTo():Audio Success");
+                    //force an update on the position display
+                    updatePosition();
+                },
+                function (err) {
+                    console.log("seekAudioTo():Audio Error: " + err.code);
+                });
+        },
+        function(e) {
+            console.log("Error getting pos="+e);
+            setAudioPosition("Error: "+e);
+        });
+}
+
+window.onload = function() {
+  addListenerToClass('playAudio', function () {
+    playAudio();
+  });
+  addListenerToClass('pauseAudio', pauseAudio);
+  addListenerToClass('stopAudio', stopAudio);
+  addListenerToClass('releaseAudio', releaseAudio);
+  addListenerToClass('seekAudioBy', seekAudio, 'by');
+  addListenerToClass('seekAudioTo', seekAudio, 'to');
+  addListenerToClass('recordAudio', recordAudio);
+  addListenerToClass('playRecording', playRecording);
+
+  addListenerToClass('backBtn', backHome);
+  init();
+}

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/index.html
----------------------------------------------------------------------
diff --git a/autotest/index.html b/autotest/index.html
index a699870..3a41d78 100644
--- a/autotest/index.html
+++ b/autotest/index.html
@@ -30,6 +30,7 @@
 
     <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
     <script type="text/javascript" src="../cordova-incl.js"></script>
+    <script type="text/javascript" charset="utf-8" src="./index.js"></script>      
   </head>
   <body id="stage" class="theme">
     <h1>Cordova API Specs</h1>
@@ -57,6 +58,6 @@
     <a href="pages/whitelist.html" class="btn large" style="width:100%;">Run Whitelist Tests</a>
     <a href="pages/localXHR.html" class="btn large" style="width:100%;">Run local XHR Tests</a>
     <a href="pages/vibration.html" class="btn large" style="width:100%;">Run Vibration Tests</a>
-    <h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
+    <h2> </h2><div class="backBtn">Back</div>
   </body>
 </html>

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/index.js
----------------------------------------------------------------------
diff --git a/autotest/index.js b/autotest/index.js
new file mode 100644
index 0000000..aec19b4
--- /dev/null
+++ b/autotest/index.js
@@ -0,0 +1,4 @@
+window.onload = function() {
+  addListenerToClass('backBtn', backHome);
+}
+

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/accelerometer.html
----------------------------------------------------------------------
diff --git a/autotest/pages/accelerometer.html b/autotest/pages/accelerometer.html
index 856dc70..52b333b 100644
--- a/autotest/pages/accelerometer.html
+++ b/autotest/pages/accelerometer.html
@@ -45,26 +45,10 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/accelerometer.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/all.html
----------------------------------------------------------------------
diff --git a/autotest/pages/all.html b/autotest/pages/all.html
index ef656bc..e381ef4 100644
--- a/autotest/pages/all.html
+++ b/autotest/pages/all.html
@@ -63,53 +63,10 @@
   <script type="text/javascript" src="../tests/storage.tests.js"></script>
   <script type="text/javascript" src="../tests/splashscreen.tests.js"></script>
   <script type="text/javascript" src="../tests/localXHR.tests.js"></script>
-
-  <script type="text/javascript">
-      var root, temp_root, persistent_root;
-
-      document.addEventListener('deviceready', function () {
-          // one-time retrieval of the root file system entry
-          var onError = function(e) {
-              console.log('[ERROR] Problem setting up root filesystem for test running! Error to follow.');
-              console.log(JSON.stringify(e));
-          };
-
-          window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
-              function(fileSystem) {
-                  console.log('File API test Init: Setting PERSISTENT FS.');
-                  root = fileSystem.root; // set in file.tests.js
-                  persistent_root = root;
-
-                  // Once root is set up, fire off tests
-                  var jasmineEnv = jasmine.getEnv();
-                  jasmineEnv.updateInterval = 1000;
-
-                  var htmlReporter = new jasmine.HtmlReporter();
-                  jasmineEnv.addReporter(htmlReporter);
-
-                  // the following will only be defined if the Medic plugin is loaded
-                  if('medic' in window) {
-                      if( medic.isEnabled() ) {
-                          jasmineEnv.addReporter(medic.getJSReporter());
-                      }
-                  }
-
-                  jasmineEnv.specFilter = function(spec) {
-                    return htmlReporter.specFilter(spec);
-                  };
-
-                  jasmineEnv.execute();
-              }, onError);
-          window.requestFileSystem(LocalFileSystem.TEMPORARY, 0,
-              function(fileSystem) {
-                  console.log('File API test Init: Setting TEMPORARY FS.');
-                  temp_root = fileSystem.root; // set in file.tests.js
-              }, onError);
-      }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./all.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a class="backBtn">Back</a>
 </body>
 </html>

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/all.js
----------------------------------------------------------------------
diff --git a/autotest/pages/all.js b/autotest/pages/all.js
new file mode 100644
index 0000000..bc72b29
--- /dev/null
+++ b/autotest/pages/all.js
@@ -0,0 +1,46 @@
+var root, temp_root, persistent_root;
+
+document.addEventListener('deviceready', function () {
+    // one-time retrieval of the root file system entry
+    var onError = function(e) {
+        console.log('[ERROR] Problem setting up root filesystem for test running! Error to follow.');
+        console.log(JSON.stringify(e));
+    };
+
+    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
+        function(fileSystem) {
+            console.log('File API test Init: Setting PERSISTENT FS.');
+            root = fileSystem.root; // set in file.tests.js
+            persistent_root = root;
+
+            // Once root is set up, fire off tests
+            var jasmineEnv = jasmine.getEnv();
+            jasmineEnv.updateInterval = 1000;
+
+            var htmlReporter = new jasmine.HtmlReporter();
+            jasmineEnv.addReporter(htmlReporter);
+
+            // the following will only be defined if the Medic plugin is loaded
+            if('medic' in window) {
+                if( medic.isEnabled() ) {
+                    jasmineEnv.addReporter(medic.getJSReporter());
+                }
+            }
+
+            jasmineEnv.specFilter = function(spec) {
+              return htmlReporter.specFilter(spec);
+            };
+
+            jasmineEnv.execute();
+        }, onError);
+    window.requestFileSystem(LocalFileSystem.TEMPORARY, 0,
+        function(fileSystem) {
+            console.log('File API test Init: Setting TEMPORARY FS.');
+            temp_root = fileSystem.root; // set in file.tests.js
+        }, onError);
+}, false);
+
+window.onload = function() {
+  addListenerToClass('backBtn', backHome);
+}
+

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/battery.html
----------------------------------------------------------------------
diff --git a/autotest/pages/battery.html b/autotest/pages/battery.html
index cb430de..2063417 100644
--- a/autotest/pages/battery.html
+++ b/autotest/pages/battery.html
@@ -42,25 +42,10 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/battery.tests.js"></script>
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a class="backBtn">Back</a>
 </body>
 </html>

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/bridge.html
----------------------------------------------------------------------
diff --git a/autotest/pages/bridge.html b/autotest/pages/bridge.html
index ca03e79..822d9ec 100644
--- a/autotest/pages/bridge.html
+++ b/autotest/pages/bridge.html
@@ -45,27 +45,11 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/bridge.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>
 

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/camera.html
----------------------------------------------------------------------
diff --git a/autotest/pages/camera.html b/autotest/pages/camera.html
index c1dafee..91843d7 100644
--- a/autotest/pages/camera.html
+++ b/autotest/pages/camera.html
@@ -46,26 +46,10 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/camera.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/capture.html
----------------------------------------------------------------------
diff --git a/autotest/pages/capture.html b/autotest/pages/capture.html
index 39faa2b..bac570f 100644
--- a/autotest/pages/capture.html
+++ b/autotest/pages/capture.html
@@ -45,27 +45,11 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/capture.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a class="backBtn">Back</a>
 </body>
 </html>
 

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/compass.html
----------------------------------------------------------------------
diff --git a/autotest/pages/compass.html b/autotest/pages/compass.html
index d97b680..80de16f 100644
--- a/autotest/pages/compass.html
+++ b/autotest/pages/compass.html
@@ -45,27 +45,11 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/compass.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>
 

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/contacts.html
----------------------------------------------------------------------
diff --git a/autotest/pages/contacts.html b/autotest/pages/contacts.html
index 1518f19..e8e5fae 100644
--- a/autotest/pages/contacts.html
+++ b/autotest/pages/contacts.html
@@ -46,26 +46,11 @@
   <!-- Tests -->
   <script type="text/javascript" src="../tests/contacts.tests.js"></script>
 
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn" id="backHome">Back</a>
 </body>
 </html>
 

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/datauri.html
----------------------------------------------------------------------
diff --git a/autotest/pages/datauri.html b/autotest/pages/datauri.html
index b64b21a..33474dd 100644
--- a/autotest/pages/datauri.html
+++ b/autotest/pages/datauri.html
@@ -43,23 +43,7 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/datauri.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/device.html
----------------------------------------------------------------------
diff --git a/autotest/pages/device.html b/autotest/pages/device.html
index 7252e67..b1bed1d 100644
--- a/autotest/pages/device.html
+++ b/autotest/pages/device.html
@@ -45,27 +45,11 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/device.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>
 

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/file.html
----------------------------------------------------------------------
diff --git a/autotest/pages/file.html b/autotest/pages/file.html
index d143c74..d201791 100644
--- a/autotest/pages/file.html
+++ b/autotest/pages/file.html
@@ -44,47 +44,10 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/file.tests.js"></script>
-
-  <script type="text/javascript">
-      var root, temp_root, persistent_root;
-
-      document.addEventListener('deviceready', function () {
-          // one-time retrieval of the root file system entry
-          var onError = function(e) {
-              console.log('[ERROR] Problem setting up root filesystem for test running! Error to follow.');
-              console.log(JSON.stringify(e));
-          };
-
-          window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
-              function(fileSystem) {
-                  console.log('File API test Init: Setting PERSISTENT FS.');
-                  root = fileSystem.root; // set in file.tests.js
-                  persistent_root = root;
-
-                  // Once root is set up, fire off tests
-                  var jasmineEnv = jasmine.getEnv();
-                  jasmineEnv.updateInterval = 1000;
-
-                  var htmlReporter = new jasmine.HtmlReporter();
-
-                  jasmineEnv.addReporter(htmlReporter);
-
-                  jasmineEnv.specFilter = function(spec) {
-                    return htmlReporter.specFilter(spec);
-                  };
-
-                  jasmineEnv.execute();
-              }, onError);
-          window.requestFileSystem(LocalFileSystem.TEMPORARY, 0,
-              function(fileSystem) {
-                  console.log('File API test Init: Setting TEMPORARY FS.');
-                  temp_root = fileSystem.root; // set in file.tests.js
-              }, onError);
-      }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./file.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/file.js
----------------------------------------------------------------------
diff --git a/autotest/pages/file.js b/autotest/pages/file.js
new file mode 100644
index 0000000..9b1a67a
--- /dev/null
+++ b/autotest/pages/file.js
@@ -0,0 +1,39 @@
+var root, temp_root, persistent_root;
+
+document.addEventListener('deviceready', function () {
+    // one-time retrieval of the root file system entry
+    var onError = function(e) {
+        console.log('[ERROR] Problem setting up root filesystem for test running! Error to follow.');
+        console.log(JSON.stringify(e));
+    };
+
+    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
+        function(fileSystem) {
+            console.log('File API test Init: Setting PERSISTENT FS.');
+            root = fileSystem.root; // set in file.tests.js
+            persistent_root = root;
+
+            // Once root is set up, fire off tests
+            var jasmineEnv = jasmine.getEnv();
+            jasmineEnv.updateInterval = 1000;
+
+            var htmlReporter = new jasmine.HtmlReporter();
+
+            jasmineEnv.addReporter(htmlReporter);
+
+            jasmineEnv.specFilter = function(spec) {
+              return htmlReporter.specFilter(spec);
+            };
+
+            jasmineEnv.execute();
+        }, onError);
+    window.requestFileSystem(LocalFileSystem.TEMPORARY, 0,
+        function(fileSystem) {
+            console.log('File API test Init: Setting TEMPORARY FS.');
+            temp_root = fileSystem.root; // set in file.tests.js
+        }, onError);
+}, false);
+
+window.onload = function() {
+  addListenerToClass('backBtn', backHome);
+}

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/filetransfer.html
----------------------------------------------------------------------
diff --git a/autotest/pages/filetransfer.html b/autotest/pages/filetransfer.html
index 60cfcff..09809d8 100644
--- a/autotest/pages/filetransfer.html
+++ b/autotest/pages/filetransfer.html
@@ -44,48 +44,11 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/filetransfer.tests.js"></script>
-
-  <script type="text/javascript">
-      var root, temp_root, persistent_root;
-
-      document.addEventListener('deviceready', function () {
-          // one-time retrieval of the root file system entry
-          var onError = function(e) {
-              console.log('[ERROR] Problem setting up root filesystem for test running! Error to follow.');
-              console.log(JSON.stringify(e));
-          };
-
-          window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
-              function(fileSystem) {
-                  console.log('File API test Init: Setting PERSISTENT FS.');
-                  root = fileSystem.root; // set in file.tests.js
-                  persistent_root = root;
-
-                  // Once root is set up, fire off tests
-                  var jasmineEnv = jasmine.getEnv();
-                  jasmineEnv.updateInterval = 1000;
-
-                  var htmlReporter = new jasmine.HtmlReporter();
-
-                  jasmineEnv.addReporter(htmlReporter);
-
-                  jasmineEnv.specFilter = function(spec) {
-                    return htmlReporter.specFilter(spec);
-                  };
-
-                  jasmineEnv.execute();
-              }, onError);
-          window.requestFileSystem(LocalFileSystem.TEMPORARY, 0,
-              function(fileSystem) {
-                  console.log('File API test Init: Setting TEMPORARY FS.');
-                  temp_root = fileSystem.root; // set in file.tests.js
-              }, onError);
-      }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./file.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>
 

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/geolocation.html
----------------------------------------------------------------------
diff --git a/autotest/pages/geolocation.html b/autotest/pages/geolocation.html
index 39f634e..b7a0698 100644
--- a/autotest/pages/geolocation.html
+++ b/autotest/pages/geolocation.html
@@ -45,27 +45,11 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/geolocation.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>
 

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/globalization.html
----------------------------------------------------------------------
diff --git a/autotest/pages/globalization.html b/autotest/pages/globalization.html
index 6ca5aaf..295067e 100644
--- a/autotest/pages/globalization.html
+++ b/autotest/pages/globalization.html
@@ -45,26 +45,10 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/globalization.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/localXHR.html
----------------------------------------------------------------------
diff --git a/autotest/pages/localXHR.html b/autotest/pages/localXHR.html
index 2e64007..10415f0 100644
--- a/autotest/pages/localXHR.html
+++ b/autotest/pages/localXHR.html
@@ -45,26 +45,10 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/localXHR.tests.js"></script>
-
-  <script type="text/javascript">
-      document.addEventListener('deviceready', function () {
-          var jasmineEnv = jasmine.getEnv();
-          jasmineEnv.updateInterval = 1000;
-
-          var htmlReporter = new jasmine.HtmlReporter();
-
-          jasmineEnv.addReporter(htmlReporter);
-
-          jasmineEnv.specFilter = function (spec) {
-              return htmlReporter.specFilter(spec);
-          };
-
-          jasmineEnv.execute();
-      }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/media.html
----------------------------------------------------------------------
diff --git a/autotest/pages/media.html b/autotest/pages/media.html
index 7e2c9e5..ac1fa75 100644
--- a/autotest/pages/media.html
+++ b/autotest/pages/media.html
@@ -45,27 +45,11 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/media.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>
 

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/network.html
----------------------------------------------------------------------
diff --git a/autotest/pages/network.html b/autotest/pages/network.html
index dcdec18..6af5521 100644
--- a/autotest/pages/network.html
+++ b/autotest/pages/network.html
@@ -45,27 +45,11 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/network.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>
 

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/notification.html
----------------------------------------------------------------------
diff --git a/autotest/pages/notification.html b/autotest/pages/notification.html
index 5ebfb86..50777bf 100644
--- a/autotest/pages/notification.html
+++ b/autotest/pages/notification.html
@@ -45,27 +45,11 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/notification.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>
 

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/platform.html
----------------------------------------------------------------------
diff --git a/autotest/pages/platform.html b/autotest/pages/platform.html
index e6ae3af..3ddecd0 100644
--- a/autotest/pages/platform.html
+++ b/autotest/pages/platform.html
@@ -45,27 +45,11 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/platform.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>
 

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/run-tests.js
----------------------------------------------------------------------
diff --git a/autotest/pages/run-tests.js b/autotest/pages/run-tests.js
new file mode 100644
index 0000000..8e079ad
--- /dev/null
+++ b/autotest/pages/run-tests.js
@@ -0,0 +1,18 @@
+document.addEventListener('deviceready', function () {
+  var jasmineEnv = jasmine.getEnv();
+  jasmineEnv.updateInterval = 1000;
+
+  var htmlReporter = new jasmine.HtmlReporter();
+
+  jasmineEnv.addReporter(htmlReporter);
+
+  jasmineEnv.specFilter = function(spec) {
+    return htmlReporter.specFilter(spec);
+  };
+
+  jasmineEnv.execute();
+}, false);
+
+window.onload = function() {
+  addListenerToClass('backBtn', backHome);
+}

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/splashscreen.html
----------------------------------------------------------------------
diff --git a/autotest/pages/splashscreen.html b/autotest/pages/splashscreen.html
index d830f9e..6ac1c4d 100644
--- a/autotest/pages/splashscreen.html
+++ b/autotest/pages/splashscreen.html
@@ -45,27 +45,11 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/splashscreen.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>
 

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/storage.html
----------------------------------------------------------------------
diff --git a/autotest/pages/storage.html b/autotest/pages/storage.html
index 9ca226b..0f836e9 100644
--- a/autotest/pages/storage.html
+++ b/autotest/pages/storage.html
@@ -45,27 +45,11 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/storage.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>
 

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/vibration.html
----------------------------------------------------------------------
diff --git a/autotest/pages/vibration.html b/autotest/pages/vibration.html
index b6bd03f..04db2ec 100644
--- a/autotest/pages/vibration.html
+++ b/autotest/pages/vibration.html
@@ -45,27 +45,11 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/vibration.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>
 

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/autotest/pages/whitelist.html
----------------------------------------------------------------------
diff --git a/autotest/pages/whitelist.html b/autotest/pages/whitelist.html
index ca3712c..ececfa2 100644
--- a/autotest/pages/whitelist.html
+++ b/autotest/pages/whitelist.html
@@ -45,27 +45,11 @@
 
   <!-- Tests -->
   <script type="text/javascript" src="../tests/whitelist.tests.js"></script>
-
-  <script type="text/javascript">
-    document.addEventListener('deviceready', function () {
-      var jasmineEnv = jasmine.getEnv();
-      jasmineEnv.updateInterval = 1000;
-
-      var htmlReporter = new jasmine.HtmlReporter();
-
-      jasmineEnv.addReporter(htmlReporter);
-
-      jasmineEnv.specFilter = function(spec) {
-        return htmlReporter.specFilter(spec);
-      };
-
-      jasmineEnv.execute();
-    }, false);
-  </script>
+  <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>      
 </head>
 
 <body>
-  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  <a href="javascript:" class="backBtn">Back</a>
 </body>
 </html>
 

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/battery/index.html
----------------------------------------------------------------------
diff --git a/battery/index.html b/battery/index.html
index 70b0db7..016dc87 100644
--- a/battery/index.html
+++ b/battery/index.html
@@ -28,75 +28,10 @@
     <title>Cordova Mobile Spec</title>
     <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
     <script type="text/javascript" charset="utf-8" src="../cordova-incl.js"></script>      
-
-      
-<script type="text/javascript" charset="utf-8">
-
-    var deviceReady = false;
-    
-    /**
-     * Function called when page has finished loading.
-     */
-    function init() {
-        document.addEventListener("deviceready", function() {
-                deviceReady = true;
-                console.log("Device="+device.platform+" "+device.version);
-            }, false);
-        window.setTimeout(function() {
-            if (!deviceReady) {
-                alert("Error: Apache Cordova did not initialize.  Demo will not run correctly.");
-            }
-        },1000);
-    }
-
-    /* Battery */
-    function updateInfo(info) {
-        document.getElementById('level').innerText = info.level;
-        document.getElementById('isPlugged').innerText = info.isPlugged;
-        if (info.level > 5) {
-            document.getElementById('crit').innerText = "false";
-        }
-        if (info.level > 20) {
-            document.getElementById('low').innerText = "false";
-        }
-    }
-    
-    function batteryLow(info) {
-        document.getElementById('low').innerText = "true";
-    }
-    
-    function batteryCritical(info) {
-        document.getElementById('crit').innerText = "true";
-    }
-    
-    function addBattery() {
-        window.addEventListener("batterystatus", updateInfo, false);
-    }
-    
-    function removeBattery() {
-        window.removeEventListener("batterystatus", updateInfo, false);
-    }
-    
-    function addLow() {
-        window.addEventListener("batterylow", batteryLow, false);
-    }
-    
-    function removeLow() {
-        window.removeEventListener("batterylow", batteryLow, false);
-    }
-    
-    function addCritical() {
-        window.addEventListener("batterycritical", batteryCritical, false);
-    }
-    
-    function removeCritical() {
-        window.removeEventListener("batterycritical", batteryCritical, false);
-    }
-
-</script>
+    <script type="text/javascript" charset="utf-8" src="./index.js"></script>      
 
   </head>
-  <body onload="init();" id="stage" class="theme">
+  <body id="stage" class="theme">
   
     <h1>Battery</h1>
     <div id="info">
@@ -107,12 +42,12 @@
         Critical: <span id="crit"></span><br/>
     </div>
     <h2>Action</h2>
-    <div class="btn large" onclick="addBattery();">Add "batterystatus" listener</div>
-    <div class="btn large" onclick="removeBattery();">Remove "batterystatus" listener</div>
-    <div class="btn large" onclick="addLow();">Add "batterylow" listener</div>
-    <div class="btn large" onclick="removeLow();">Remove "batterylow" listener</div>
-    <div class="btn large" onclick="addCritical();">Add "batterycritical" listener</div>
-    <div class="btn large" onclick="removeCritical();">Remove "batterycritical" listener</div>
-    <h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
+    <div class="btn large addBattery">Add "batterystatus" listener</div>
+    <div class="btn large removeBattery">Remove "batterystatus" listener</div>
+    <div class="btn large addLow">Add "batterylow" listener</div>
+    <div class="btn large removeLow">Remove "batterylow" listener</div>
+    <div class="btn large addCritical">Add "batterycritical" listener</div>
+    <div class="btn large removeCritical">Remove "batterycritical" listener</div>
+    <h2> </h2><div class="backBtn">Back</div>
   </body>
 </html>      

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0de5e956/battery/index.js
----------------------------------------------------------------------
diff --git a/battery/index.js b/battery/index.js
new file mode 100644
index 0000000..1a0d488
--- /dev/null
+++ b/battery/index.js
@@ -0,0 +1,72 @@
+var deviceReady = false;
+
+/**
+ * Function called when page has finished loading.
+ */
+function init() {
+    document.addEventListener("deviceready", function() {
+            deviceReady = true;
+            console.log("Device="+device.platform+" "+device.version);
+        }, false);
+    window.setTimeout(function() {
+        if (!deviceReady) {
+            alert("Error: Apache Cordova did not initialize.  Demo will not run correctly.");
+        }
+    },1000);
+}
+
+/* Battery */
+function updateInfo(info) {
+    document.getElementById('level').innerText = info.level;
+    document.getElementById('isPlugged').innerText = info.isPlugged;
+    if (info.level > 5) {
+        document.getElementById('crit').innerText = "false";
+    }
+    if (info.level > 20) {
+        document.getElementById('low').innerText = "false";
+    }
+}
+
+function batteryLow(info) {
+    document.getElementById('low').innerText = "true";
+}
+
+function batteryCritical(info) {
+    document.getElementById('crit').innerText = "true";
+}
+
+function addBattery() {
+    window.addEventListener("batterystatus", updateInfo, false);
+}
+
+function removeBattery() {
+    window.removeEventListener("batterystatus", updateInfo, false);
+}
+
+function addLow() {
+    window.addEventListener("batterylow", batteryLow, false);
+}
+
+function removeLow() {
+    window.removeEventListener("batterylow", batteryLow, false);
+}
+
+function addCritical() {
+    window.addEventListener("batterycritical", batteryCritical, false);
+}
+
+function removeCritical() {
+    window.removeEventListener("batterycritical", batteryCritical, false);
+}
+
+window.onload = function() {
+  addListenerToClass('addBattery', addBattery);
+  addListenerToClass('removeBattery', removeBattery);
+  addListenerToClass('addLow', addLow);
+  addListenerToClass('removeLow', removeLow);
+  addListenerToClass('addCritical', addCritical);
+  addListenerToClass('removeCritical', removeCritical);
+  
+  addListenerToClass('backBtn', backHome);
+  init();
+}


Mime
View raw message