Reuse ACE

Reuse action/condition/expression from other plugin.

Action cr.plugins_.WebStorage.prototype.acts.StoreLocal.call(webstorage_obj, key, value);


Condition
cr.plugins_.WebStorage.prototype.cnds.LocalStorageExists.call(webstorage_obj, key);



Expression 

var fake_ret = {
    value:0,
    set_any: function(value){this.value=value;},
    set_int: function(value){this.value=value;},
    set_float: function(value){this.value=value;}, 
    set_string: function(value) {this.value=value;},
};
cr.plugins_.WebStorage.prototype.exps.LocalValue.call(webstorage_obj, fake_ret, key);
return fake_ret.value



Get instance 
var plugins = this.runtime.types; 
var name, inst; 
for (name in plugins)
{
    inst = plugins[name].instances[0]; 
    if (inst instanceof cr.plugins_.WebStorage.prototype.Instance)
    {
        // get target instance 
    } 
 
 
 
Reference - webstorage extension plugin
   

2 comments:

  1. Seeing the code just "hanging out in space" makes it hard to understand. As opposed to showing the code snippets within the their code blocks in their actual parent scripts. Or at least a note saying what script they go in.

    ReplyDelete
  2. I would _guess_ this code is in the runtime.js. Am I right?

    ReplyDelete