From 05617165c0268266671477f21e2c754fbfcce14f Mon Sep 17 00:00:00 2001
From: Ryan Seys <rsmseys@gmail.com>
Date: Fri, 1 Jun 2012 18:24:46 +0000
Subject: [PATCH] fix for undos and off-by-one in pan and zooms

---
 bigbluebutton-apps/.classpath.old               |  1 -
 .../playback/slides/lib/popcorn-complete.min.js |  0
 .../slides/playback/slides/lib/writing.js       | 16 ++++++++++++----
 .../slides/scripts/publish/slides.rb            | 17 +++++++++--------
 4 files changed, 21 insertions(+), 13 deletions(-)
 mode change 100644 => 100755 record-and-playback/slides/playback/slides/lib/popcorn-complete.min.js
 mode change 100644 => 100755 record-and-playback/slides/playback/slides/lib/writing.js

diff --git a/bigbluebutton-apps/.classpath.old b/bigbluebutton-apps/.classpath.old
index 065fe37b81..1e6d54b17c 100644
--- a/bigbluebutton-apps/.classpath.old
+++ b/bigbluebutton-apps/.classpath.old
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="src/main/java"/>
-	<classpathentry kind="src" path="test/commandline"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/record-and-playback/slides/playback/slides/lib/popcorn-complete.min.js b/record-and-playback/slides/playback/slides/lib/popcorn-complete.min.js
old mode 100644
new mode 100755
diff --git a/record-and-playback/slides/playback/slides/lib/writing.js b/record-and-playback/slides/playback/slides/lib/writing.js
old mode 100644
new mode 100755
index 6a58f2f373..0488854e5d
--- a/record-and-playback/slides/playback/slides/lib/writing.js
+++ b/record-and-playback/slides/playback/slides/lib/writing.js
@@ -91,9 +91,14 @@ var panZoomArray = panelements[0].getElementsByTagName("event");
 viewBoxes = xmlDoc.getElementsByTagName("viewBox");
 
 var pzlen = panZoomArray.length;
+var second_val;
 //fill the times array with the times of the svg images.
-for (var k = 0;k < pzlen-1; k++) {
-	vboxValues[[panZoomArray[k].getAttribute("timestamp"), panZoomArray[k+1].getAttribute("timestamp")]] = viewBoxes[k].childNodes[0].data;
+for (var k = 0;k < pzlen; k++) {
+	if(panZoomArray[k+1] == undefined) {
+		second_val = "end";
+	}
+	else second_val = panZoomArray[k+1].getAttribute("timestamp");
+	vboxValues[[panZoomArray[k].getAttribute("timestamp"), second_val]] = viewBoxes[k].childNodes[0].data;
 }
 
 // - - - END OF GLOBAL VARIABLES - - - //
@@ -180,7 +185,10 @@ function getViewboxAtTime(time) {
 	for (key in vboxValues) {
 		if(vboxValues.hasOwnProperty(key)) {
 			var arry = key.split(",");
-			if ((parseFloat(arry[0]) <= curr_t) && (parseFloat(arry[1]) >= curr_t)) {
+			if(arry[1] == "end") {
+				return vboxValues[key];
+			}
+			else if ((parseFloat(arry[0]) <= curr_t) && (parseFloat(arry[1]) >= curr_t)) {
 				return vboxValues[key];
 			}
 		}
@@ -334,7 +342,7 @@ p.code({
 			}
 			var elapsed = new Date().getTime() - start;
 			if(parseInt(elapsed, 10) !== 0) {
-				console.log("frame time: " + elapsed);
+				//console.log("frame time: " + elapsed);
 			}
 		}
     }
diff --git a/record-and-playback/slides/scripts/publish/slides.rb b/record-and-playback/slides/scripts/publish/slides.rb
index d6cf8c4710..5cedbbae28 100755
--- a/record-and-playback/slides/scripts/publish/slides.rb
+++ b/record-and-playback/slides/scripts/publish/slides.rb
@@ -176,23 +176,24 @@ if (playback == "slides")
 						# It must be the closest shape drawn that hasn't already been undone.
 						if (closest_shape == nil) || (shape[:timestamp].to_f > closest_shape[:timestamp].to_f)
 							# It cannot be an undo for another shape already.
-							if !(undos.has_key? shape[:timestamp])
+							if !(undos.has_key? shape)
 								# Must be part of this presentation of course
 								if shape.xpath(".//pageNumber")[0].text() == undo.xpath(".//pageNumber")[0].text()
 									# Must be a shape in this page too.
 									if shape.xpath(".//presentation")[0].text() == undo.xpath(".//presentation")[0].text()
 										if ((shape.xpath(".//type")[0].text() == "rectangle") || (shape.xpath(".//type")[0].text() == "ellipse"))
 											shape_already_processed = false
-											undos.each do |u, v|
-												if shape.xpath(".//dataPoints")[0].text().split(",")[0] == u.xpath(".//dataPoints")[0].text().split(",")[0]
-													if shape.xpath(".//dataPoints")[0].text().split(",")[1] == u.xpath(".//dataPoints")[0].text().split(",")[1]
-														shape_already_processed = true
+											if(undos.length == 0)
+												shape_already_processed = false
+											else
+												undos.each do |u, v|
+													if shape.xpath(".//dataPoints")[0].text().split(",")[0] == u.xpath(".//dataPoints")[0].text().split(",")[0]
+														if shape.xpath(".//dataPoints")[0].text().split(",")[1] == u.xpath(".//dataPoints")[0].text().split(",")[1]
+															shape_already_processed = true
+														end
 													end
 												end
 											end
-											if(undos.length == 0)
-												shape_already_processed
-											end
 											if !(shape_already_processed)
 												closest_shape = shape
 											end
-- 
GitLab