]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Add connection wizard.
authorChris Porter <redacted>
Sat, 18 Oct 2008 15:59:58 +0000 (16:59 +0100)
committerChris Porter <redacted>
Sat, 18 Oct 2008 15:59:58 +0000 (16:59 +0100)
compile.bat
compile.sh
js/ui/connectwizard.js [new file with mode: 0644]
static/mochauidebug.html
static/quidebug.html
static/swmuidebug.html
static/uglyuidebug.html

index b09a7075bbf73d217d994116f296a5c0631e3406..efe5f125614a6cfd33c23307aed36a052b78f172 100644 (file)
@@ -3,7 +3,7 @@ mkdir compiled
 del /q compiled\*.js\r
 \r
 cd js\r
-copy version.js + jslib.js + irc\ircconnection.js + irc\irclib.js + irc\baseircclient.js + irc\irctracker.js + irc\commandparser.js + irc\ircclient.js + ui\baseui.js + ui\baseuiwindow.js + ui\colour.js + ui\url.js + ui\theme.js + ui\genericlogin.js + qwebircinterface.js + irc\commandhistory.js ..\compiled\qwebirc-concat.js /b\r
+copy version.js + jslib.js + irc\ircconnection.js + irc\irclib.js + irc\baseircclient.js + irc\irctracker.js + irc\commandparser.js + irc\ircclient.js + ui\baseui.js + ui\baseuiwindow.js + ui\colour.js + ui\url.js + ui\theme.js + ui\genericlogin.js + ui\connectwizard.js + qwebircinterface.js + irc\commandhistory.js ..\compiled\qwebirc-concat.js /b\r
 copy ui\swmlayout.js + ui\swmui.js ..\compiled\swmui-concat.js /b\r
 cd ..\compiled\r
 \r
index 5675fb0a212f92320575ac228f90949afe87f763..8193439746f75969a486b079e3c30c8d1b8a750a 100755 (executable)
@@ -3,7 +3,7 @@ mkdir -p compiled
 rm -f compiled/*.js
 
 cd js
-cat version.js jslib.js irc/ircconnection.js irc/irclib.js irc/baseircclient.js irc/irctracker.js irc/commandparser.js irc/ircclient.js ui/baseui.js ui/baseuiwindow.js ui/colour.js ui/url.js ui/theme.js ui/genericlogin.js irc/commandhistory.js qwebircinterface.js > ../compiled/qwebirc-concat.js
+cat version.js jslib.js irc/ircconnection.js irc/irclib.js irc/baseircclient.js irc/irctracker.js irc/commandparser.js irc/ircclient.js ui/baseui.js ui/baseuiwindow.js ui/colour.js ui/url.js ui/theme.js ui/genericlogin.js ui/connectwizard.js irc/commandhistory.js qwebircinterface.js > ../compiled/qwebirc-concat.js
 cat ui/swmlayout.js ui/swmui.js > ../compiled/swmui-concat.js
 
 error() {
diff --git a/js/ui/connectwizard.js b/js/ui/connectwizard.js
new file mode 100644 (file)
index 0000000..b423d31
--- /dev/null
@@ -0,0 +1,271 @@
+var WebmasterGuideStep = new Class({
+  Implements: [Options, Events],
+  options: {
+    "title": "",
+    "first": "",
+    "hint": "",
+    "middle": null,
+    "premove": null,
+    "example": ""
+  },
+  initialize: function(parent, options) {
+    this.setOptions(options);
+    this.parent = parent;
+  },
+  show: function() {
+    this.parent.title.set("html", this.options.title);
+    this.parent.firstRow.set("html", this.options.first);
+    this.parent.hint.set("html", this.options.hint);
+    this.parent.example.set("text", this.options.example);
+    
+    while(this.parent.middleRow.childNodes.length > 0)
+      this.parent.middleRow.removeChild(this.parent.middleRow.childNodes[0]);
+      
+    if($defined(this.options.middle))
+      this.parent.middleRow.appendChild(this.options.middle);
+    
+    this.fireEvent("show");
+  }
+});
+
+var WebmasterGuide = new Class({
+  Implements: [Options, Events],
+  options: {
+    parent: null,
+    baseURL: "http://webchat.quakenet.org/"
+  },
+  initialize: function(options) {
+    this.setOptions(options);
+    this.create(options.parent);
+    this.addSteps();
+  },
+  create: function(parent) {
+    this.t = parent;
+
+    var titleRow = this.newRow();
+    this.title = new Element("h2");
+    this.title.setStyle("margin-top", "0px");
+    this.title.setStyle("margin-bottom", "5px");
+    titleRow.appendChild(this.title);
+    
+    this.firstRow = this.newRow();
+    this.middleRow = this.newRow();
+    var hintRow = this.newRow();
+    this.hint = new Element("div");
+    this.hint.setStyle("font-size", "0.8em");
+    this.hint.setStyle("font-style", "italic");
+    hintRow.appendChild(this.hint);
+    var exampleRow = this.newRow();
+    this.example = new Element("pre");
+    exampleRow.appendChild(this.example);
+    
+    var nextRow = this.newRow();
+    nextRow.setStyle("position", "absolute");
+    nextRow.setStyle("bottom", "0px");
+    nextRow.setStyle("right", "0px");
+    nextRow.setStyle("margin", "3px");
+    var backBtn = new Element("input");
+    backBtn.type = "submit";
+    backBtn.value = "< Back";
+    backBtn.addEvent("click", this.back.bind(this));
+    nextRow.appendChild(backBtn);
+    
+    var nextBtn = new Element("input");
+    nextBtn.type = "submit";
+    nextBtn.value = "Next >";
+    nextRow.appendChild(nextBtn);
+    nextBtn.addEvent("click", this.next.bind(this));
+    
+    this.nextBtn = nextBtn;
+    this.backBtn = backBtn;
+  },
+  newRow: function() {
+    var cell = new Element("div");
+    this.t.appendChild(cell);
+    return cell;
+  },
+  newStep: function(options) {
+    return new WebmasterGuideStep(this, options);
+  },
+  newRadio: function(parent, text, name, selected) {
+    var p = new Element("div");
+    parent.appendChild(p);
+      
+    var r = new Element("input");
+    r.type = "radio";
+    r.name = name;
+    
+    if(selected)
+      r.checked = true;
+      
+    p.appendChild(r);
+    p.appendChild(document.createTextNode(text));
+      
+    return r;
+  },
+  addSteps: function() {
+    var af = function() { this.options.middle.focus(); };
+  
+    this.welcome = this.newStep({
+      "title": "Welcome!",
+      "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."
+    });
+    
+    this.chanBox = new Element("input");
+    this.chans = this.newStep({
+      "title": "Set channels",
+      "first": "Enter the channels you would like the client to join on startup:",
+      "hint": "You can supply multiple channels by seperating them with a comma, e.g.:",
+      "example": "#rogue,#eu-mage",
+      middle: this.chanBox,
+    }).addEvent("show", af);
+    
+    var customnickDiv = new Element("div");
+    this.customnick = this.newStep({
+      "title": "Nickname mode",
+      "first": "At startup would you like the client to use a random nickname, a preset nickname or a nickname of the users choice?",
+      "hint": "It is recommended that you only use a preset nickname if the client is for your own personal use.",
+      middle: customnickDiv
+    });
+
+    this.randnick = this.newRadio(customnickDiv, "Use a random nickname, e.g. qwebirc12883.", "nick", true);
+    this.choosenick = this.newRadio(customnickDiv, "Make the user choose a nickname.", "nick");
+    this.presetnick = this.newRadio(customnickDiv, "Use a preset nickname of your choice.", "nick");
+    
+    var promptdiv = new Element("form");
+    this.connectdialog = this.newStep({
+      "title": "Display connect dialog?",
+      "first": "Do you want the user to be shown the connect dialog (with the values you have supplied pre-entered) or just a connect confirmation?",
+      middle: promptdiv,
+      "hint": "You need to display the dialog if you want the user to be able to set their nickname before connecting.",
+    });
+    
+    this.connectdialogr = this.newRadio(promptdiv, "Show the connect dialog.", "prompt", true);
+    var autoconnect = this.newRadio(promptdiv, "Connect without displaying the dialog.", "prompt");
+    
+    this.nicknameBox = new Element("input");
+    this.nickname = this.newStep({
+      "title": "Set nickname",
+      "first": "Enter the nickname you would like the client to use by default:",
+      "premove": function() {
+        if(this.nicknameBox.value == "") {
+          alert("You must supply a nickname.");
+          this.nicknameBox.focus();
+          return false;
+        }
+        return true;
+      }.bind(this),
+      middle: this.nicknameBox
+    }).addEvent("show", af);
+
+    var codeDiv = new Element("div");
+    this.finish = this.newStep({
+      "title": "Finished!",
+      "first": "Your custom link is:",
+      middle: codeDiv
+    }).addEvent("show", function() {
+      var alink = new Element("a");
+      var abox = new Element("input");
+      var url = this.generateURL();
+      
+      alink.href = url;
+      alink.appendChild(document.createTextNode(url));
+      abox.value = "<iframe src=\"" + url + "\"></iframe>";
+      
+      var mBox = [
+        alink,
+        new Element("br"), new Element("br"),
+        document.createTextNode("You can embed this into your page with the following code:"),
+        new Element("br"),
+        abox
+      ];
+
+      while(codeDiv.childNodes.length > 0)
+        codeDiv.removeChild(codeDiv.childNodes[0]);
+        
+      mBox.forEach(function(x) {
+        codeDiv.appendChild(x);
+      });
+    }.bind(this));
+
+    this.updateSteps();
+    this.step = 0;
+    
+    this.showStep();
+  },
+  updateSteps: function() {
+    this.steps = [this.welcome, this.customnick];
+    
+    if(this.presetnick.checked)
+      this.steps.push(this.nickname);
+      
+    this.steps.push(this.chans);
+    if(!this.choosenick.checked)
+      this.steps.push(this.connectdialog);
+    
+    this.steps.push(this.finish);
+  },
+  showStep: function() {
+    this.backBtn.disabled = !(this.step > 0);
+    
+    this.nextBtn.value = (this.step >= this.steps.length - 1)?"Close":"Next >";
+      
+    this.steps[this.step].show();
+  },
+  next: function() {
+    var pm = this.steps[this.step].options.premove;
+    
+    if(pm && !pm())
+      return;
+      
+    this.updateSteps();
+    if(this.step >= this.steps.length - 1) {
+      this.close();
+      return;
+    }
+    this.step = this.step + 1;
+    this.showStep();
+  },
+  close: function() {
+    this.fireEvent("close");
+  },
+  back: function() {
+    if(this.step <= 0)
+      return;
+
+      this.step = this.step - 1;
+    this.showStep();
+  },
+  generateURL: function() {
+    var chans = this.chanBox.value;
+    var nick = this.nicknameBox.value;
+    var connectdialog = this.connectdialogr.checked || this.choosenick.checked;
+    
+    var URL = [];
+    if(this.presetnick.checked) {
+      URL.push("nick=" + escape(nick));
+    } else if(this.choosenick.checked) {
+      URL.push("nick=");
+    }
+    
+    if(chans) {
+      var d = chans.split(",");
+      var d2 = [];
+      
+      /* WTB map */
+      d.forEach(function(x) {
+        if(x.charAt(0) == '#')
+          x = x.substring(1);
+          
+        d2.push(x);
+      });
+      
+      URL.push("channels=" + escape(d2.join(",")));
+    }
+    
+    if(connectdialog)
+      URL.push("prompt=1");
+
+    return this.options.baseURL + "?" + URL.join("&");
+  }
+});
index c52d91816030174df52b1b3431cc182ad1b86074..edc6708757059cbcda893a0788b187f4ecbec6ab 100644 (file)
@@ -27,6 +27,7 @@
   <script type="text/javascript" src="js/debug/ui/url.js"></script>
   <script type="text/javascript" src="js/debug/ui/theme.js"></script>
   <script type="text/javascript" src="js/debug/ui/genericlogin.js"></script>
+  <script type="text/javascript" src="js/debug/ui/connectwizard.js"></script>
   <script type="text/javascript" src="js/debug/ui/mochaui.js"></script>
   <script type="text/javascript" src="js/debug/qwebircinterface.js"></script>
   <script type="text/javascript">
index 7d9b2b3cd2f5e7213dec797e123c4310b1f3cf0f..473b1314e1a30d6bddae70788fca50a9ce8a4811 100644 (file)
@@ -21,6 +21,7 @@
   <script type="text/javascript" src="js/debug/ui/url.js"></script>
   <script type="text/javascript" src="js/debug/ui/theme.js"></script>
   <script type="text/javascript" src="js/debug/ui/genericlogin.js"></script>
+  <script type="text/javascript" src="js/debug/ui/connectwizard.js"></script>
   <script type="text/javascript" src="js/debug/ui/qui.js"></script>
   <script type="text/javascript" src="js/debug/qwebircinterface.js"></script>
   <script type="text/javascript">
index 1880182be1536b36741d1fda733cfd65aef1c581..76df8d2fcdb852dd0809b668e7c2616f8dae6415 100644 (file)
@@ -20,6 +20,7 @@
   <script type="text/javascript" src="js/debug/ui/url.js"></script>
   <script type="text/javascript" src="js/debug/ui/theme.js"></script>
   <script type="text/javascript" src="js/debug/ui/genericlogin.js"></script>
+  <script type="text/javascript" src="js/debug/ui/connectwizard.js"></script>
   <script type="text/javascript" src="js/debug/ui/swmlayout.js"></script>
   <script type="text/javascript" src="js/debug/ui/swmui.js"></script>
   <script type="text/javascript" src="js/debug/qwebircinterface.js"></script>
index ce8dc22440aa1df402175b0e235c47a6c57aa823..bb572bf47359ef91e76a3613da7761993a5e6542 100644 (file)
@@ -20,6 +20,7 @@
   <script type="text/javascript" src="js/debug/ui/url.js"></script>
   <script type="text/javascript" src="js/debug/ui/theme.js"></script>
   <script type="text/javascript" src="js/debug/ui/genericlogin.js"></script>
+  <script type="text/javascript" src="js/debug/ui/connectwizard.js"></script>
   <script type="text/javascript" src="js/debug/ui/uglyui.js"></script>
   <script type="text/javascript" src="js/debug/qwebircinterface.js"></script>
   <script type="text/javascript">