[Laszlo-checkins] r3675 - in openlaszlo/branches/legals: WEB-INF/lps/lfc/services WEB-INF/lps/lfc/views/platform/dhtml WEB-INF/lps/lfc/views/platform/swf examples/musicdhtml test/lfc/legals/testjscomm
max@openlaszlo.org
max at openlaszlo.org
Tue Feb 6 13:12:04 PST 2007
Author: max
Date: 2007-02-06 13:11:57 -0800 (Tue, 06 Feb 2007)
New Revision: 3675
Modified:
openlaszlo/branches/legals/WEB-INF/lps/lfc/services/LzBrowser.as
openlaszlo/branches/legals/WEB-INF/lps/lfc/services/LzHistory.as
openlaszlo/branches/legals/WEB-INF/lps/lfc/views/platform/dhtml/LzDrawView.lzs
openlaszlo/branches/legals/WEB-INF/lps/lfc/views/platform/swf/LzDrawView.lzs
openlaszlo/branches/legals/examples/musicdhtml/index.jsp
openlaszlo/branches/legals/examples/musicdhtml/main.lzx
openlaszlo/branches/legals/test/lfc/legals/testjscomm/copy-of-hello.lzx
openlaszlo/branches/legals/test/lfc/legals/testjscomm/test6.html
openlaszlo/branches/legals/test/lfc/legals/testjscomm/test8.html
Log:
Change 20070206-maxcarlson-v by maxcarlson at max-carlsons-computer.local on 2007-02-06 11:32:57 PST
in /Users/maxcarlson/openlaszlo/legals
Summary: UPDATED: Add queueing to LzBrowser.callJS() for swf, add updated arc() method to drawview for SWF and HTML
New Features:
Bugs Fixed: LPP-3192 - LzBrowser.callJS does not queue calls in swf6/7 mode, LPP-3491 - LzDrawView's arc method does not function as expected.
Technical Reviewer: jcrowley
QA Reviewer: promanik
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details: test6.html - added button and method callbak for queueing test
copy-of-hello.lzx - improved testcase
test8.html - added button and method callbak for queueing test
LzBrowser.as - Added queuing for callJS()
LzHistory.as - Clear out calljs queue when callMethod() is used
LzDrawView.lzs - Add Ming's updated arc() routine for DHTML and SWF
main.lzx - don't set attributes with a null value
index.jsp - remove extra embednew.js include, return true from setAttr to ensure queueing works properly.
Tests: Testcase from LPP-3491 shows imrpoved behavior of draview.arc(). examples/musicdhtml/ runs in Firefox or Safari properly. Playing the music causes the play track head to move. /testjscomm/test6.html and /testjscomm/test8.html show consistent behavior, including queuing of callJS() calls.
Files:
M test/lfc/legals/testjscomm/test6.html
M test/lfc/legals/testjscomm/copy-of-hello.lzx
M test/lfc/legals/testjscomm/test8.html
M WEB-INF/lps/lfc/services/LzBrowser.as
M WEB-INF/lps/lfc/services/LzHistory.as
M WEB-INF/lps/lfc/views/platform/swf/LzDrawView.lzs
M WEB-INF/lps/lfc/views/platform/dhtml/LzDrawView.lzs
M examples/musicdhtml/main.lzx
M examples/musicdhtml/index.jsp
Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20070206-maxcarlson-v.tar
Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/services/LzBrowser.as
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/services/LzBrowser.as 2007-02-06 21:06:20 UTC (rev 3674)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/services/LzBrowser.as 2007-02-06 21:11:57 UTC (rev 3675)
@@ -70,10 +70,48 @@
* @param Optional arguments to call
*/
LzBrowser.callJS = function (js, callback) {
+ if (this.__jslocked == true) {
+ this.__jscallq.push(arguments);
+ //Debug.write('queued', this.__jscallq.length, arguments);
+ return;
+ }
+
+ this.__jscallback = callback;
+ callback = LzBrowser.callJSReturn;
var args = [].slice.call(arguments, 2);
args.unshift(js, callback);
+
+ this.__jslocked = true;
+ //Debug.write('calling with args real', arguments);
DojoExternalInterface.call.apply(this, args);
}
+LzBrowser.__jscallback = null;
+LzBrowser.__jslocked = false;
+LzBrowser.__jscallq = [];
+
+LzBrowser.callJSReturn = function (a) {
+ //Debug.write('callJSReturn', a);
+ if (LzBrowser.__jscallback) {
+ LzBrowser.__jscallback(a);
+ }
+ LzBrowser._dequeueJS();
+}
+
+LzBrowser._dequeueJS = function (a) {
+ this.__jslocked = false;
+ this.__jscallback = null;
+ if (this.__jscallq.length > 0) {
+ var a = this.__jscallq.pop();
+ //Debug.write('calling with args q', a);
+ LzBrowser.callJS.apply(this, a);
+ }
+}
+
+LzBrowser._jsreset = function () {
+ this.__jslocked = false;
+ this.__jscallback = null;
+ this.__jscallq = [];
+}
/**
* Returns the current version of the Flash player.
Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/services/LzHistory.as
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/services/LzHistory.as 2007-02-06 21:06:20 UTC (rev 3674)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/services/LzHistory.as 2007-02-06 21:11:57 UTC (rev 3675)
@@ -123,6 +123,7 @@
* @access private
*/
LzHistory.callMethod = function(js) {
+ if (LzBrowser.__jslocked) LzBrowser._jsreset();
var scope = canvas;
//Debug.write('callMethod', js);
var s = js.indexOf('(')
Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/views/platform/dhtml/LzDrawView.lzs
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/views/platform/dhtml/LzDrawView.lzs 2007-02-06 21:06:20 UTC (rev 3674)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/views/platform/dhtml/LzDrawView.lzs 2007-02-06 21:11:57 UTC (rev 3675)
@@ -212,12 +212,14 @@
* @param Number clockwise: anticlockwise if true, clockwise otherwise
*/
function arc(x, y, radius, startAngle, endAngle, clockwise) {
- x += radius*Math.cos(startAngle);
- y += radius*Math.sin(startAngle);
+ var sx = x + radius*Math.cos(startAngle);
+ var sy = y + radius*Math.sin(2 * Math.PI - startAngle);
startAngle *= 180/Math.PI;
endAngle *= 180/Math.PI;
- var arc = clockwise == true ? startAngle - endAngle : endAngle - startAngle;
- this.moveTo(x, y);
+ var arc = clockwise == true ? ((endAngle - startAngle) - 360): endAngle - startAngle;
+ //move pen to the point along the circle at startAngle
+ this.moveTo(sx, sy);
+ //retain the center of the arc as the center point passed in.
return this._drawArc(x, y, radius, arc, startAngle);
}
@@ -383,7 +385,7 @@
yRadius = radius;
}
// Init vars
- var segAngle, theta, angle, angleMid, segs, ax, ay, bx, by, cx, cy;
+ var segAngle, theta, angle, angleMid, segs,bx, by, cx, cy;
// no sense in drawing more than is needed :)
if (Math.abs(arc)>360) {
arc = 360;
@@ -399,9 +401,7 @@
theta = -(segAngle/180)*Math.PI;
// convert angle startAngle to radians
angle = -(startAngle/180)*Math.PI;
- // find our starting points (ax,ay) relative to the secified x,y
- ax = x-Math.cos(angle)*radius;
- ay = y-Math.sin(angle)*yRadius;
+
// if our arc is larger than 45 degrees, draw as 45 degree segments
// so that we match Flash's native circle routines.
if (segs>0) {
@@ -412,11 +412,11 @@
// find the angle halfway between the last angle and the new
angleMid = angle-(theta/2);
// calculate our end point
- bx = ax+Math.cos(angle)*radius;
- by = ay+Math.sin(angle)*yRadius;
+ bx = x+Math.cos(angle)*radius;
+ by = y+Math.sin(angle)*yRadius;
// calculate our control point
- cx = ax+Math.cos(angleMid)*(radius/Math.cos(theta/2));
- cy = ay+Math.sin(angleMid)*(yRadius/Math.cos(theta/2));
+ cx = x+Math.cos(angleMid)*(radius/Math.cos(theta/2));
+ cy = y+Math.sin(angleMid)*(yRadius/Math.cos(theta/2));
// draw the arc segment
this.quadraticCurveTo(cx, cy, bx, by);
}
Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/views/platform/swf/LzDrawView.lzs
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/views/platform/swf/LzDrawView.lzs 2007-02-06 21:06:20 UTC (rev 3674)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/views/platform/swf/LzDrawView.lzs 2007-02-06 21:11:57 UTC (rev 3675)
@@ -344,12 +344,14 @@
* @param Number clockwise: anticlockwise if true, clockwise otherwise
*/
function arc(x, y, radius, startAngle, endAngle, clockwise) {
- x += radius*Math.cos(startAngle);
- y += radius*Math.sin(startAngle);
+ var sx = x + radius*Math.cos(startAngle);
+ var sy = y + radius*Math.sin(2 * Math.PI - startAngle);
startAngle *= 180/Math.PI;
endAngle *= 180/Math.PI;
- var arc = clockwise == true ? startAngle - endAngle : endAngle - startAngle;
- this.moveTo(x, y);
+ var arc = clockwise == true ? ((endAngle - startAngle) - 360): endAngle - startAngle;
+ //move pen to the point along the circle at startAngle
+ this.moveTo(sx, sy);
+ //retain the center of the arc as the center point passed in.
return this._drawArc(x, y, radius, arc, startAngle);
}
@@ -515,7 +517,7 @@
yRadius = radius;
}
// Init vars
- var segAngle, theta, angle, angleMid, segs, ax, ay, bx, by, cx, cy;
+ var segAngle, theta, angle, angleMid, segs,bx, by, cx, cy;
// no sense in drawing more than is needed :)
if (Math.abs(arc)>360) {
arc = 360;
@@ -531,9 +533,7 @@
theta = -(segAngle/180)*Math.PI;
// convert angle startAngle to radians
angle = -(startAngle/180)*Math.PI;
- // find our starting points (ax,ay) relative to the secified x,y
- ax = x-Math.cos(angle)*radius;
- ay = y-Math.sin(angle)*yRadius;
+
// if our arc is larger than 45 degrees, draw as 45 degree segments
// so that we match Flash's native circle routines.
if (segs>0) {
@@ -544,11 +544,11 @@
// find the angle halfway between the last angle and the new
angleMid = angle-(theta/2);
// calculate our end point
- bx = ax+Math.cos(angle)*radius;
- by = ay+Math.sin(angle)*yRadius;
+ bx = x+Math.cos(angle)*radius;
+ by = y+Math.sin(angle)*yRadius;
// calculate our control point
- cx = ax+Math.cos(angleMid)*(radius/Math.cos(theta/2));
- cy = ay+Math.sin(angleMid)*(yRadius/Math.cos(theta/2));
+ cx = x+Math.cos(angleMid)*(radius/Math.cos(theta/2));
+ cy = y+Math.sin(angleMid)*(yRadius/Math.cos(theta/2));
// draw the arc segment
this.quadraticCurveTo(cx, cy, bx, by);
}
Modified: openlaszlo/branches/legals/examples/musicdhtml/index.jsp
===================================================================
--- openlaszlo/branches/legals/examples/musicdhtml/index.jsp 2007-02-06 21:06:20 UTC (rev 3674)
+++ openlaszlo/branches/legals/examples/musicdhtml/index.jsp 2007-02-06 21:11:57 UTC (rev 3675)
@@ -31,7 +31,7 @@
}
</script><script type="text/javascript">
lzOptions = { ServerRoot: '<%= request.getContextPath() %>', appendDivID: 'lzdhtmlappdiv'};
- </script><script type="text/javascript" src="<%= request.getContextPath() %>/lps/includes/embed-compressed.js"></script><script type="text/javascript" src="<%= request.getContextPath() %>/lps/includes/embed-compressed.js"></script><script type="text/javascript">
+ </script><script type="text/javascript" src="<%= request.getContextPath() %>/lps/includes/embed-compressed.js"></script><script type="text/javascript">
Lz.dhtmlEmbedLFC('<%= request.getContextPath() %>/lps/includes/lfc/LFCdhtml.js');
</script><style type="text/css">
html, body
@@ -50,6 +50,7 @@
Lz.dhtmlEmbed({url: 'main.lzx?lzt=object&lzr=dhtml&_canvas_debug=false', bgcolor: '#ffffff', width: '100%', height: '150', id: 'lzdhtmlapp'});
function setCanAttr(n, v) {
canvas.setAttr(n, v);
+ return true;
}
</script><noscript>
Please enable JavaScript in order to use this application.
Modified: openlaszlo/branches/legals/examples/musicdhtml/main.lzx
===================================================================
--- openlaszlo/branches/legals/examples/musicdhtml/main.lzx 2007-02-06 21:06:20 UTC (rev 3674)
+++ openlaszlo/branches/legals/examples/musicdhtml/main.lzx 2007-02-06 21:11:57 UTC (rev 3675)
@@ -1,6 +1,6 @@
<canvas bgcolor="#EAEAEA" width="640" height="140" >
<method name="setAttr" args="n, v">
- audioplayer.setAttribute(n, v * 1);
+ if (n != null) audioplayer.setAttribute(n, v * 1);
</method>
<!--method event="oninit">
Modified: openlaszlo/branches/legals/test/lfc/legals/testjscomm/copy-of-hello.lzx
===================================================================
--- openlaszlo/branches/legals/test/lfc/legals/testjscomm/copy-of-hello.lzx 2007-02-06 21:06:20 UTC (rev 3674)
+++ openlaszlo/branches/legals/test/lfc/legals/testjscomm/copy-of-hello.lzx 2007-02-06 21:11:57 UTC (rev 3675)
@@ -8,8 +8,24 @@
<canvas height="700">
<attribute name="mytext" value="Hello!" type="text"/>
- <button onclick="LzBrowser.callJS('getUserAgent', function (ua) { canvas.setAttribute('mytext', ua) })">Get browser useragent</button>
+ <attribute name="foo" value="" type="text"/>
+ <attribute name="farb" value="" type="text"/>
+ <button onclick="">Get browser useragent
+ <handler name="onclick">
+ LzBrowser.callJS('getUserAgent', function (ua) { canvas.setAttribute('mytext', ua) })
+ </handler>
+ </button>
+ <button x="200">Test callJS queuing
+ <handler name="onclick">
+ LzBrowser.callJS('getFoo', function (a) { if (a != 'foo') LzBrowser.loadJS('alert(\'warning: did not get foo: ' + a + '\')') });
+ LzBrowser.callJS('getBar', function (a) { if (a != 'bar') LzBrowser.loadJS('alert(\'warning: did not get bar: ' + a + '\')') });
+ </handler>
+ </button>
<text y="40" text="${parent.mytext}" width="1000"/>
+ <text y="60" text="${parent.foo}" width="100"/>
+ <text y="60" x="110" text="${parent.farb}" width="100"/>
+ <text y="100" name="stat" multiline="true" width="1000"/>
+
<view name="aview" y="80" bgcolor="red" width="20" height="30">
<method name="testMethod" args="str, bool1, bool2, num1, num2, prop1, prop2">
<![CDATA[
@@ -21,7 +37,7 @@
</view>
</canvas>
<!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
-* Copyright 2001-2006 Laszlo Systems, Inc. All Rights Reserved. *
+* Copyright 2001-2007 Laszlo Systems, Inc. All Rights Reserved. *
* Use is subject to license terms. *
* X_LZ_COPYRIGHT_END ****************************************************** -->
<!-- @LZX_VERSION@ -->
Modified: openlaszlo/branches/legals/test/lfc/legals/testjscomm/test6.html
===================================================================
--- openlaszlo/branches/legals/test/lfc/legals/testjscomm/test6.html 2007-02-06 21:06:20 UTC (rev 3674)
+++ openlaszlo/branches/legals/test/lfc/legals/testjscomm/test6.html 2007-02-06 21:11:57 UTC (rev 3675)
@@ -7,7 +7,7 @@
<link rel="SHORTCUT ICON" href="http://www.laszlosystems.com/favicon.ico">
<title>OpenLaszlo Application</title><script type="text/javascript">
//* A_LZ_COPYRIGHT_BEGIN ******************************************************
-//* Copyright 2001-2006 Laszlo Systems, Inc. All Rights Reserved. *
+//* Copyright 2001-2007 Laszlo Systems, Inc. All Rights Reserved. *
//* Use is subject to license terms. *
//* A_LZ_COPYRIGHT_END ********************************************************
// If loaded bare into a browser, set the browser size to the canvas size
@@ -61,6 +61,12 @@
function getUserAgent() {
return navigator.userAgent;
}
+ function getFoo() {
+ return 'foo';
+ }
+ function getBar() {
+ return 'bar';
+ }
</script><noscript>
Please enable JavaScript in order to use this application.
@@ -70,6 +76,7 @@
<input type="button" onclick="this.form.txt.value = Lz.getCanvasAttribute('mytext');" value="Get Text from flash"/>
<input type="button" onclick="alert(Lz.getCanvasAttribute('width'))" value="Get Canvas Width"/>
<input type="button" onclick="alert(Lz.getCanvasAttribute('height'))" value="Get Canvas Height"/>
+ <input type="button" onclick="Lz.setCanvasAttribute('foo', 'bar'); Lz.setCanvasAttribute('farb', 'baz')" value="set canvas attributes"/>
<input type="button" onclick="Lz.callMethod('aview.testMethod(\'foo\', true, false, 1, 0, width, height)')" value="Test method arg casting"/>
</form>
</body>
Modified: openlaszlo/branches/legals/test/lfc/legals/testjscomm/test8.html
===================================================================
--- openlaszlo/branches/legals/test/lfc/legals/testjscomm/test8.html 2007-02-06 21:06:20 UTC (rev 3674)
+++ openlaszlo/branches/legals/test/lfc/legals/testjscomm/test8.html 2007-02-06 21:11:57 UTC (rev 3675)
@@ -7,7 +7,7 @@
<link rel="SHORTCUT ICON" href="http://www.laszlosystems.com/favicon.ico">
<title>OpenLaszlo Application</title><script type="text/javascript">
//* A_LZ_COPYRIGHT_BEGIN ******************************************************
-//* Copyright 2001-2006 Laszlo Systems, Inc. All Rights Reserved. *
+//* Copyright 2001-2007 Laszlo Systems, Inc. All Rights Reserved. *
//* Use is subject to license terms. *
//* A_LZ_COPYRIGHT_END ********************************************************
// If loaded bare into a browser, set the browser size to the canvas size
@@ -62,6 +62,12 @@
function getUserAgent() {
return navigator.userAgent;
}
+ function getFoo() {
+ return 'foo';
+ }
+ function getBar() {
+ return 'bar';
+ }
</script><noscript>
Please enable JavaScript in order to use this application.
@@ -71,6 +77,7 @@
<input type="button" onclick="this.form.txt.value = Lz.getCanvasAttribute('mytext');" value="Get Text from flash"/>
<input type="button" onclick="alert(Lz.getCanvasAttribute('width'))" value="Get Canvas Width"/>
<input type="button" onclick="alert(Lz.getCanvasAttribute('height'))" value="Get Canvas Height"/>
+ <input type="button" onclick="Lz.setCanvasAttribute('foo', 'bar'); Lz.setCanvasAttribute('farb', 'baz')" value="set canvas attributes"/>
<input type="button" onclick="Lz.callMethod('aview.testMethod(\'foo\', true, false, 1, 0, width, height)')" value="Test method arg casting"/>
</form>
</body>
More information about the Laszlo-checkins
mailing list