Continue working on rewriting stuff
This commit is contained in:
parent
c7b3adbed1
commit
b5ec80d02f
72
www/assets/js/data.js
Normal file
72
www/assets/js/data.js
Normal file
|
@ -0,0 +1,72 @@
|
|||
var CLIENT = {
|
||||
rank: -1,
|
||||
name: "",
|
||||
logged_in: false,
|
||||
profile: {
|
||||
image: "",
|
||||
text: ""
|
||||
}
|
||||
};
|
||||
|
||||
var CHANNEL = {
|
||||
opts: {},
|
||||
openqueue: false,
|
||||
perms: {},
|
||||
};
|
||||
|
||||
var PLAYER = false;
|
||||
var VWIDTH = $("#ytapiplayer").parent().css("width").replace("px", "");
|
||||
var VHEIGHT = ""+parseInt(parseInt(VWIDTH) * 9 / 16);
|
||||
var POSITION = -1;
|
||||
var socket;
|
||||
var IGNORED = [];
|
||||
var CHATHIST = [];
|
||||
var CHATHISTIDX = 0;
|
||||
var SCROLLCHAT = true;
|
||||
var LASTCHATNAME = "";
|
||||
var LASTCHATTIME = 0;
|
||||
var FOCUSED = true;
|
||||
var PAGETITLE = "CyTube";
|
||||
var TITLE_BLINK;
|
||||
var KICKED = false;
|
||||
var NAME = readCookie("cytube_uname");
|
||||
var SESSION = readCookie("cytube_session");
|
||||
|
||||
function getOrDefault(k, def) {
|
||||
var v = localStorage.getItem(k);
|
||||
if(v === null)
|
||||
return def;
|
||||
if(v === "true")
|
||||
return true;
|
||||
if(v === "false")
|
||||
return false;
|
||||
if(v.match(/[0-9]+/))
|
||||
return parseInt(v);
|
||||
if(v.match(/[0-9\.]+/))
|
||||
return parseFloat(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
var USEROPTS = {
|
||||
theme : getOrDefault("theme", "default"),
|
||||
css : getOrDefault("css", ""),
|
||||
layout : getOrDefault("layout", "default"),
|
||||
synch : getOrDefault("synch", true),
|
||||
hidevid : getOrDefault("hidevid", false),
|
||||
show_timestamps : getOrDefault("show_timestamps", true),
|
||||
modhat : getOrDefault("modhat", false),
|
||||
blink_title : getOrDefault("blink_title", false),
|
||||
sync_accuracy : getOrDefault("sync_accuracy", 2),
|
||||
chatbtn : getOrDefault("chatbtn", false),
|
||||
altsocket : getOrDefault("altsocket", false)
|
||||
};
|
||||
|
||||
var Rank = {
|
||||
Guest: 0,
|
||||
Member: 1,
|
||||
Leader: 1.5,
|
||||
Moderator: 2,
|
||||
Admin: 3,
|
||||
Owner: 10,
|
||||
Siteadmin: 255
|
||||
};
|
|
@ -14,8 +14,136 @@ function generateToggle(chevron, div) {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
/* setup show/hide toggles */
|
||||
generateToggle("#usercountwrap", "#userlist");
|
||||
generateToggle("#librarytoggle", "#librarywrap");
|
||||
generateToggle("#userpltoggle", "#userplaylistwrap");
|
||||
generateToggle("#playlisttoggle", "#playlist_controls");
|
||||
|
||||
/* navbar stuff */
|
||||
$("#optlink").click(showOptionsMenu);
|
||||
$("#guestlogin").click(function() {
|
||||
socket && socket.emit("login", {
|
||||
name: $("#guestname").val(),
|
||||
});
|
||||
});
|
||||
$("#login").click(showLoginMenu);
|
||||
$("#logout").click(function() {
|
||||
eraseCookie("cytube_name");
|
||||
eraseCookie("cytube_session");
|
||||
document.ocation.reload(true);
|
||||
});
|
||||
|
||||
/* chatbox */
|
||||
$("#chatline").keyDown(function(ev) {
|
||||
if(ev.keyCode == 13) {
|
||||
var msg = $("#chatline").val();
|
||||
if(msg.trim()) {
|
||||
if(USEROPTS.modhat && CLIENT.rank >= Rank.Moderator) {
|
||||
msg = "/m " + msg;
|
||||
}
|
||||
socket.emit("chatMsg", {
|
||||
msg: msg
|
||||
});
|
||||
CHATHIST.push($("#chatline").val());
|
||||
CHATLISTIDX = CHATHIST.length;
|
||||
$("#chatline").val("");
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if(ev.keyCode == 9) {
|
||||
var words = $("#chatline").val().split(" ");
|
||||
var current = words[words.length - 1].toLowerCase();
|
||||
var users = $("#userlist").children();
|
||||
var match = null;
|
||||
for(var i = 0; i < users.length; i++) {
|
||||
var name = users[i].children[1].innerHTML.toLowerCase();
|
||||
if(name.indexOf(current) == 0 && match == null) {
|
||||
match = users[i].children[1].innerHTML;
|
||||
}
|
||||
else if(name.indexOf(current) == 0) {
|
||||
match = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(match != null) {
|
||||
words[words.length - 1] = match;
|
||||
if(words.length == 1)
|
||||
words[0] += ": ";
|
||||
else
|
||||
words[words.length - 1] += " ";
|
||||
$("#chatline").val(words.join(" "));
|
||||
}
|
||||
ev.preventDefault();
|
||||
return false;
|
||||
}
|
||||
else if(ev.keyCode == 38) {
|
||||
if(CHATHISTIDX == CHATHIST.length) {
|
||||
CHATHIST.push($("#chatline").val());
|
||||
}
|
||||
if(CHATHISTIDX > 0) {
|
||||
CHATHISTIDX--;
|
||||
$("#chatline").val(CHATHIST[CHATHISTIDX]);
|
||||
}
|
||||
|
||||
ev.preventDefault();
|
||||
return false;
|
||||
}
|
||||
else if(ev.keyCode == 40) {
|
||||
if(CHATHISTIDX < CHATHIST.length - 1) {
|
||||
CHATHISTIDX++;
|
||||
$("#chatline").val(CHATHIST[CHATHISTIDX]);
|
||||
}
|
||||
|
||||
ev.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/* poll controls */
|
||||
$("#newpollbtn").click(showPollMenu);
|
||||
|
||||
/* search controls */
|
||||
$("#library_search").click(function() {
|
||||
socket.emit("searchMedia", {
|
||||
source: "library",
|
||||
query: $("#library_query").val().toLowerCase()
|
||||
});
|
||||
});
|
||||
|
||||
$("#library_query").keydown(function(ev) {
|
||||
if(ev.keyCode == 13) {
|
||||
socket.emit("searchMedia", {
|
||||
source: "library",
|
||||
query: $("#library_query").val().toLowerCase()
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$("#youtube_search").click(function() {
|
||||
socket.emit("searchMedia", {
|
||||
source: "yt",
|
||||
query: $("#library_query").val().toLowerCase()
|
||||
});
|
||||
});
|
||||
|
||||
/* user playlists */
|
||||
|
||||
$("#userpltoggle").click(function() {
|
||||
socket.emit("listPlaylists");
|
||||
});
|
||||
|
||||
$("#userpl_save").click(function() {
|
||||
if($("#userpl_name").val().trim() == "") {
|
||||
makeAlert("Invalid Name", "Playlist name cannot be empty", "alert-error")
|
||||
.addClass("span12")
|
||||
.insertAfter($("#userpl_save").parent());
|
||||
return;
|
||||
}
|
||||
socket.emit("savePlaylist", {
|
||||
name: $("#userpl_name").val()
|
||||
});
|
||||
});
|
||||
|
||||
/* playlist controls */
|
||||
|
|
|
@ -89,6 +89,8 @@
|
|||
<div class="row-fluid" id="leftpane-inner">
|
||||
<!-- poll container -->
|
||||
<div class="span12" id="pollwrap">
|
||||
<!-- new poll controls -->
|
||||
<button class="btn btn-primary btn-small" id="newpollbtn">New Poll</button>
|
||||
</div>
|
||||
<!-- library search -->
|
||||
<div class="span12 pointer" id="librarytoggle">
|
||||
|
@ -167,6 +169,7 @@
|
|||
|
||||
<script src="./assets/js/jquery.js"></script>
|
||||
<!-- My Javascript -->
|
||||
<script src="./assets/js/data.js"></script>
|
||||
<script src="./assets/js/ui.js"></script>
|
||||
<!--
|
||||
<script src="./assets/js/iourl.js"></script>
|
||||
|
|
Loading…
Reference in a new issue