This is just some static backup of the original site, don't expect every link to work!

Ignore:
Timestamp:
Nov 3, 2014, 12:35:40 PM (8 years ago)
Author:
rene <rene@…>
Branches:
ng_0.9
Children:
7204cb
Parents:
3c9c29
Message:

code formatting (no code changes)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/vI_identityDataExtras.js

    r3c9c29 r509348  
    2525var EXPORTED_SYMBOLS = ["identityDataExtras", "registerIdExtrasObject", "identityDataExtrasObject", "identityDataExtrasCheckboxObject"];
    2626
    27 const {classes: Cc, interfaces: Ci, utils: Cu, results : Cr} = Components;
     27const {
     28  classes: Cc,
     29  interfaces: Ci,
     30  utils: Cu,
     31  results: Cr
     32} = Components;
    2833
    2934Cu.import("resource://v_identity/vI_log.js");
     
    4752    .getService(Ci.nsIWindowMediator)
    4853    .getMostRecentWindow(null);
    49   for each (let [, identityDataExtrasObject] in Iterator(idExtrasObjects)) {
     54  for each(let [, identityDataExtrasObject] in Iterator(idExtrasObjects)) {
    5055    this.extras.push(new identityDataExtrasObject(currentWindow));
    5156  }
     
    5358    this.loopThroughExtras(
    5459      function (extra) {
    55         extra.value = rdfDatasource._getRDFValue(resource, extra.field);});
     60        extra.value = rdfDatasource._getRDFValue(resource, extra.field);
     61      });
    5662}
    5763identityDataExtras.prototype = {
    58   loopThroughExtras : function(k, returnVal) {
    59     for( var i = 0; i < this.extras.length; i++ ) {
     64  loopThroughExtras: function (k, returnVal) {
     65    for (var i = 0; i < this.extras.length; i++) {
    6066      try {
    6167        returnVal = k(this.extras[i], i, returnVal)
    62       }
    63       catch (e) {
     68      } catch (e) {
    6469        Log.warn("identityDataExtras '" + this.extras[i].field + "' returned an error:", e);
    6570        dumpCallStack(e);
     
    6873    return returnVal;
    6974  },
    70  
     75
    7176  // just give a duplicate of the current identityDataExtras, else we will work with pointers
    72   getDuplicate : function() {
     77  getDuplicate: function () {
    7378    var newExtras = new identityDataExtras();
    7479    this.loopThroughExtras(function (extra, i) {
     
    7782    return newExtras;
    7883  },
    79    
     84
    8085  // copys all values of an identity. This way we can create a new object with a different document-context
    81   copy : function(extras) {
     86  copy: function (extras) {
    8287    this.loopThroughExtras(function (extra, i) {
    8388      extra.value = extras.extras[i].value;
     
    8590  },
    8691
    87   equal : function(identityDataExtras) {
     92  equal: function (identityDataExtras) {
    8893    var returnVal = true;
    8994    return this.loopThroughExtras(function (extra, i, returnVal) {
    90       return extra.active?(extra.equal(identityDataExtras.extras[i]) && returnVal):returnVal;
     95      return extra.active ? (extra.equal(identityDataExtras.extras[i]) && returnVal) : returnVal;
    9196    }, returnVal);
    9297  },
    93  
    94   getMatrix : function() {
     98
     99  getMatrix: function () {
    95100    var returnVal = "";
    96101    return this.loopThroughExtras(function (extra, i, returnVal) {
    97102      if (extra.active && extra.valueHtml)
    98103        returnVal += "<tr>" +
    99           "<td class='col1 extras '>" + stringBundle.GetStringFromName("vident.identityData.extras." + extra.field) + "</td>" +
    100           "<td class='col2 extras '>" + extra.valueHtml + "</td>" +
    101           "</tr>"
     104        "<td class='col1 extras '>" + stringBundle.GetStringFromName("vident.identityData.extras." + extra.field) + "</td>" +
     105        "<td class='col2 extras '>" + extra.valueHtml + "</td>" +
     106        "</tr>"
    102107      return returnVal;
    103108    }, returnVal);
    104109  },
    105110
    106   getCompareMatrix : function() {
     111  getCompareMatrix: function () {
    107112    var returnVal = "";
    108113    return this.loopThroughExtras(function (extra, i, returnVal) {
    109114      if (extra.active) {
    110         var classEqual = (extra.lastCompareResult)?"equal":"unequal";
     115        var classEqual = (extra.lastCompareResult) ? "equal" : "unequal";
    111116        returnVal += "<tr>" +
    112         "<td class='col1 extras " + classEqual + "'>" + stringBundle.GetStringFromName("vident.identityData.extras." + extra.field) + "</td>" +
    113         "<td class='col2 extras " + classEqual + "'>" + extra.lastCompareValue + "</td>" +
    114         "<td class='col3 extras " + classEqual + "'>" + extra.valueHtml + "</td>" +
    115         "</tr>"
     117          "<td class='col1 extras " + classEqual + "'>" + stringBundle.GetStringFromName("vident.identityData.extras." + extra.field) + "</td>" +
     118          "<td class='col2 extras " + classEqual + "'>" + extra.lastCompareValue + "</td>" +
     119          "<td class='col3 extras " + classEqual + "'>" + extra.valueHtml + "</td>" +
     120          "</tr>"
    116121      }
    117122      return returnVal
     
    119124  },
    120125
    121   status : function() {
     126  status: function () {
    122127    var returnVal = "";
    123128    return this.loopThroughExtras(function (extra) {
    124       return returnVal += returnVal?" ":"" + extra.status;
     129      return returnVal += returnVal ? " " : "" + extra.status;
    125130    }, returnVal);
    126131  },
    127132
    128   readIdentityValues : function(identity) {
     133  readIdentityValues: function (identity) {
    129134    this.loopThroughExtras(function (extra) {
    130135      extra.readIdentityValue(identity)
     
    132137  },
    133138
    134   setValuesToEnvironment : function() {
     139  setValuesToEnvironment: function () {
    135140    this.loopThroughExtras(function (extra) {
    136141      extra.setValueToEnvironment()
    137142    });
    138143  },
    139  
    140   getValuesFromEnvironment : function() {
     144
     145  getValuesFromEnvironment: function () {
    141146    this.loopThroughExtras(function (extra) {
    142147      extra.getValueFromEnvironment()
    143148    });
    144149  },
    145  
     150
    146151  // add value's to the pref object, required for rdfDataTreeCollection
    147   addPrefs : function(pref) {
     152  addPrefs: function (pref) {
    148153    this.loopThroughExtras(function (extra) {
    149154      pref[extra.field + "Col"] = extra.valueNice;
     
    156161}
    157162identityDataExtrasObject.prototype = {
    158   value :   null,  // will contain the current value of the object and can be accessed from outside
    159   field :   null,  // short description of the field
    160   option :  null,  // option from preferences, boolean
    161   window :  null,  // the current Window the object was created for
    162  
    163   lastCompareValue : "",
    164   lastCompareResult : false,
     163  value: null, // will contain the current value of the object and can be accessed from outside
     164  field: null, // short description of the field
     165  option: null, // option from preferences, boolean
     166  window: null, // the current Window the object was created for
     167
     168  lastCompareValue: "",
     169  lastCompareResult: false,
    165170
    166171  get valueHtml() {
    167       if (!this.value)
    168         return "";
    169       return  "<div class='bool" + ((this.value=="true")?" checked":"") + "'>" +
    170               "<label class='screen'>&nbsp;</label>" +
    171               "<label class='braille'>" + this.valueNice + "</label>" +
    172           "</div>"
     172    if (!this.value)
     173      return "";
     174    return "<div class='bool" + ((this.value == "true") ? " checked" : "") + "'>" +
     175      "<label class='screen'>&nbsp;</label>" +
     176      "<label class='braille'>" + this.valueNice + "</label>" +
     177      "</div>"
    173178  },
    174179  get valueNice() {
    175       if (!this.value)
    176         return "";
    177       return (this.value=="true")?"yes":"no";
     180    if (!this.value)
     181      return "";
     182    return (this.value == "true") ? "yes" : "no";
    178183  },
    179184  get status() {
     
    182187    return "";
    183188  },
    184   get active() { return vIprefs.get("storage") && vIprefs.get(this.option) },
    185   equal : function(compareIdentityDataExtrasObject) {
     189  get active() {
     190    return vIprefs.get("storage") && vIprefs.get(this.option)
     191  },
     192  equal: function (compareIdentityDataExtrasObject) {
    186193    this.lastCompareValue = compareIdentityDataExtrasObject.valueHtml;
    187194    this.lastCompareResult = (!this.value || !compareIdentityDataExtrasObject.value || this.value == compareIdentityDataExtrasObject.value);
    188195    if (!this.lastCompareResult) {
    189       Log.debug("extras not equal "+ this.field + " ('" + this.value + "' != '" + compareIdentityDataExtrasObject.value + "')");
     196      Log.debug("extras not equal " + this.field + " ('" + this.value + "' != '" + compareIdentityDataExtrasObject.value + "')");
    190197    }
    191198    return this.lastCompareResult;
    192199  },
    193200  // function to read the value from a given identity (probably not part of identity)
    194   readIdentityValue : function(identity) { },
     201  readIdentityValue: function (identity) {},
    195202  // function to set or read the value from/to the environment
    196   setValueToEnvironment : function() {
     203  setValueToEnvironment: function () {
    197204    let id = this.currentWindow.document.documentElement.id;
    198     switch(id) {
    199       case "msgcomposeWindow":
    200         this.setValueToEnvironment_msgCompose();
    201         break;
    202       case "messengerWindow":
    203         this.setValueToEnvironment_messenger();
    204         break;
    205       case "vI_rdfDataTreeWindow":
    206       case "vI_rdfDataEditor":
    207         this.setValueToEnvironment_dataEditor();
    208         break;
    209       default:
    210         Log.error("getValueFromEnvironment unknown window: " + id)
    211     }
    212   },
    213   getValueFromEnvironment : function() {
     205    switch (id) {
     206    case "msgcomposeWindow":
     207      this.setValueToEnvironment_msgCompose();
     208      break;
     209    case "messengerWindow":
     210      this.setValueToEnvironment_messenger();
     211      break;
     212    case "vI_rdfDataTreeWindow":
     213    case "vI_rdfDataEditor":
     214      this.setValueToEnvironment_dataEditor();
     215      break;
     216    default:
     217      Log.error("getValueFromEnvironment unknown window: " + id)
     218    }
     219  },
     220  getValueFromEnvironment: function () {
    214221    let id = this.currentWindow.document.documentElement.id;
    215     switch(id) {
    216       case "msgcomposeWindow":
    217         this.getValueFromEnvironment_msgCompose();
    218         break;
    219       case "messengerWindow":
    220         this.getValueFromEnvironment_messenger();
    221         break;
    222       case "vI_rdfDataTreeWindow":
    223       case "vI_rdfDataEditor":
    224         this.getValueFromEnvironment_dataEditor();
    225         break;
    226       default:
    227         Log.error("getValueFromEnvironment unknown window: " + id)
    228     }
    229   },
    230   setValueToEnvironment_msgCompose : function() {
     222    switch (id) {
     223    case "msgcomposeWindow":
     224      this.getValueFromEnvironment_msgCompose();
     225      break;
     226    case "messengerWindow":
     227      this.getValueFromEnvironment_messenger();
     228      break;
     229    case "vI_rdfDataTreeWindow":
     230    case "vI_rdfDataEditor":
     231      this.getValueFromEnvironment_dataEditor();
     232      break;
     233    default:
     234      Log.error("getValueFromEnvironment unknown window: " + id)
     235    }
     236  },
     237  setValueToEnvironment_msgCompose: function () {
    231238    Log.error("setValueToEnvironment not implemented for msgCompose and " + this.field)
    232239  },
    233   setValueToEnvironment_messenger : function() {
     240  setValueToEnvironment_messenger: function () {
    234241    Log.error("setValueToEnvironment not implemented for Messenger and " + this.field)
    235242  },
    236   setValueToEnvironment_dataEditor : function() {
     243  setValueToEnvironment_dataEditor: function () {
    237244    Log.error("setValueToEnvironment not implemented for dataEditor and " + this.field)
    238245  },
    239   getValueFromEnvironment_msgCompose : function() {
     246  getValueFromEnvironment_msgCompose: function () {
    240247    Log.error("setValueToEnvironment not implemented for msgCompose and " + this.field)
    241248  },
    242   getValueFromEnvironment_messenger : function() {
     249  getValueFromEnvironment_messenger: function () {
    243250    Log.error("setValueToEnvironment not implemented for Messenger and " + this.field)
    244251  },
    245   getValueFromEnvironment_dataEditor : function() {
     252  getValueFromEnvironment_dataEditor: function () {
    246253    Log.error("setValueToEnvironment not implemented for dataEditor and " + this.field)
    247254  }
     
    254261identityDataExtrasCheckboxObject.prototype = {
    255262  __proto__: identityDataExtrasObject.prototype,
    256  
    257   updateFunction_msgCompose : function() {},
    258   elementID_msgCompose : null,
    259  
    260   readIdentityValue : function(identity) {
     263
     264  updateFunction_msgCompose: function () {},
     265  elementID_msgCompose: null,
     266
     267  readIdentityValue: function (identity) {
    261268    if (this.active)
    262       this.value = (this.func_valueFromIdentity(identity))?"true":"false";
    263   },
    264 
    265   setValueToEnvironment_msgCompose: function() {
     269      this.value = (this.func_valueFromIdentity(identity)) ? "true" : "false";
     270  },
     271
     272  setValueToEnvironment_msgCompose: function () {
    266273    var element = this.currentWindow.document.getElementById(this.elementID_msgCompose);
    267274    if (!this.active || (this.value == null) || !element)
    268275      return;
    269    
     276
    270277    this.updateFunction_msgCompose();
    271278    if ((element.getAttribute("checked") == "true") != (this.value == "true")) {
    272       Log.debug("change "+ this.field + " to " + this.value + " with doCommand");
     279      Log.debug("change " + this.field + " to " + this.value + " with doCommand");
    273280      element.doCommand();
    274281    }
    275282  },
    276  
    277   setValueToEnvironment_dataEditor: function() {
     283
     284  setValueToEnvironment_dataEditor: function () {
    278285    if (this.value != null) {
    279286      this.currentWindow.document.getElementById("vI_" + this.option).setAttribute("checked", this.value);
     
    282289    this.currentWindow.document.getElementById("vI_" + this.option + "_store").doCommand();
    283290  },
    284  
    285   getValueFromEnvironment_msgCompose: function() {
     291
     292  getValueFromEnvironment_msgCompose: function () {
    286293    var element = this.currentWindow.document.getElementById(this.elementID_msgCompose)
    287294    if (this.active && element) {
    288295      this.updateFunction_msgCompose();
    289       this.value = ((element.getAttribute("checked") == "true")?"true":"false");
    290     }
    291   },
    292  
    293   getValueFromEnvironment_dataEditor: function() {
     296      this.value = ((element.getAttribute("checked") == "true") ? "true" : "false");
     297    }
     298  },
     299
     300  getValueFromEnvironment_dataEditor: function () {
    294301    if (this.currentWindow.document.getElementById("vI_" + this.option + "_store").getAttribute("checked") == "true") {
    295302      var elementValue = this.currentWindow.document.getElementById("vI_" + this.option).getAttribute("checked");
    296       this.value = (elementValue == "true")?"true":"false"
    297     }
    298     else
     303      this.value = (elementValue == "true") ? "true" : "false"
     304    } else
    299305      this.value = null;
    300306  }
Note: See TracChangeset for help on using the changeset viewer.