]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/panes/feedback.js
1 qwebirc
.ui
.FeedbackPane
= new Class({
3 initialize: function(parent
) {
4 this.textboxVisible
= false;
5 var delayfn = function() { parent
.set("html", "<div class=\"loading\">Loading. . .</div>"); };
6 var cb
= delayfn
.delay(500);
8 this.addEvent("select", this.onSelect
);
10 var r
= new Request
.HTML({url: "panes/feedback.html", update: parent
, onSuccess: function() {
12 parent
.getElement("input[class=close]").addEvent("click", function() {
13 this.fireEvent("close");
15 parent
.getElement("input[class=close2]").addEvent("click", function() {
16 this.fireEvent("close");
19 var textbox
= parent
.getElement("textarea");
20 this.textbox
= textbox
;
21 parent
.getElement("input[class=submitfeedback]").addEvent("click", function() {
22 this.sendFeedback(parent
, textbox
, textbox
.value
);
25 this.textboxVisible
= true;
30 onSelect: function() {
31 if(this.textboxVisible
)
34 sendFeedback: function(parent
, textbox
, text
) {
35 text
= text
.replace(/^\s*/, "").replace(/\s*$/, "");
36 var mainText
= parent
.getElement("p[class=maintext]");
38 if(text
.length
< 25) {
39 mainText
.set("text", "I don't suppose you could enter a little bit more? Thanks!");
44 this.textboxVisible
= false;
45 var mainBody
= parent
.getElement("div[class=enterarea]");
46 mainBody
.setStyle("display", "none");
48 var messageBody
= parent
.getElement("div[class=messagearea]");
49 var messageText
= parent
.getElement("p[class=messagetext]");
50 var messageClose
= parent
.getElement("input[class=close2]");
52 messageText
.set("text", "Submitting. . .");
53 messageBody
.setStyle("display", "");
55 /* basic checksum to stop really lame kiddies spamming */
57 var esctext
= encodeURIComponent(text
);
58 for(var i
=0;i
<text
.length
;i
++)
59 checksum
= ((checksum
+ 1) % 256) ^ (text
.charCodeAt(i
) % 256);
61 var r
= new Request({url: "/feedback", onSuccess: function() {
62 messageText
.set("text", "Submitted successfully, thanks for the feedback!");
63 messageClose
.setStyle("display", "");
64 }, onFailure: function() {
65 this.textboxVisible
= true;
66 messageBody
.setStyle("display", "none");
67 mainBody
.setStyle("display", "");
68 mainText
.set("text", "Looks like something went wrong submitting :(");
69 }.bind(this)}).send("feedback=" + text
+ "&c=" + checksum
);