Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Porter <slug@qwebirc.org>2010-04-24 02:28:21 (GMT)
committer Chris Porter <slug@qwebirc.org>2010-04-24 02:28:21 (GMT)
commit35d6507564d0fcbd11891dad07753e20d78fe593 (patch)
tree14d6cc8d3fac52923eb8ca0b05621d176bc040ba
parent09bf9a41f32b047a1636d553808cebe8941efaf1 (diff)
Add dynamic setting of UI options in URL.
-rw-r--r--js/qwebircinterface.js5
-rw-r--r--js/ui/baseui.js6
-rw-r--r--js/ui/panes/embed.js27
-rw-r--r--js/ui/panes/options.js57
4 files changed, 86 insertions, 9 deletions
diff --git a/js/qwebircinterface.js b/js/qwebircinterface.js
index 381ecbd..4989780 100644
--- a/js/qwebircinterface.js
+++ b/js/qwebircinterface.js
@@ -19,6 +19,7 @@ qwebirc.ui.Interface = new Class({
theme: undefined,
baseURL: null,
hue: null,
+ uiOptionsArg: null,
dynamicBaseURL: "/",
staticBaseURL: "/"
},
@@ -44,6 +45,10 @@ qwebirc.ui.Interface = new Class({
if(this.options.searchURL) {
var args = qwebirc.util.parseURI(String(document.location));
this.options.hue = this.getHueArg(args);
+
+ if($defined(args["uio"]))
+ this.options.uiOptionsArg = args["uio"];
+
var url = args["url"];
var chans, nick = args["nick"];
diff --git a/js/ui/baseui.js b/js/ui/baseui.js
index 3da28ab..524a853 100644
--- a/js/ui/baseui.js
+++ b/js/ui/baseui.js
@@ -190,7 +190,7 @@ qwebirc.ui.StandardUI = new Class({
this.parent(parentElement, windowClass, uiName, options);
this.tabCompleter = new qwebirc.ui.TabCompleterFactory(this);
- this.uiOptions = new qwebirc.ui.DefaultOptionsClass(this);
+ this.uiOptions = new qwebirc.ui.DefaultOptionsClass(this, options.uiOptionsArg);
this.customWindows = {};
var ev;
@@ -293,7 +293,9 @@ qwebirc.ui.StandardUI = new Class({
d.setSubWindow(ew);
},
embeddedWindow: function() {
- this.addCustomWindow("Embedding wizard", qwebirc.ui.EmbedWizard, "embeddedwizard", {baseURL: this.options.baseURL});
+ this.addCustomWindow("Embedding wizard", qwebirc.ui.EmbedWizard, "embeddedwizard", {baseURL: this.options.baseURL, uiOptions: this.uiOptions, optionsCallback: function() {
+ this.optionsWindow();
+ }.bind(this)});
},
optionsWindow: function() {
this.addCustomWindow("Options", qwebirc.ui.OptionsPane, "optionspane", this.uiOptions);
diff --git a/js/ui/panes/embed.js b/js/ui/panes/embed.js
index 9d4867d..7a3fd1e 100644
--- a/js/ui/panes/embed.js
+++ b/js/ui/panes/embed.js
@@ -32,11 +32,16 @@ qwebirc.ui.EmbedWizardStep = new Class({
qwebirc.ui.EmbedWizard = new Class({
Implements: [Options, Events],
options: {
- parent: null,
+ uiOptions: null,
+ optionsCallback: null,
baseURL: "http://webchat.quakenet.org/"
},
initialize: function(parent, options) {
- this.setOptions(options);
+ /* for some unknown reason setOptions doesn't work... */
+ this.options.uiOptions = options.uiOptions;
+ this.options.baseURL = options.baseURL;
+ this.options.optionsCallback = options.optionsCallback;
+
this.create(parent);
this.addSteps();
},
@@ -110,7 +115,7 @@ qwebirc.ui.EmbedWizard = new Class({
};
this.welcome = this.newStep({
- "title": "Welcome!",
+ "title": "Add webchat to your website",
"first": "This wizard will help you create an embedded client by asking you questions then giving you the code to add to your website.<br/><br/>You can use the <b>Next</b> and <b>Back</b> buttons to navigate through the wizard; click <b>Next</b> to continue."
});
@@ -143,6 +148,17 @@ qwebirc.ui.EmbedWizard = new Class({
middle: promptdiv,
"hint": "You need to display the dialog if you want the user to be able to set their nickname before connecting."
});
+
+ var changeOptions = new Element("input");
+ changeOptions.type = "submit";
+ changeOptions.value = "Alter current look and feel";
+ changeOptions.addEvent("click", this.options.optionsCallback);
+
+ this.lookandfeel = this.newStep({
+ "title": "Alter look and feel?",
+ "first": "The look and feel will be copied from the current settings.",
+ middle: changeOptions
+ });
var autoconnect = this.newRadio(promptdiv, "Connect without displaying the dialog.", "prompt", true);
this.connectdialogr = this.newRadio(promptdiv, "Show the connect dialog.", "prompt");
@@ -216,6 +232,7 @@ qwebirc.ui.EmbedWizard = new Class({
if(this.chanBox.value != "" && !this.choosenick.checked)
this.steps.push(this.connectdialog);
+ this.steps.push(this.lookandfeel);
this.steps.push(this.finish);
},
showStep: function() {
@@ -278,6 +295,10 @@ qwebirc.ui.EmbedWizard = new Class({
if(connectdialog)
URL.push("prompt=1");
+ var uioptions = this.options.uiOptions.serialise();
+ if(uioptions != "")
+ URL.push("uio=" + uioptions);
+
return this.options.baseURL + (URL.length>0?"?":"") + URL.join("&");
}
});
diff --git a/js/ui/panes/options.js b/js/ui/panes/options.js
index 251b01d..2422f75 100644
--- a/js/ui/panes/options.js
+++ b/js/ui/panes/options.js
@@ -9,6 +9,10 @@ qwebirc.ui.supportsFocus = function() {
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, {
enabled: function() {
@@ -27,8 +31,12 @@ qwebirc.config.DEFAULT_OPTIONS = [
[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 channel lines", 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],
+ [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
}],
@@ -213,7 +221,13 @@ qwebirc.config.Option = new Class({
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)
@@ -411,6 +425,41 @@ qwebirc.ui.CookieOptions = new Class({
}
});
+qwebirc.ui.SuppliedArgOptions = new Class({
+ Extends: qwebirc.ui.CookieOptions,
+ initialize: function(ui, arg) {
+ var p = {};
+
+ if($defined(arg) && arg != "") {
+ var decoded = qwebirc.util.b64Decode(arg);
+ if(decoded)
+ p = qwebirc.util.parseURI("?" + decoded);
+ }
+
+ this.parsedOptions = p;
+ this.parent(ui);
+ },
+ _get: function(x) {
+ if(x.settableByURL !== true)
+ return this.parent(x);
+
+ var opt = this.parsedOptions[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 + "=" + x.value);
+ }.bind(this));
+
+ return qwebirc.util.b64Encode(result.join("&")).replaceAll("=", "");
+ }
+});
+
qwebirc.ui.DefaultOptionsClass = new Class({
- Extends: qwebirc.ui.CookieOptions
+ Extends: qwebirc.ui.SuppliedArgOptions
});