Image/Notes storage and basic preview.
Change-Id: I466b5e2232811af3fad2266c28e8c4475b77eb71
This commit is contained in:
@@ -20,7 +20,12 @@
|
||||
var mClient;
|
||||
var mTransmitter;
|
||||
</script>
|
||||
|
||||
<script src="js/ui.js"></script>
|
||||
|
||||
<script src="js/client.js"></script>
|
||||
<script src="js/receiver.js"></script>
|
||||
<script src="js/slideshow.js"></script>
|
||||
<script src="js/transmitter.js"></script>
|
||||
</head>
|
||||
<body onLoad="init();">
|
||||
@@ -39,8 +44,8 @@
|
||||
<button id="blank" onclick="mTransmitter.blankScreen()">Blank Screen</button>
|
||||
<button id="resume" onclick="mTransmitter.resume()">Resume</button>
|
||||
<br/>
|
||||
<img id="preview"></img>
|
||||
|
||||
|
||||
<p>Current slide: <span id="current slide">---</span></p>
|
||||
<p>Current slide: <span id="current_slide">---</span></p>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -11,6 +11,7 @@ function Client( aServerAddress ) {
|
||||
var mReceiveBuffer = "";
|
||||
var mCurrentMessage = [];
|
||||
var mSocket;
|
||||
var mReceiver = new Receiver();
|
||||
|
||||
// PUBLIC
|
||||
this.sendMessage = function( aMessage ) {
|
||||
@@ -18,10 +19,6 @@ function Client( aServerAddress ) {
|
||||
}
|
||||
|
||||
// PRIVATE
|
||||
function processMessage( aMessage ) {
|
||||
console.log( "Received message " + aMessage );
|
||||
}
|
||||
|
||||
function dataReceived( aEvent ) {
|
||||
mReceiveBuffer += aEvent.data;
|
||||
var i;
|
||||
@@ -31,7 +28,7 @@ function Client( aServerAddress ) {
|
||||
if ( aLine.length > 0 ) {
|
||||
mCurrentMessage.push( aLine );
|
||||
} else {
|
||||
processMessage( mCurrentMessage );
|
||||
mReceiver.parseMessage( mCurrentMessage );
|
||||
mCurrentMessage = [];
|
||||
}
|
||||
aLine = "";
|
||||
|
46
firefoxos/sdremote/js/receiver.js
Normal file
46
firefoxos/sdremote/js/receiver.js
Normal file
@@ -0,0 +1,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;
|
||||
}
|
||||
|
||||
|
||||
}
|
33
firefoxos/sdremote/js/slideshow.js
Normal file
33
firefoxos/sdremote/js/slideshow.js
Normal file
@@ -0,0 +1,33 @@
|
||||
function Slideshow() {
|
||||
|
||||
var mSlides = 0;
|
||||
var mCurrentSlide;
|
||||
|
||||
var mNotes = [];
|
||||
var mPreviews = [];
|
||||
|
||||
this.setLength = function( aLength ) {
|
||||
mSlides = aLength;
|
||||
}
|
||||
|
||||
this.setCurrentSlide = function( aSlide ) {
|
||||
mCurrentSlide = aSlide;
|
||||
}
|
||||
|
||||
this.getCurrentSlide = function() {
|
||||
return mCurrentSlide;
|
||||
}
|
||||
|
||||
this.putPreview = function( aSlide, aImage ) {
|
||||
mPreviews[ aSlide ] = aImage;
|
||||
}
|
||||
|
||||
this.putNotes = function( aSlide, aNotes ) {
|
||||
mNotes[ aSlide ] = aNotes;
|
||||
}
|
||||
|
||||
this.getPreview = function( aSlide ) {
|
||||
return mPreviews[ aSlide ];
|
||||
}
|
||||
|
||||
}
|
9
firefoxos/sdremote/js/ui.js
Normal file
9
firefoxos/sdremote/js/ui.js
Normal file
@@ -0,0 +1,9 @@
|
||||
function updatePreview( aSlideshow ) {
|
||||
var aOutputImage = document.getElementById('preview');
|
||||
var aPreview = aSlideshow.getPreview( aSlideshow.getCurrentSlide() );
|
||||
|
||||
aOutputImage.src = "data:image/png;base64," + aPreview;
|
||||
console.log( "Set image : " + aPreview );
|
||||
|
||||
document.getElementById('current_slide').innerHTML = aSlideshow.getCurrentSlide();
|
||||
}
|
Reference in New Issue
Block a user