Removed data attributes
This commit is contained in:
parent
15ab7e6f13
commit
6e03377d7d
@ -56,9 +56,9 @@
|
|||||||
|
|
||||||
<script type="text/html" id="network">
|
<script type="text/html" id="network">
|
||||||
{{#networks}}
|
{{#networks}}
|
||||||
<div class="network list-group" data-id="{{id}}" data-nick="{{nick}}">
|
<div id="network-{{id}}" class="network list-group">
|
||||||
{{#each channels}}
|
{{#each channels}}
|
||||||
<a href="{{name}}" class="channel list-group-item" data-id="{{id}}" data-name="{{name}}">
|
<a href="{{name}}" id="channel-{{id}}" class="channel list-group-item">
|
||||||
<span class="badge pull-right"></span>
|
<span class="badge pull-right"></span>
|
||||||
{{name}}
|
{{name}}
|
||||||
</a>
|
</a>
|
||||||
@ -69,7 +69,7 @@
|
|||||||
|
|
||||||
<script type="text/html" id="channel">
|
<script type="text/html" id="channel">
|
||||||
{{#channels}}
|
{{#channels}}
|
||||||
<a href="{{name}}" class="channel list-group-item" data-id="{{id}}" data-name="{{name}}">
|
<a href="{{name}}" id="channel-{{id}}" class="channel list-group-item">
|
||||||
<span class="badge pull-right"></span>
|
<span class="badge pull-right"></span>
|
||||||
{{name}}
|
{{name}}
|
||||||
</a>
|
</a>
|
||||||
@ -78,7 +78,7 @@
|
|||||||
|
|
||||||
<script type="text/html" id="window">
|
<script type="text/html" id="window">
|
||||||
{{#channels}}
|
{{#channels}}
|
||||||
<div class="window {{type}}" data-id="{{id}}">
|
<div id="window-{{id}}" class="window {{type}}">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<div class="toggle">
|
<div class="toggle">
|
||||||
<a href="#" class="left">Channels</a>
|
<a href="#" class="left">Channels</a>
|
||||||
|
@ -16,8 +16,6 @@ $(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function event(type, json) {
|
function event(type, json) {
|
||||||
console.log(json);
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
||||||
case "network":
|
case "network":
|
||||||
@ -40,19 +38,16 @@ $(function() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "channel":
|
case "channel":
|
||||||
var target = json.target;
|
var id = json.data.id;
|
||||||
|
console.log(json.data);
|
||||||
if (json.action == "remove") {
|
if (json.action == "remove") {
|
||||||
$("[data-id='" + json.data.id + "']").remove();
|
$("#channel-" + id + ", #window-" + id).remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var network = sidebar
|
sidebar.find(".channel").removeClass("active");
|
||||||
.find(".network")
|
|
||||||
.find(".channel")
|
|
||||||
.removeClass("active")
|
|
||||||
.end();
|
|
||||||
|
|
||||||
network = network.filter("[data-id='" + json.target + "']").append(
|
$("#network-" + json.target).append(
|
||||||
render("#channel", {channels: json.data})
|
render("#channel", {channels: json.data})
|
||||||
).find(".channel")
|
).find(".channel")
|
||||||
.last()
|
.last()
|
||||||
@ -70,7 +65,7 @@ $(function() {
|
|||||||
case "user":
|
case "user":
|
||||||
var target;
|
var target;
|
||||||
if (typeof json.target !== "undefined") {
|
if (typeof json.target !== "undefined") {
|
||||||
target = chat.find(".window[data-id='" + json.target + "']");
|
target = chat.find("#window-" + json.target);
|
||||||
}
|
}
|
||||||
|
|
||||||
target = target.find(".users");
|
target = target.find(".users");
|
||||||
@ -80,7 +75,7 @@ $(function() {
|
|||||||
case "message":
|
case "message":
|
||||||
var target;
|
var target;
|
||||||
if (typeof json.target !== "undefined") {
|
if (typeof json.target !== "undefined") {
|
||||||
target = chat.find(".window[data-id='" + json.target + "']");
|
target = $("#window-" + json.target);
|
||||||
}
|
}
|
||||||
|
|
||||||
var message = json.data;
|
var message = json.data;
|
||||||
@ -104,29 +99,24 @@ $(function() {
|
|||||||
.find(".badge")
|
.find(".badge")
|
||||||
.html("")
|
.html("")
|
||||||
.end();
|
.end();
|
||||||
var id = item.data("id");
|
$("#window-" + item.attr("id").replace("channel-", ""))
|
||||||
chat.find(".window[data-id='" + id + "']")
|
|
||||||
.bringToTop();
|
.bringToTop();
|
||||||
});
|
});
|
||||||
|
|
||||||
sidebar.find("input[type=checkbox]").each(function() {
|
sidebar.find("input[type=checkbox]").each(function() {
|
||||||
var input = $(this);
|
var input = $(this);
|
||||||
var value = input.val();
|
var value = input.val();
|
||||||
|
|
||||||
var checked = true;
|
var checked = true;
|
||||||
if (($.cookie("hidden") || []).indexOf(value) !== -1) {
|
if (($.cookie("hidden") || []).indexOf(value) !== -1) {
|
||||||
checked = false;
|
checked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
input.prop("checked", checked)
|
input.prop("checked", checked)
|
||||||
.wrap("<label>")
|
.wrap("<label>")
|
||||||
.parent()
|
.parent()
|
||||||
.append(value);
|
.append(value);
|
||||||
|
|
||||||
if (checked) {
|
if (checked) {
|
||||||
chat.addClass("show-" + value);
|
chat.addClass("show-" + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
input.on("change", function() {
|
input.on("change", function() {
|
||||||
var hidden = $.cookie("hidden") || "";
|
var hidden = $.cookie("hidden") || "";
|
||||||
if (input.prop("checked")) {
|
if (input.prop("checked")) {
|
||||||
@ -134,10 +124,7 @@ $(function() {
|
|||||||
} else {
|
} else {
|
||||||
hidden += value;
|
hidden += value;
|
||||||
}
|
}
|
||||||
|
$.cookie("hidden", hidden); // Save the cookie with the new values.
|
||||||
// Save the cookie with the new values.
|
|
||||||
$.cookie("hidden", hidden);
|
|
||||||
|
|
||||||
chat.toggleClass(
|
chat.toggleClass(
|
||||||
"show-" + value,
|
"show-" + value,
|
||||||
input.prop("checked")
|
input.prop("checked")
|
||||||
@ -145,36 +132,6 @@ $(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
chat.on("click touchstart", ".toggle a", function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
$("#viewport").toggleClass($(this).attr("class"));
|
|
||||||
});
|
|
||||||
|
|
||||||
chat.on("submit", "form", function() {
|
|
||||||
var input = $(this).find(".input");
|
|
||||||
var text = input.val();
|
|
||||||
if (text != "") {
|
|
||||||
input.val("");
|
|
||||||
socket.emit("input", {
|
|
||||||
id: input.data("target"),
|
|
||||||
text: text
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
chat.on("focus", "input[type=text]", function() {
|
|
||||||
$(this).closest(".window").find(".messages").scrollToBottom();
|
|
||||||
});
|
|
||||||
|
|
||||||
chat.on("click", ".close", function() {
|
|
||||||
var btn = $(this);
|
|
||||||
btn.prop("disabled", true);
|
|
||||||
socket.emit("input", {
|
|
||||||
id: btn.closest(".window").data("id"),
|
|
||||||
text: "/LEAVE"
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
chat.on("append", ".messages", function(e) {
|
chat.on("append", ".messages", function(e) {
|
||||||
var item = $(this);
|
var item = $(this);
|
||||||
var last = item.find(".message:last");
|
var last = item.find(".message:last");
|
||||||
@ -182,39 +139,42 @@ $(function() {
|
|||||||
if (type && !chat.hasClass("show-" + type)) {
|
if (type && !chat.hasClass("show-" + type)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var id = item.parent()
|
||||||
var id = item.parent().data("id");
|
.attr("id")
|
||||||
|
.replace("window-", "");
|
||||||
var badge = sidebar
|
var badge = sidebar
|
||||||
.find(".channel[data-id='" + id + "']:not(.active)")
|
.find("#channel-" + id + ":not(.active)")
|
||||||
.find(".badge");
|
.find(".badge");
|
||||||
|
|
||||||
var num = (parseInt(badge.html()) + 1) || "1";
|
var num = (parseInt(badge.html()) + 1) || "1";
|
||||||
badge.html(num);
|
badge.html(num);
|
||||||
});
|
});
|
||||||
|
|
||||||
chat.on("click", ".user", function(e) {
|
chat.on("click touchstart", ".toggle a", function(e) {
|
||||||
e.preventDefault();
|
$("#viewport").toggleClass($(this).attr("class"));
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
chat.on("dblclick", ".user", function() {
|
chat.on("submit", "form", function() {
|
||||||
var user = $(this);
|
var input = $(this).find(".input");
|
||||||
var id = user.closest(".window").data("id");
|
var text = input.val();
|
||||||
var name = user.attr("href");
|
if (text == "") {
|
||||||
|
return false;
|
||||||
var channel = sidebar
|
|
||||||
.find(".channel[data-id='" + id + "']")
|
|
||||||
.siblings(".channel[data-name='" + name + "']");
|
|
||||||
if (channel.size() != 0) {
|
|
||||||
channel.trigger("click");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
input.val("");
|
||||||
socket.emit("input", {
|
socket.emit("input", {
|
||||||
id: id,
|
id: input.data("target"),
|
||||||
text: "/QUERY " + name
|
text: text
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
chat.on("focus", "input[type=text]", function() {
|
||||||
|
$(this).closest(".window").find(".messages").scrollToBottom();
|
||||||
|
});
|
||||||
|
|
||||||
|
chat.on("click", ".user", function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
var highest = 1;
|
var highest = 1;
|
||||||
$.fn.bringToTop = function() {
|
$.fn.bringToTop = function() {
|
||||||
return this.css('z-index', highest++)
|
return this.css('z-index', highest++)
|
||||||
|
Loading…
Reference in New Issue
Block a user