Subversion Repositories general

Rev

Blame | Last modification | View Log | RSS feed

var EXPORTED_SYMBOLS = ["NoModal_DialogParams"];

// =====================================================================================================================
var NoModal_DialogParams = {
        MAX_VALUES: 8,

        // -----------------------------------------------------------------------------------------------------------------
        create: function()
        {
                return Components.classes["@mozilla.org/embedcomp/dialogparam;1"]
                        .createInstance(Components.interfaces.nsIDialogParamBlock);
        },

        // -----------------------------------------------------------------------------------------------------------------
        encode: function(obj, params)
        {
                params.QueryInterface(Components.interfaces.nsIDialogParamBlock);

                var i = 0;
                for(var a in obj) {
                        params.SetString(i++, a);
                        params.SetString(i++, obj[a]);
                }

                for(; i < NoModal_DialogParams.MAX_VALUES * 2; ++i) {
                        params.SetString(i, null);
                }
        },

        // -----------------------------------------------------------------------------------------------------------------
        decode: function(params, obj)
        {
                params.QueryInterface(Components.interfaces.nsIDialogParamBlock);

                for(var i = 0; i < NoModal_DialogParams.MAX_VALUES; ++i) {
                        var k = params.GetString(i*2);
                        var v = params.GetString(i*2+1);

                        if(k != "") obj[k] = v;
                }
        },
}