Loading ...
Sorry, an error occurred while loading the content.

YUI3 and webworkers

Expand Messages
  • Mark Jarecki
    Hi all, I m looking into implementing an app with web workers and YUI3, however, am wondering how to give the worker access to the YUI3 library. My current
    Message 1 of 5 , Dec 15, 2009
    • 0 Attachment

      Hi all,

      I'm looking into implementing an app with web workers and YUI3, however, am wondering how to give the worker access to the YUI3 library. 

      My current method works, but is obviously missing a means of importing YUI3. I've tried importScripts() to no avail.

      If anyone has a quick example or suggestions on how to do this, that would be greatly appreciated.

      Thanks,

      Mark

      HTML
      <!DOCTYPE html>
      <html lang="en">
      <head>
      <meta http-equiv=" content-type" content="text/ html;charset= utf-8" />
        <script type="text/javascri pt" src="path/to/ yui/build/ yui/yui-min. js"></script>
      </head>
      <body>
      <script type="text/javascri pt">
      YUI({

      base: 'path/to/yui/ build/',
      combine: false,
      modules: {
      worker: {fullpath:'path/ to/worker. js'},
      view: {fullpath:'path/ to/js/view. js', requires: ['dd-constrain' ]},
      manager: {fullpath:'path/ to/manager. js', requires: ['base', 'view', 'worker']}
      },
      timeout: 10000

      }).use('manager' , function(Y) {

      Y.on("domready" , function(){ 

      var ManagerPages = Y.Base.build( "managerPages" , Y.Manager, [Y.ManagerPages] );
      var mp = new ManagerPages( );
      }, Y);

      });
      </script>
      </body>
      </html>

      manager.js
      YUI.add("manager" , function(Y) {

          var Manager,
          MANAGER = 'manager',
          $D = Y.DOM,
          $L = Y.Lang,
          $J = Y.JSON,
          isBoolean = $L.isBoolean;

         Manager = function(config) { Manager.superclass. constructor. apply(this, arguments); };

      Y.mix(Manager, {
      NAME: MANAGER,
      ATTRS: {

      someATTR: {
      value: false,
      validator: isBoolean
      }
      }        
      });

      Y.extend(Manager, Y.Base, {
      _worker: null,
      initializer: function(config) {

      //initialise exchange worker
      try {

      this. _worker = new Worker('http: //127.0.0. 1/static/ js/exchangeworke r.js');
      this. _worker.onmessage = function(e) {
      if (e.data == "nay") {
      alert("the worker responded");
      };
      }
      this. _worker.postMessage ("yay");

      } catch(e) {

      alert('Unable to create worker: ' + e.message);
      return;
      }
      }

      });

      Y.Manager = Manager;

      }, "3.0.0");


      worker.js
      onmessage = function(e){
      postMessage( "nay");
      };
    • Satyam
      ... In what circumstance? In response to a user click or such or when drawing them or what? ... Method getTrEl() returns the TR HTML element and then you can
      Message 2 of 5 , Dec 16, 2009
      • 0 Attachment
        wizard_files3 escribió:
        > Hi. This might be a newbie questions, but I really need an answer to them.
        >
        >
        > 1) How do I get a hold of a particular cell? (I have all data in JSP, but I need a particular row/cell in order to change its value at runtime). Should I give all cell specific names? Search by row?
        >
        In what circumstance? In response to a user click or such or when
        drawing them or what?
        > 2) How do I gray out a row?
        >
        Method getTrEl() returns the TR HTML element and then you can user
        YAHOO.util.Dom.addClass to add a className that will provide the graying
        out.

        Satyam
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >
        > ------------------------------------------------------------------------
        >
        >
        > No virus found in this incoming message.
        > Checked by AVG - www.avg.com
        > Version: 9.0.716 / Virus Database: 270.14.108/2566 - Release Date: 12/15/09 08:52:00
        >
        >
      • wizard_files3
        Thank you. Satyam, for your response! My scenario: -I receive data from Ajax call (I don t want to use DataSource for now). -Based on the data received, I need
        Message 3 of 5 , Dec 16, 2009
        • 0 Attachment
          Thank you. Satyam, for your response!

          My scenario:
          -I receive data from Ajax call (I don't want to use DataSource for now).
          -Based on the data received, I need to find a specific row by one of the columns with unique identifier
          -Update a cell in that row
          -How can I do that if my row is in Datatable?

          p.s. If I assign an id <td id='something'> to my td before Progressive rendering, would I still be able to access it by that id, and Datatable will pick up this dynamic change?







          --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
          >
          >
          >
          > wizard_files3 escribió:
          > > Hi. This might be a newbie questions, but I really need an answer to them.
          > >
          > >
          > > 1) How do I get a hold of a particular cell? (I have all data in JSP, but I need a particular row/cell in order to change its value at runtime). Should I give all cell specific names? Search by row?
          > >
          > In what circumstance? In response to a user click or such or when
          > drawing them or what?
          > > 2) How do I gray out a row?
          > >
          > Method getTrEl() returns the TR HTML element and then you can user
          > YAHOO.util.Dom.addClass to add a className that will provide the graying
          > out.
          >
          > Satyam
          > >
          > >
          > > ------------------------------------
          > >
          > > Yahoo! Groups Links
          > >
          > >
          > >
          > > ------------------------------------------------------------------------
          > >
          > >
          > > No virus found in this incoming message.
          > > Checked by AVG - www.avg.com
          > > Version: 9.0.716 / Virus Database: 270.14.108/2566 - Release Date: 12/15/09 08:52:00
          > >
          > >
          >
        • Satyam
          You explanation simply expands the same question without adding any more info. Do you: a) Want to transform the data being presented to the user before the
          Message 4 of 5 , Dec 17, 2009
          • 0 Attachment
            You explanation simply expands the same question without adding any more
            info. Do you:

            a) Want to transform the data being presented to the user before the
            user sees it? If so:
            1) does it apply to several fields? It is related to formatting?
            2) is there a particular field that you need updated? Can it be
            located by any piece of data within the record?
            b) Want to allow the user to click on a cell, edit it and save the change

            Id's coming from the HTML table will not be preserved. You have to
            completely separate the presentation stuff from the underlying data. In
            DataTable you operate on the data and let the DataTable deal with the
            presentation. There are hooks to allow you to control some aspects of
            that presentation but basically you leave it to the DataTable. You
            don't go accessing the HTML elements because what you want to deal with
            is the data, that is what is going into the database server or wherever
            it is stored.

            Satyam

            wizard_files3 escribió:
            > Thank you. Satyam, for your response!
            >
            > My scenario:
            > -I receive data from Ajax call (I don't want to use DataSource for now).
            > -Based on the data received, I need to find a specific row by one of the columns with unique identifier
            > -Update a cell in that row
            > -How can I do that if my row is in Datatable?
            >
            > p.s. If I assign an id <td id='something'> to my td before Progressive rendering, would I still be able to access it by that id, and Datatable will pick up this dynamic change?
            >
            >
            >
            >
            >
            >
            >
            > --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
            >
            >>
            >> wizard_files3 escribió:
            >>
            >>> Hi. This might be a newbie questions, but I really need an answer to them.
            >>>
            >>>
            >>> 1) How do I get a hold of a particular cell? (I have all data in JSP, but I need a particular row/cell in order to change its value at runtime). Should I give all cell specific names? Search by row?
            >>>
            >>>
            >> In what circumstance? In response to a user click or such or when
            >> drawing them or what?
            >>
            >>> 2) How do I gray out a row?
            >>>
            >>>
            >> Method getTrEl() returns the TR HTML element and then you can user
            >> YAHOO.util.Dom.addClass to add a className that will provide the graying
            >> out.
            >>
            >> Satyam
            >>
            >>> ------------------------------------
            >>>
            >>> Yahoo! Groups Links
            >>>
            >>>
            >>>
            >>> ------------------------------------------------------------------------
            >>>
            >>>
            >>> No virus found in this incoming message.
            >>> Checked by AVG - www.avg.com
            >>> Version: 9.0.716 / Virus Database: 270.14.108/2566 - Release Date: 12/15/09 08:52:00
            >>>
            >>>
            >>>
            >
            >
            >
            >
            > ------------------------------------
            >
            > Yahoo! Groups Links
            >
            >
            >
            > ------------------------------------------------------------------------
            >
            >
            > No virus found in this incoming message.
            > Checked by AVG - www.avg.com
            > Version: 9.0.716 / Virus Database: 270.14.110/2568 - Release Date: 12/16/09 09:02:00
            >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.