-qwebirc.config.CHECK_BOX = 1;
-qwebirc.config.TEXT_BOX = 2;
-qwebirc.config.RADIO_BUTTONS = 3;
-
qwebirc.ui.supportsFocus = function() {
var ua = navigator.userAgent;
if(!$defined(ua))
return [true];
}
+/**
+ * Note that options are settable by the uioptions url arg by default unless you specifiy
+ * settableByURL...
+ */
qwebirc.config.DEFAULT_OPTIONS = [
- [1, "BEEP_ON_MENTION", "Beep when nick mentioned or on query activity (requires Flash)", true, {
+ [1, "BEEP_ON_MENTION", "Beep on activity", true, {
+ applyChanges: function(value, ui) {
+ if(ui.setBeepOnMention)
+ ui.setBeepOnMention(value);
+ }
+ }],
+ [16, "NOTIFICATIONS", "Emit HTML5 notifications on activity", false, {
enabled: function() {
- if(!$defined(Browser.Plugins.Flash) || Browser.Plugins.Flash.version < 8)
+ if(!("Notification" in window))
return [false, false]; /* [disabled, default_value] */
return [true];
},
- get: function(value, ui) {
- if(ui.setBeepOnMention)
- ui.setBeepOnMention(value);
+ applyChanges: function(value, ui) {
+ if(ui.setNotifications)
+ ui.setNotifications(value);
}
}],
[7, "FLASH_ON_MENTION", "Flash titlebar when nick mentioned or on query activity", true, {
}],
[2, "DEDICATED_MSG_WINDOW", "Send privmsgs to dedicated messages window", false],
[4, "DEDICATED_NOTICE_WINDOW", "Send notices to dedicated message window", false],
- [3, "NICK_OV_STATUS", "Show status (@/+) before nicknames in nicklist", true],
- [5, "ACCEPT_SERVICE_INVITES", "Automatically join channels when invited by Q", true],
- [6, "USE_HIDDENHOST", "Hide your hostmask when authed to Q (+x)", true],
+ [3, "NICK_OV_STATUS", "Show status (@/+) before nicknames in channel lines", true],
+ [5, "ACCEPT_SERVICE_INVITES", "Automatically join channels when invited by Q", true, {
+ settableByURL: false
+ }],
+ [6, "USE_HIDDENHOST", "Hide your hostmask when authed to Q (+x)", true, {
+ settableByURL: false
+ }],
[8, "LASTPOS_LINE", "Show a last position indicator for each window", true, {
enabled: qwebirc.ui.supportsFocus
}],
[9, "NICK_COLOURS", "Automatically colour nicknames", false],
- [10, "HIDE_JOINPARTS", "Hide JOINS/PARTS/QUITS", false]
+ [10, "HIDE_JOINPARTS", "Hide JOINS/PARTS/QUITS", false],
+ [11, "STYLE_HUE", "Adjust user interface hue", function() {
+ return {class_: qwebirc.config.HueOption, default_: 210};
+ }, {
+ applyChanges: function(value, ui) {
+ ui.setModifiableStylesheetValues({hue: value});
+ }
+ }],
+ [12, "QUERY_ON_NICK_CLICK", "Query on nickname click in channel", false],
+ [13, "SHOW_NICKLIST", "Show nickname list in channels", qwebirc.util.deviceHasKeyboard()],
+ [14, "SHOW_TIMESTAMPS", "Show timestamps", true], /* we rely on the hue update */
+ [15, "SIDE_TABS", "Show tabs on the side", false, {
+ enabled: function() {
+ if(Browser.Engine.trident && Browser.Engine.version < 8)
+ return [false, false]; /* [disabled, default_value] */
+ return [true];
+ },
+ applyChanges: function(value, ui) {
+ ui.setSideTabs(value);
+ }
+ }]
];
qwebirc.config.DefaultOptions = null;
this.render();
},
- createInput: function(type, parent, name, selected) {
+ createInput: function(type, parent, name, selected, id) {
if(!$defined(parent))
parent = this.parentElement;
- return qwebirc.util.createInput(type, parent, name, selected);
+ return qwebirc.util.createInput(type, parent, name, selected, this.option.id);
},
FE: function(element, parent) {
var n = new Element(element);
render: function() {
this.event("render", this.mainElement);
},
- get: function(value) {
- this.event("get", [value, this.parentObject.optionObject.ui]);
- return value;
+ applyChanges: function() {
+ this.event("applyChanges", [this.get(), this.parentObject.optionObject.ui]);
},
event: function(name, x) {
if(!$defined(this.option.extras))
return;
t.pass(x, this)();
+ },
+ cancel: function() {
}
});
this.parent();
},
get: function() {
- return this.parent(this.mainElement.value);
+ return this.mainElement.value;
+ }
+});
+
+qwebirc.config.HueInput = new Class({
+ Extends: qwebirc.config.Input,
+ render: function() {
+ var i = new Element("div");
+ i.addClass("qwebirc-optionspane");
+ i.addClass("hue-slider");
+ this.parentElement.appendChild(i);
+
+ var k = new Element("div");
+ k.addClass("knob");
+ if(Browser.Engine.trident) {
+ k.setStyle("top", "0px");
+ k.setStyle("background-color", "black");
+ }
+
+ i.appendChild(k);
+
+ var slider = new Slider(i, k, {steps: 36, range: [0, 369], wheel: true});
+ slider.set(this.value);
+ this.startValue = this.value;
+
+ slider.addEvent("change", function(step) {
+ this.value = step;
+ this.applyChanges();
+ }.bind(this));
+ this.mainElement = i;
+
+ if(!this.enabled)
+ slider.detach();
+
+ this.parent();
+ },
+ get: function() {
+ return this.value;
+ },
+ cancel: function() {
+ this.value = this.startValue;
+ this.applyChanges();
}
});
qwebirc.config.CheckInput = new Class({
Extends: qwebirc.config.Input,
render: function() {
- var i = this.createInput("checkbox");
+ var i = this.createInput("checkbox", null, null, null, this.id);
this.mainElement = i;
i.checked = this.value;
this.parent();
},
get: function() {
- return this.parent(this.mainElement.checked);
+ return this.mainElement.checked;
}
});
var x = this.elements[i];
if(x.checked) {
this.option.position = i;
- return this.parent(this.option.options[i][1]);
+ return this.option.options[i][1];
}
}
}
this.default_ = enabledResult[1];
} else {
this.enabled = true;
- }
+ }
+
+ if($defined(extras) && $defined(extras.settableByURL)) {
+ this.settableByURL = extras.settableByURL;
+ } else {
+ this.settableByURL = true;
+ }
},
setSavedValue: function(x) {
if(this.enabled)
Element: qwebirc.config.CheckInput
});
+qwebirc.config.HueOption = new Class({
+ Extends: qwebirc.config.Option,
+ Element: qwebirc.config.HueInput
+});
+
qwebirc.ui.Options = new Class({
initialize: function(ui) {
if(!$defined(qwebirc.config.DefaultOptions))
var type;
if(stype == "boolean") {
type = qwebirc.config.CheckOption;
+ } else if(stype == "function") {
+ var options = default_();
+ type = options.class_;
+ default_ = options.default_;
} else {
type = qwebirc.config.TextOption;
}
var row = FE("tr", tb);
var cella = FE("td", row);
- cella.set("text", x.label + ":");
+
+ x.id = qwebirc.util.generateID();
+ var label = new Element("label", {"for": x.id});
+ cella.appendChild(label);
+ label.set("text", x.label + ":");
var cellb = FE("td", row);
this.boxList.push([x, new x.Element(cellb, x, i, this)]);
var cancel = qwebirc.util.createInput("submit", cellb);
cancel.value = "Cancel";
cancel.addEvent("click", function() {
+ this.cancel();
this.fireEvent("close");
}.bind(this));
},
var box = x[1];
this.optionObject.setValue(option, box.get());
}.bind(this));
+ this.boxList.forEach(function(x) {
+ x[1].applyChanges();
+ }.bind(this));
this.optionObject.flush();
+ },
+ cancel: function() {
+ this.boxList.forEach(function(x) {
+ x[1].cancel();
+ }.bind(this));
}
});
}
});
+qwebirc.ui.SuppliedArgOptions = new Class({
+ Extends: qwebirc.ui.CookieOptions,
+ initialize: function(ui, arg) {
+ var p = new QHash();
+
+ if($defined(arg) && arg != "" && arg.length > 2) {
+ var checksum = arg.substr(arg.length - 2, 2);
+ var decoded = qwebirc.util.b64Decode(arg.substr(0, arg.length - 2));
+
+ if(decoded && (new qwebirc.util.crypto.MD5().digest(decoded).slice(0, 2) == checksum)) {
+ var p2 = qwebirc.util.parseURI("?" + decoded);
+ p2.each(function(k, v) {
+ p.put(k, JSON.decode(v, true));
+ });
+ }
+ }
+
+ this.parsedOptions = p;
+ this.parent(ui);
+ },
+ _get: function(x) {
+ if(x.settableByURL !== true)
+ return this.parent(x);
+
+ var opt = this.parsedOptions.get(String(x.optionId));
+ if(!$defined(opt))
+ return this.parent(x);
+
+ return opt;
+ },
+ serialise: function() {
+ var result = [];
+ this.getOptionList().forEach(function(x) {
+ if(x.settableByURL && x.default_ != x.value)
+ result.push(x.optionId + "=" + JSON.encode(x.value));
+ }.bind(this));
+
+ var raw = result.join("&");
+ var checksum = new qwebirc.util.crypto.MD5().digest(raw).slice(0, 2);
+ return (qwebirc.util.b64Encode(raw)).replaceAll("=", "") + checksum;
+ }
+});
+
qwebirc.ui.DefaultOptionsClass = new Class({
- Extends: qwebirc.ui.CookieOptions
+ Extends: qwebirc.ui.SuppliedArgOptions
});