summaryrefslogtreecommitdiff
path: root/www/static/js/avatar.js
diff options
context:
space:
mode:
authorroot <root@dino.fm>2013-04-21 20:00:42 -0400
committerroot <root@dino.fm>2013-04-21 20:00:42 -0400
commit3790eedc2f48c725c586b8c7b924875fedbeb7b4 (patch)
tree6ad7a958495ea2bf8f02846eb9b8ec6127bcb136 /www/static/js/avatar.js
parent5a309541befe767901b24ca2389a1497d16ab5f5 (diff)
getting ready to push
Diffstat (limited to 'www/static/js/avatar.js')
-rwxr-xr-xwww/static/js/avatar.js236
1 files changed, 0 insertions, 236 deletions
diff --git a/www/static/js/avatar.js b/www/static/js/avatar.js
deleted file mode 100755
index 11d39d4..0000000
--- a/www/static/js/avatar.js
+++ /dev/null
@@ -1,236 +0,0 @@
-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("<img") !== -1)
- {
- postponeScroll = true
- d.joy(">> 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("<img") !== -1)
- // setTimeout('d.scrollToBottom("#chat")', 2000)
- if (msg.indexOf("scannerjammer.com/avatar") === -1)
- msg = "http://scannerjammer.com/avatar/" + d.choice(AVATARS) + " " + msg
- $.post(API.URL.room.say, {room: Room.name, session: Auth.session, msg: msg}, Room.sayCallback)
- d.scrollToBottom("#chat")
- }
-Chat.parse = function (row)
- {
- return Chat.parseWords(row[3])
- },
-Chat.parseWords = function (raw)
- {
- var words = raw.split(" ")
- var s = ""
- for (i in words)
- {
- var avatar = ""
- var word = words[i]
- if (word.indexOf("http") !== -1)
- {
- if (word.indexOf("scannerjammer.com/avatar") !== -1)
- {
- avatar = word
- }
- else if (word.indexOf("youtube.com/watch?") !== -1)
- {
- var ytid = "youtube_"+Youtube.getYtid(word)
- var txt
- if (ytid in Player.videos)
- txt = Player.videos[ytid].title
- else
- txt = word
- s += '<a href="'+word+'" class="ytlink" id="'+ytid+'" target="_parent">'+txt+'</a> '
- }
- 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 += '<a href="'+word+'" class="ytlink" id="'+ytid+'" target="_parent">'+txt+'</a> '
- }
- 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 += '<a href="'+word+'" class="ytlink" id="'+ytid+'" target="_parent">'+txt+'</a> '
- }
- // 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 += '<a href="'+word+'" class="ytlink" id="'+ytid+'" target="_parent">'+txt+'</a> '
- }
- 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 += '<a href="'+word+'" class="ytlink" id="'+vimeoid+'" target="_parent">'+txt+'</a> '
- }
- 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 += '<a href="'+word+'" class="ytlink" id="'+scid+'" target="_parent">'+txt+'</a> '
- }
- 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 += '<a href="'+word+'" target="_blank" class="pic"><img src="'+word+'" /></a>'
- }
- else if (word.indexOf("scannerjammer.com/profile") !== -1)
- {
- var username = word.substr( word.indexOf("profile")+8 ).replace("/","")
- s += '<a href="'+word+'">ScannerJammer: '+username+'</a>'
- }
- else
- {
- var poffset = word.indexOf('//')
- var linktext = word.substr(poffset+2, word.indexOf('/', poffset+2)).replace("www.","")
- s += '<a href="'+word+'" target="_blank">'+linktext+'</a> '
- }
- }
- 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 += '<a href="http://'+word+'" target="_blank">'+txt+'</a> '
- }
- else
- s += word + " "
- }
- if (! avatar.length)
- avatar = d.choice(AVATARS)
- Avatar.orientation = ! Avatar.orientation
- if (Avatar.orientation)
- {
- var q = '<div class="frame"><table border="0"><tr><td valign="top" class="avatar-left"><img src="'+ avatar +'"/></td>'
- q += '<td valign="top" class="tri"><div class="triangle-left"></div></td><td class="message">'
- q += '<div class="message-blurb">' + s + '</div></td></tr></table></div>'
- return q
- }
- else
- {
- var q = [
- '<div class="frame">',
- '<table border="0"><tr><td valign="top" class="message"><div class="message-blurb">',
- s,
- '</div></td><td valign="top" class="tri"><div class="triangle-right"></div></td><td valign="top" class="avatar-right">',
- '<img src="',
- avatar,
- '" /></td></tr></table></div>'
- ].join("")
- return q
- }
-
- return s
- }