blackberry / BB10-WebWorks-Framework

The BB10 WebWorks Framework is packaged within an application BAR file to run on a BB10 device (or simulator)
60 stars 34 forks source link

webworks-1.0.4.7.js doesn't seem to work for PlayBook anymore #607

Closed asiayeah closed 11 years ago

asiayeah commented 11 years ago

I include webworks.js so the same source code can work on both bb10 and PlayBook.

Since I migrated to webworks-1.0.4.7.js from 1.0.4.5.js, I found my PlayBook app isn't initializing.

I have compared webworks-1.0.4.7.js and I found patching the following will fix the issue.

-    // Let's create the webworks namespace
-    createWebworksReady();
+    //build window.webworks once all loading has completed
+    function onReadyStateChanged() {
+        if (document.readyState === 'complete') {
+            createWebworksReady();
+            document.removeEventListener('readystatechange', onReadyStateChanged, false);
+        }
+    }
+    document.addEventListener('readystatechange', onReadyStateChanged, false);
+    onReadyStateChanged();

May I know why it was done that way in 1.0.4.7? Shouldn't webworks-1.0.4.7.js work for PlayBook app as well so that they could use 'webworksready' event?

Thanks.

ejzn commented 11 years ago

This change was made to allow injection. We weren't getting a consistent ready state on BB10. This was a more accepted way. We did not check backwards compatibility with Playbook.

kwallis commented 11 years ago

At a bit higher level, it is now supported to use the BlackBerry10 WebWorks SDK to create a PlayBook WebWorks application. The fact it worked previously is pretty cool, but entirely unintended and coincidental.

Ken Wallis

Product Manager – WebWorks

BlackBerry

289-261-4369


From: Erik Johnson [notifications@github.com] Sent: Thursday, January 31, 2013 11:24 AM To: blackberry/BB10-WebWorks-Framework Subject: Re: [BB10-WebWorks-Framework] webworks-1.0.4.7.js doesn't seem to work for PlayBook anymore (#607)

This change was made to allow injection. We weren't getting a consistent ready state on BB10. This was a more accepted way. We did not check backwards compatibility with Playbook.

— Reply to this email directly or view it on GitHubhttps://github.com/blackberry/BB10-WebWorks-Framework/issues/607#issuecomment-12950604.


This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.

ejzn commented 11 years ago

I think you meant not instead of "now" Ken? ;)

kwallis commented 11 years ago

Yup! ;)

asiayeah commented 11 years ago

No problem. I would use a workaround.

As a clarification, I am using BlackBerry 10 WebWorks SDK and WebWorks SDK for PlayBook OS correspondingly. However, I were trying to use the same code base for both platforms.

Thanks.

jeffheifetz commented 11 years ago

@kwallis I believe you are misunderstanding the use case. He was not using the BB10 SDK for a playbook app, but attempting to have a single source app for playbook and BB10.

@asiayeah we no longer recommend linking the file directly, and now instead adding a script tag for local:///chrome/webworks.js. Unfortunately this path will not exist on PB or BB10, one possible solution is to dynamically load the script file if the blacberry variable does not exist. Something like the following

<script>
    //blackberry will already be defined for BlackBerry OS and BlackBerry Tablet OS
    if (!blackberry) {
        var head= document.getElementsByTagName('head')[0],
            script= document.createElement('script');
        script.src= 'local:///chrome/webworks.js';
        head.appendChild(script);
    }
</script>
asiayeah commented 11 years ago

@jeffheifetz Thanks for clarifying for me.

My bug report is if I include webworks-1.0.4.7.js in a PlayBook application and using WebWorks SDK for PlayBook. I am no longer receiving the ''webworksready' event.

My solution: I am going to follow the bbUI.js samples strictly, https://github.com/blackberry/bbUI.js/blob/master/samples/index.htm

That seems to work fine for both BB10 and PlayBook using their corresponding WebWorks SDK.

Thank you, everyone.