From ef51b60c6481254d88c5fc3c34f4127b7f881a58 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 26 Nov 2012 12:05:40 -0500 Subject: Frontend static/ folder --- frontend/static/js/avatar.js | 236 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 frontend/static/js/avatar.js (limited to 'frontend/static/js/avatar.js') diff --git a/frontend/static/js/avatar.js b/frontend/static/js/avatar.js new file mode 100644 index 0000000..11d39d4 --- /dev/null +++ b/frontend/static/js/avatar.js @@ -0,0 +1,236 @@ +var Avatar = + { + orientation: true, + loaded: false, + } +Room.loadCallback = function () { setTimeout(Viewport.fullscreenOn, 500) } +Chat.store = function (lines) + { + var newVideos = [] + var newChat = [] + var postponeScroll = false + for (i in lines) + { + if (! lines[i]) + continue + row = lines[i].split("\t") + if (row[0] === 'VIDEO') + { + row.shift() + if (row[0] in Chat.oldVideo) + continue + Chat.oldVideo[row[0]] = row + Playlist.enqueueOldVideoFormat([row]) + } + else if (row[0] === 'ROOM') + { + Room.updateSetting(row[1],row[2]) + } + else if (row[0] === 'LIKE') + { + username = row[1] + Like.enqueue(username) + } + else if (row[0] === 'CAM') + { + VideoChat.updateCount(row[1]) + } + else + { + // 0 id 1 date 2 user 3 msg + if (row[0] in Chat.oldChat) + continue + Chat.oldChat[row[0]] = row + var c = Chat.parse(row) + if (c.indexOf("> POSTPONING") + } + if (row[2] === Auth.username && $.md5(row[3]) in Chat.messages) + continue + newChat.push(c) + } + } + if (newChat.length) + { + if (Avatar.loaded) + { + $("#chat").append(newChat.join("")) + } + else + { + Avatar.loaded = true + $("#chat").append(newChat[newChat.length-1]) + } + if (postponeScroll) + setTimeout('d.scrollToBottom("#chat")', 2000) + else + d.scrollToBottom("#chat") + } + } +Chat.say = function () + { + d.act("+ sent message") + var msg = d.sanitize( $("#chat-message").val() ) + $("#chat-message").val("") + if (! msg) return + if (msg === "debug=1") { $("#msg").show(); d.scrollToBottom("#msg"); return } + if (msg === "debug=0") { $("#msg").hide(); return } + if (msg === "poll=0") { d.error("+ DISABLED POLLING"); clearTimeout(Chat.timer); return} + if (msg.indexOf("bg=") === 0) { Room.setBg( msg.split("=",2)[1] ); return } + var hash = $.md5(msg) + Chat.messages[hash] = true + var newrow = [0, 0, Auth.username, msg] + // var newdiv = Chat.parse(newrow) + // $("#chat").append(newdiv) + // if (newdiv.indexOf("'+txt+' ' + } + else if (word.indexOf("youtube.com/v/") !== -1) + { + var index = word.indexOf("/v/") + var ytid = "youtube_"+word.substr(index+3,11) + var txt + if (ytid in Player.videos) + txt = Player.videos[ytid].title + else + txt = word + s += ''+txt+' ' + } + else if (word.indexOf("youtu.be") !== -1) + { + var ytid = "youtube_"+word.substr(16,11) + var txt + if (ytid in Player.videos) + txt = Player.videos[ytid].title + else + txt = word + s += ''+txt+' ' + } + // http://www.youtube.com/user/ahchachachacha#p/f/28/1GSBekxLR1E + else if (word.indexOf("youtube.com/user") !== -1) + { + var ytid = "youtube_"+word.substr(-11) + var txt + if (ytid in Player.videos) + txt = Player.videos[ytid].title + else + txt = word + s += ''+txt+' ' + } + else if (word.indexOf("vimeo.com") !== -1) + { + var vimeoid = word.replace(VIMEOregexp, "vimeo_$3") + if (vimeoid in Player.videos) + txt = Player.videos[vimeoid].title + else + txt = word + s += ''+txt+' ' + } + else if (word.indexOf("soundcloud.com") !== -1) + { + var scid = "soundcloud_" + $.md5(word) + if (scid in Player.videos) + txt = Player.videos[scid].title + else + txt = word + s += ''+txt+' ' + } + else if (word.indexOf(".jpeg") !== -1 || + word.indexOf(".JPG") !== -1 || + word.indexOf(".GIF") !== -1 || + word.indexOf(".PNG") !== -1 || + word.indexOf(".JPEG") !== -1 || + word.indexOf(".jpg") !== -1 || + word.indexOf(".gif") !== -1 || + word.indexOf(".png") !== -1) + { + s += '' + } + else if (word.indexOf("scannerjammer.com/profile") !== -1) + { + var username = word.substr( word.indexOf("profile")+8 ).replace("/","") + s += 'ScannerJammer: '+username+'' + } + else + { + var poffset = word.indexOf('//') + var linktext = word.substr(poffset+2, word.indexOf('/', poffset+2)).replace("www.","") + s += ''+linktext+' ' + } + } + else if (word.indexOf(".com") !== -1 || + word.indexOf(".net") !== -1 || + word.indexOf(".org") !== -1 || + word.indexOf(".us") !== -1 || + word.indexOf(".nu") !== -1 || + word.indexOf(".uk") !== -1 || + word.indexOf(".fr") !== -1 || + word.indexOf(".de") !== -1 || + word.indexOf(".fm") !== -1) + { + var txt = word.replace("www.","") + s += ''+txt+' ' + } + else + s += word + " " + } + if (! avatar.length) + avatar = d.choice(AVATARS) + Avatar.orientation = ! Avatar.orientation + if (Avatar.orientation) + { + var q = '
' + q += '
' + q += '
' + s + '
' + return q + } + else + { + var q = [ + '
', + '
', + s, + '
', + '
' + ].join("") + return q + } + + return s + } -- cgit v1.2.3-70-g09d2