Difference between revisions of "Patch Camera 10 Second Countdown Timer"

From WebOS Internals
Jump to navigation Jump to search
(No difference)

Revision as of 07:23, 1 August 2009

I made a mod of this mod so that instead of a 2.5sec delay, you get a 10 second countdown timer complete with animated countdown! (-- retry)

First the View needs to start at 10 (or any other value you want really)

		<div class="capture-button capture-timer-button" id="captureTimerButton">10</div>

Then edit javascripts/camera-control.js . This is the biggest mod of the OP's work. Notice I am still using the same captureTimer method name but its contents are different, and it calls a new method, captureTimerLoop, and there are two class properties used. If you are using something other than 10 seconds, make sure you change both of the 10's here, so that all three 10's are identical. If I knew a way to call a public class property in the view, this could be a single config var, ah well.


    _captureTimerLoopCount:10,
    _captureTimerIntId:false,
    captureTimerLoop: function(){
        --this._captureTimerLoopCount;
       this.scene.controller.get('captureTimerButton').innerHTML = this._captureTimerLoopCount
        if ( this._captureTimerLoopCount == 0 ) {
            this.scene.controller.window.clearInterval(this._captureTimerIntId);
            this.capture();
            this._captureTimerIntId = false;
            this._captureTimerLoopCount = 10;
            this.scene.controller.get('captureTimerButton').innerHTML = this._captureTimerLoopCount;
        }
    },

     /** hack
     * Perform capture with timer delay
     *
     * @return   Returns true if the capture started successfully.
     */
    captureTimer: function(){
        if ( !this._captureTimerIntId ) {
            this._captureTimerIntId = this.scene.controller.window.setInterval( function(){
                this.captureTimerLoop();
            }.bind(this), 1000 );
        }
    },

For stylesheets/camera.css , I merely added a font color of white so the seconds countdown contrasts nicely. I tried to place the count in the center, but it messed up the neighboring images, and I rather like the way it looks off on the far upper left.

.capture-timer-button {
		background: url(../images/menu-capture-timer.png) top left no-repeat;
		left: 155px;
                color: white;
}

And that's it. Now restart the GUI with :

root@castle:/# initctl stop LunaSysMgr && initctl start LunaSysMgr

Wait for the GUI to come back and snap some delayed shots!

When you're happy with the hack, don't forget to remount the root fs read-only:

mount -o remout,ro /

My thanks to the OP for this hack which helped me to get some understanding of how Luna apps function.