[Libreoffice-commits] core.git: firefoxos/sdremote
Andrzej J.R. Hunt
andrzej at ahunt.org
Fri Apr 12 02:51:06 PDT 2013
firefoxos/sdremote/index.html | 9 +++++--
firefoxos/sdremote/js/client.js | 7 +----
firefoxos/sdremote/js/receiver.js | 46 +++++++++++++++++++++++++++++++++++++
firefoxos/sdremote/js/slideshow.js | 33 ++++++++++++++++++++++++++
firefoxos/sdremote/js/ui.js | 9 +++++++
5 files changed, 97 insertions(+), 7 deletions(-)
New commits:
commit 520f4d45e9cd592381af66a8ed357de3e346734b
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Fri Apr 12 10:49:44 2013 +0100
Image/Notes storage and basic preview.
Change-Id: I466b5e2232811af3fad2266c28e8c4475b77eb71
diff --git a/firefoxos/sdremote/index.html b/firefoxos/sdremote/index.html
index eaf82f9..4752239 100644
--- a/firefoxos/sdremote/index.html
+++ b/firefoxos/sdremote/index.html
@@ -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>
diff --git a/firefoxos/sdremote/js/client.js b/firefoxos/sdremote/js/client.js
index f9ad71b..7702506 100644
--- a/firefoxos/sdremote/js/client.js
+++ b/firefoxos/sdremote/js/client.js
@@ -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 = "";
diff --git a/firefoxos/sdremote/js/receiver.js b/firefoxos/sdremote/js/receiver.js
new file mode 100644
index 0000000..8cecaa4
--- /dev/null
+++ b/firefoxos/sdremote/js/receiver.js
@@ -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;
+ }
+
+
+}
\ No newline at end of file
diff --git a/firefoxos/sdremote/js/slideshow.js b/firefoxos/sdremote/js/slideshow.js
new file mode 100644
index 0000000..0940ab5
--- /dev/null
+++ b/firefoxos/sdremote/js/slideshow.js
@@ -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 ];
+ }
+
+}
\ No newline at end of file
diff --git a/firefoxos/sdremote/js/ui.js b/firefoxos/sdremote/js/ui.js
new file mode 100644
index 0000000..a8c7d6b
--- /dev/null
+++ b/firefoxos/sdremote/js/ui.js
@@ -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();
+}
\ No newline at end of file
More information about the Libreoffice-commits
mailing list