]>
jfr.im git - irc/quakenet/qwebirc.git/blob - static/js/ui/uglyui.js
1 function UglyUI(parent
, theme
) {
5 var tabs
= new Element("div", {"styles": { "border": "1px solid black", "padding": "4px", "font-family": "Lucida Console" } });
6 parent
.appendChild(tabs
);
9 var window
= new Element("div", {"styles": { "border": "1px solid black", "margin": "2px 0px 0px 0px", "height": "480px" } });
10 parent
.appendChild(window
);
12 var form
= new Element("form");
13 var inputbox
= new Element("input", {"styles": { "width": "400px", "border": "1px solid black", "margin": "2px 0px 0px 0px"} });
15 form
.addEvent("submit", function(e
) {
18 self
.send(inputbox
.value
);
21 parent
.appendChild(form
);
22 form
.appendChild(inputbox
);
25 this.newWindow = function(windowname
, ischannel
, displayname
) {
26 var o
= tabhash
[windowname
];
30 var container
= new Element("div", { "styles": { "display": "none", "font-family": "Lucida Console" } });
31 window
.appendChild(container
);
37 nicklist
= new Element("div", {"styles": { "border-left": "1px solid black", "width": "125px", "float": "right", "height": "480px", "clear": "both", "overflow": "auto", "background": "white"} });
38 container
.appendChild(nicklist
);
41 var x
= new Element("div", {"styles": { "height": "480px" }});
42 container
.appendChild(x
);
45 topic
= new Element("div", {"styles": { "background": "#fef", "height": "20px" } });
49 var e
= new Element("div", {"styles": { "height": "460px", "overflow": "auto", "word-wrap": "break-word" }});
52 var tab
= new Element("span", {"styles": { "border": "1px black solid", "padding": "2px", "cursor": "default", "margin-right": "2px", "background": "#eee", "clear": "both" } });
54 tab
.appendText(displayname
);
56 tab
.appendText(windowname
);
58 tab
.addEvent("click", function() {
59 self
.selectTab(windowname
);
61 tabs
.appendChild(tab
);
63 if(windowname
!= "") {
64 var tabclose
= new Element("span", {"styles": { "border": "1px black solid", "margin-left": "5px", "padding": "2px", "font-size": "0.5em" } });
65 tabclose
.addEvent("click", function() {
67 self
.send("/PART " + windowname
);
69 self
.closeWindow(windowname
);
71 tabclose
.setText("X");
72 tab
.appendChild(tabclose
);
74 tabhash
[windowname
] = { "name": windowname
, "container": container
, "tab": tab
, "element": e
, "lastcolour": false, "nicklist": nicklist
, "topic": topic
, "ischannel": ischannel
};
76 return tabhash
[windowname
];
79 this.getWindow = function(windowname
) {
80 return tabhash
[windowname
];
83 this.updateNickList = function(windowname
, nicks
) {
84 var w
= tabhash
[windowname
];
90 n
.removeChild(n
.firstChild
);
92 forEach(nicks
, function(nick
) {
93 var e
= document
.createElement("div");
95 e
.appendChild(document
.createTextNode(nick
));
99 this.updateTopic = function(windowname
, topic
) {
100 var w
= tabhash
[windowname
];
107 t
.removeChild(t
.firstChild
);
112 this.selectTab = function(windowname
) {
113 var w
= tabhash
[windowname
];
117 for(var i
in tabhash
) {
119 o
.container
.setStyle("display", "none");
120 o
.tab
.setStyle("background", "#eee");
123 w
.container
.setStyle("display", "block");
124 w
.tab
.setStyle("background", "#dff");
125 w
.tab
.setStyle("color", "");
126 self
.active
= windowname
;
129 this.newLine = function(windowname
, type
, line
, colour
) {
130 var window
= tabhash
[windowname
];
132 if(windowname
== false) {
133 windowname
= self
.active
;
134 window
= tabhash
[self
.active
];
136 window
= tabhash
[""];
142 window
= window
.element
;
146 } else if(wx
.lastcolour
) {
152 var e
= new Element("div", { "styles": { "background": c
} });
154 line
= theme
.message(type
, line
);
158 wx
.lastcolour
= !wx
.lastcolour
;
159 window
.appendChild(e
);
161 if(windowname
!= self
.active
)
162 wx
.tab
.setStyle("color", "red");
165 this.getActiveWindow = function() {
166 return tabhash
[self
.active
];
169 this.closeWindow = function(windowname
) {
170 var w
= tabhash
[windowname
];
174 window
.removeChild(w
.container
);
175 tabs
.removeChild(w
.tab
);
177 if(self
.active
== windowname
)
180 delete tabhash
[windowname
];
183 this.errorMessage = function(message
) {
184 self
.newLine(false, "", message
, "red");