mozilla
Your Search Results

    Using nsISimpleEnumerator

    Using nsISimpleEnumerator

    • <stringbundle>.strings
    var enumerator = document.getElementById('aStringBundleID').strings;
    var s = "";
    while (enumerator.hasMoreElements()) {
      var property = enumerator.getNext().QueryInterface(Components.interfaces.nsIProperty);
      s += property.name + ' = ' + property.value + ';\n';
    }
    alert(s);
    

    Example using JavaScript 1.7 features

    // creates a generator iterating over enum's values
    function generatorFromSimpleEnumerator(enum, interface) {
      while (enum.hasMoreElements()) {
        yield enum.getNext().QueryInterface(interface);
      }
    }
    var b = document.getElementById("stringbundleset").firstChild
    var props = generatorFromEnumerator(b.strings, Components.interfaces.nsIPropertyElement);
    var s = "";
    for (let property in props) {
      s += property.key + ' = ' + property.value + ';\n';
    }
    alert(s);
    

    Document Tags and Contributors

    Contributors to this page: Ferric, mcpherrinm, Nickolay, Yanmorin
    Last updated by: mcpherrinm,