summaryrefslogtreecommitdiff
path: root/firefoxos/sdremote/js/receiver.js
blob: 8cecaa473683edf60fd9a8329ef4bcbbb36b660d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function Receiver() {

    var mSlideshow;

    this.parseMessage = function( aMessage ) {
        console.log( "Received message " + aMessage[0] );
        switch ( aMessage[0] ) {
            case "slideshow_started":
                mSlideshow = new Slideshow();
                var aSlideShowlength = aMessage[1];
                var aCurrentSlide = aMessage[2];
                mSlideshow.setLength( aSlideShowlength );
                mSlideshow.setCurrentSlide( aCurrentSlide );
                // TODO: notify listeners
                break;
            case "slideshow_finished":
                // TODO: notify listeners
                mSlideshow = '';
                break;
            default:
                if ( !mSlideshow ) {
                    break;
                }
                var mSlide = aMessage[1];
                // TODO: notify listeners
                switch ( aMessage[0] ) {
                    case "slide_updated":
                        mSlideshow.setCurrentSlide( mSlide );
                        updatePreview( mSlideshow );
                    case "slide_notes":
                        mSlideshow.putNotes( mSlide, aMessage[2] );
                        break;
                    case "slide_preview":
                        mSlideshow.putPreview( mSlide, aMessage[2] );
                        break;
                }
                break;
        }
    }

    this.getSlideshow = function() {
        return mSlideshow;
    }


}