]>
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" } });
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" } });
65 tabclose
.addEvent("click", function() {
67 self
.send("PART " + windowname
);
68 self
.closeWindow(windowname
);
70 tabclose
.setText("X");
71 tab
.appendChild(tabclose
);
73 tabhash
[windowname
] = { "container": container
, "tab": tab
, "element": e
, "lastcolour": false, "nicklist": nicklist
, "topic": topic
};
75 return tabhash
[windowname
];
78 this.updateNickList = function(windowname
, nicks
) {
79 var w
= tabhash
[windowname
];
85 n
.removeChild(n
.firstChild
);
87 forEach(nicks
, function(nick
) {
88 var e
= document
.createElement("div");
90 e
.appendChild(document
.createTextNode(nick
));
94 this.updateTopic = function(windowname
, topic
) {
95 var w
= tabhash
[windowname
];
102 t
.removeChild(t
.firstChild
);
107 this.selectTab = function(windowname
) {
108 for(var i
in tabhash
) {
110 o
.container
.setStyle("display", "none");
111 o
.tab
.setStyle("background", "#eee");
114 tabhash
[windowname
].container
.setStyle("display", "block");
115 tabhash
[windowname
].tab
.setStyle("background", "#dff");
116 tabhash
[windowname
].tab
.setStyle("color", "");
117 self
.active
= windowname
;
120 this.newLine = function(windowname
, type
, line
, colour
) {
121 var window
= tabhash
[windowname
];
123 window
= tabhash
[""];
128 window
= window
.element
;
132 } else if(wx
.lastcolour
) {
138 var e
= new Element("div", { "styles": { "background": c
} });
140 line
= theme
.message(type
, line
);
144 wx
.lastcolour
= !wx
.lastcolour
;
145 window
.appendChild(e
);
147 if(windowname
!= self
.active
)
148 wx
.tab
.setStyle("color", "red");
151 this.closeWindow = function(windowname
) {
152 var w
= tabhash
[windowname
];
156 window
.removeChild(w
.container
);
157 tabs
.removeChild(w
.tab
);
160 delete tabhash
[windowname
];