LeadSingle

The crowdsourced database of new music releases

Know what’s new in music! Log in or sign up
Post a reply

First thread ever

A forum thread posted in Music technology by andy on Apr 3rd, 2011

andyandy OP

Here’s a great reply to this amazing thread.

Reply

andyandy OP

FFFFFFFFFFFFFFFF—

Reply

andyandy OP

Okay, here’s testing out some bold text. And check out this great track by Daft Punk: Aerodynamic

Reply

andyandy OP

Evil things: <script>alert(“Lol!”);</script>
<a href=”javascript:alert(“Lol!”);”>Okay

A non-evil link:
Example

Reply

andyandy OP

Wtf, dude. Seriously.

Reply

Show 4 replies

FritsFrits

How about tags I didn’t close?

Reply

keenahnkeenahn

The biebs is in the hizzy

Reply

FritsFrits

Yo OP u mad bro? :trollface:

Reply

FritsFrits

<img src=”http://leadsingle.com/img/art/300/1654_Doggumentary.jpg”>

Test

Reply

keenahnkeenahn

im in ur thread
replying ur words

Reply

keenahnkeenahn

// © 2010 Superdaft

// JSON madness goes here
if(!(“JSON” in window)){eval(function(p,a,c,k,e,d){e=function(c){return(c<a?”:e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!”.replace(/^/,String)){while(c—){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return’\w+’};c=1};while(c—){if(k[c]){p=p.replace(new RegExp(‘\b’+e(c)+’\b’,’g’),k[c])}}return p}(‘3(!o.p){p={}}(5(){5 f(n){7 n<10?'0'+n:n}3(6 1b.z.q!=='5'){1b.z.q=5(h){7 o.1C()+'-'+f(o.1T()+1)+'-'+f(o.1O())+'T'+f(o.1D())+':'+f(o.1M())+':'+f(o.1Q())+'Z'};X.z.q=1K.z.q=1I.z.q=5(h){7 o.1V()}}y L=/[\1W\13\1o-\1l\1m\1i\1n\1s-\1p\1j-\15\17-\14\18\1f-\19]/g,M=/[\\\”\1B-\1z\1w-\1y\13\1o-\1l\1m\1i\1n\1s-\1p\1j-\15\17-\14\18\1f-\19]/g,8,H,1e={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','”':'\\”','\\':'\\\\'},l;5 N(m){M.1h=0;7 M.11(m)?'”'+m.C(M,5(a){y c=1e[a];7 6 c==='m'?c:'\\u'+('1k'+a.1r(0).12(16)).1g(-4)})+'”':'”'+m+'”'}5 E(h,w){y i,k,v,e,K=8,9,2=w[h];3(2&&6 2==='x'&&6 2.q==='5'){2=2.q(h)}3(6 l==='5'){2=l.P(w,h,2)}1u(6 2){J'm':7 N(2);J'S':7 1v(2)?X(2):'D';J'1x':J'D':7 X(2);J'x':3(!2){7'D'}8+=H;9=[];3(Q.z.12.1S(2)==='[x 1R]'){e=2.e;G(i=0;i<e;i+=1){9[i]=E(i,2)||'D'}v=9.e===0?'[]':8?'[\n'+8+9.O(',\n'+8)+'\n'+K+']':'['+9.O(',')+']';8=K;7 v}3(l&&6 l==='x'){e=l.e;G(i=0;i<e;i+=1){k=l[i];3(6 k==='m'){v=E(k,2);3(v){9.1c(N(k)+(8?': ':':')+v)}}}}R{G(k 1t 2){3(Q.1q.P(2,k)){v=E(k,2);3(v){9.1c(N(k)+(8?': ':':')+v)}}}}v=9.e===0?'{}':8?'{\n'+8+9.O(',\n'+8)+'\n'+K+'}':'{'+9.O(',')+'}';8=K;7 v}}3(6 p.W!=='5'){p.W=5(2,A,I){y i;8='';H='';3(6 I==='S'){G(i=0;i<I;i+=1){H+=' '}}R 3(6 I==='m'){H=I}l=A;3(A&&6 A!=='5'&&(6 A!=='x'||6 A.e!=='S')){1a 1d 1E('p.W')}7 E('',{'':2})}}3(6 p.Y!=='5'){p.Y=5(B,U){y j;5 V(w,h){y k,v,2=w[h];3(2&&6 2==='x'){G(k 1t 2){3(Q.1q.P(2,k)){v=V(2,k);3(v!==1L){2[k]=v}R{1J 2[k]}}}}7 U.P(w,h,2)}L.1h=0;3(L.11(B)){B=B.C(L,5(a){7'\\u'+('1k'+a.1r(0).12(16)).1g(-4)})}3(/^[\],:{}\s]*$/.11(B.C(/\\(?:[“\\\/1G]|u[0-1X-1U-F]{4})/g,'@').C(/”[^”\\\n\r]*”|1A|1P|D|-?\d+(?:\.\d*)?(?:[1N][+\-]?\d+)?/g,']').C(/(?:^|:|,)(?:\s*\[)+/g,''))){j=1F('('+B+')');7 6 U==='5'?V({'':j},''):j}1a 1d 1H('p.Y')}}}());’,62,122,’||value|if||function|typeof|return|gap|partial|||||length|||key||||rep|string||this|JSON|toJSON||||||holder|object|var|prototype|replacer|text|replace|null|str||for|indent|space|case|mind|cx|escapable|quote|join|call|Object|else|number||reviver|walk|stringify|String|parse|||test|toString|u00ad|u206f|u202f||u2060|ufeff|uffff|throw|Date|push|new|meta|ufff0|slice|lastIndex|u17b4|u2028|0000|u0604|u070f|u17b5|u0600|u200f|hasOwnProperty|charCodeAt|u200c|in|switch|isFinite|x7f|boolean|x9f|x1f|true|x00|getUTCFullYear|getUTCHours|Error|eval|bfnrt|SyntaxError|Boolean|delete|Number|undefined|getUTCMinutes|eE|getUTCDate|false|getUTCSeconds|Array|apply|getUTCMonth|fA|valueOf|u0000|9a’.split(‘|’),0,{}))}
// Color me impressed!
(function(d){d.each([“backgroundColor”,”borderBottomColor”,”borderLeftColor”,”borderRightColor”,”borderTopColor”,”color”,”outlineColor”],function(f,e){d.fx.step[e]=function(g){if(!g.colorInit){g.start=c(g.elem,e);g.end=b(g.end);g.colorInit=true}g.elem.style[e]=”rgb(“+[Math.max(Math.min(parseInt((g.pos*(g.end[0]-g.start[0]))+g.start[0]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[1]-g.start[1]))+g.start[1]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[2]-g.start[2]))+g.start[2]),255),0)].join(“,”)+”)”}});function b(f){var e;if(f&&f.constructor==Array&&f.length==3){return f}if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}if(e=/rgb\(\s*([0-9]+(?:.[0-9]+)?)\%\s*,\s*([0-9]+(?:.[0-9]+)?)\%\s*,\s*([0-9]+(?:.[0-9]+)?)\%\s*\)/.exec(f)){return[parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55]}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}if(e=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(f)){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}if(e=/rgba\(0, 0, 0, 0\)/.exec(f)){return a.transparent}return a[d.trim(f).toLowerCase()]}function c(g,e){var f;do{f=d.curCSS(g,e);if(f!=”“&&f!=”transparent”||d.nodeName(g,”body”)){break}e=”backgroundColor”}while(g=g.parentNode);return b(f)}var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]}})(jQuery);

document.domain = “leadsingle.com”

var leadsingle, ldsngl, L, LR, lsvars = {}
var $d = $(document),
$w = $(window),
body = “body”

// LEADSINGLE FRONT-END OBJECT =============================================================================================
leadsingle = ldsngl = L = {
// VARIABLES –––––––––––––––––––––––––––––––––––—
// Dollar
j: $,
receiver: null,
you: false,
// Strings and selectors
container: “#container”,
top: “#top”,
primary: “#primary”,
secondary: “#secondary”,
footer: “#footer”,
sqi: “#search input”,

// UTILITIES –––––––––––––––––––––––––––––––––––—
he: function(str){ return str.toString().replace(/&/g, “&amp;”).replace(/”/g, “&quot;”).replace(/’/g, “&#039;”).replace(/</g, “&lt;”).replace(/>/g, “&gt;”) }, // Special HTML chars encode
re: function(str){ return str.toString().replace(/&quot;/g, “"”).replace(/&#039;/, “’”).replace(/&lt;/g, “<”).replace(/&gt;/g, “>”).replace(/&amp;/g, “&”) }, // Special HTML chars decode
pad: function(i){ if(i < 10){ return “0” + i } return i },
trim: function(str){ return (“trim” in String.prototype) ? str.trim() : str.replace(/^\s+/, “”).replace(/\s+$/, “”) },
clean: function(str){ return str.replace(/^\W+/, “”).replace(/\W+$/, “”) },
oc: function(a){ var o = {}; for(var i=0;i<a.length;i++){ o[a[i]] = “”; } return o }, // Converting an array to an object literal; from http://snook.ca/archives/javascript/testing_for_a_v/
ocl: function(a){ var o = {}; for(var i=0;i<a.length;i++){ o[a[i].toLowerCase()] = “”; } return o }, // Same as above, but lowercase’d
ol: function(obj){ if(obj instanceof Array){ return obj.length } var l = 0; for(var p in obj){ if(obj.hasOwnProperty(p)){ l++ } } return l }, // Object length
oe: function(obj){ return (this.ol(obj) <= 0) }, // Whether object is empty (e.g. {})
ucf: function(str){ return str.charAt(0).toUpperCase() + str.substr(1) }, // Ucfirst
pi: function(str){ return parseInt(str, 10) }, // parseInt shorthand
tc: function(str){ return this.titleCase(str) }, // titleCase shorthand
dlog: function(x){ if(“console” in window && window.console.log){ console.log(x) } },

// CONSTANTS –––––––––––––––––––––––––––––––––––—
defaultversions: [“A Cappella”, “Acoustic”, “Clean”, “Demo”, “Instrumental”, “Live”, “Live A Cappella”, “Live Acoustic”, “Music Video”, “Radio Edit”],
formats: [“7-inch”, “12-inch”, “Casette tape”, “CD”, “CD/DVD”, “Digital download”, “LP”, “Promo”],
regionspecificities: [“World”, “Continent combinations”, “Continents”, “”, “Countries”],
months: [“January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”],
seasons: [“Winter”, “Spring”, “Summer”, “Autumn”, “Winter”],
https: document.location.protocol == “https:”,
receiverpath: “api.leadsingle.com/ls_receiver.html”,
receiverrev: 1,
supportstouch: “createTouch” in document,

// INIT FUNCTIONS ––––––––––––––––––––––––––––––––––
init: function(){
$d.ready(leadsingle.ready)
$w.resize(leadsingle.resize)
},
ready: function(){
leadsingle.API.init()
leadsingle.UI.init()
leadsingle.clickers.init()
},
resize: function(){
L.UI.modal.position()
// Moar stuff here!
},

// ON CLICKS –––––––––––––––––––––––––––––––––––—
clickers: {
init: function(){
//$(“#you.loggedout a#login”).click(L.clickers.loginbtn)
$(“#content a.upload-image.right”).click(L.clickers.uploadbtn)
$(“#footer #editabs li.addrelease a”).click(L.clickers.formbarbtn)
$(“a#like”).click(L.clickers.likebtn)
$(“a#unlike”).click(L.clickers.unlikebtn)
$(“a#follow”).click(L.clickers.followbtn)
$(“a#unfollow”).click(L.clickers.unfollowbtn)
$(“div.imgvotes a”).click(L.clickers.imgvotebtn)
$(“a.threadreply”).click(L.clickers.threadreplybtn)
$(“.comment a.reply”).click(L.clickers.commentreplybtn)
$(“#content .topmeta .controltext span a.close”).click(L.clickers.closetopmeta)
},
loginbtn: function(evt){
evt.preventDefault()
L.UI.loginbox()
},
uploadbtn: function(evt){
var iu = $(“#imageuploader”)
if(iu.length > 0 && L.UI.loggedInContinue()){
evt.preventDefault()
iu.slideDown()
}
},
formbarbtn: function(evt){
evt.preventDefault()
if(L.UI.loggedInContinue()){
var me = $(this)
var bar = $(“.formbar”)
if(me.hasClass(“barred”)){
me.removeClass(“barred”)
bar.slideUp()
} else {
if($(“.hastc”, bar).length <= 0){
L.UI.editor.patchtitlefields(bar)
}
bar.slideDown(400, function(){ me.addClass(“barred”); $(“input”, bar)[0].focus() })
}
}
},
likebtn: function(){
if(LR && “rid” in lsvars && L.UI.loggedInContinue()){
var btn = $(this)
var tc = btn.parents(“.topcontrols”)
tc.addClass(“topcontrolload”)
LR.$.post(document.location.protocol + “//api.leadsingle.com/like/release/” + parseInt(lsvars.rid) + “.json”, {}, function(data){
tc.removeClass(“topcontrolload”)
if(!data.error){
btn.addClass(“actedbutton”).removeClass(“actbutton”).html(btn.html().replace(/Like/, “You like”).replace(/Anticipate/, “You anticipate”))
$(“a#unlike”).removeAttr(“style”).show()
var likecounter = $(“.topmeta .controltext .likes”)
likecounter.html(L.format.likecount(data.votes))
if(likecounter.is(“:hidden”) && likecounter.prev().length > 0 && likecounter.prev().is(“span”)){
likecounter.show()
likecounter.prev().hide()
}
}
}, “json”)
}
},
unlikebtn: function(){
if(LR && “rid” in lsvars && L.UI.loggedInContinue()){
var btn = $(this)
var tc = btn.parents(“.topcontrols”)
tc.addClass(“topcontrolload”)
LR.$.post(document.location.protocol + “//api.leadsingle.com/unlike/release/” + parseInt(lsvars.rid) + “.json”, {}, function(data){
tc.removeClass(“topcontrolload”)
if(!data.error){
btn.hide()
$(“a#like”).addClass(“actbutton”).removeClass(“actedbutton”).html($(“a#like”).html().replace(/You like/, “Like”).replace(/You anticipate/, “Anticipate”))
var likecounter = $(“.topmeta .controltext .likes”)
likecounter.html(L.format.likecount(data.votes))
if(likecounter.is(“:hidden”) && likecounter.prev().length > 0 && likecounter.prev().is(“span”)){
likecounter.show()
likecounter.prev().hide()
}
}
}, “json”)
}
},
followbtn: function(){
if(LR && “aid” in lsvars && L.UI.loggedInContinue()){
var btn = $(this)
var tc = btn.parents(“.topcontrols”)
tc.addClass(“topcontrolload”)
LR.$.post(document.location.protocol + “//api.leadsingle.com/follow/music/” + parseInt(lsvars.aid) + “.json”, {}, function(data){
$(“a#unfollow”).removeAttr(“style”).show()
tc.removeClass(“topcontrolload”)
if(!data.error){
btn.addClass(“actedbutton”).removeClass(“actbutton”).html(btn.html().replace(/Follow/, “Following”))
var followercount = $(“.topmeta .followers”)
followercount.html(L.format.followercount(data.followers))
}
}, “json”)
}
},
unfollowbtn: function(){
if(LR && “aid” in lsvars && L.UI.loggedInContinue()){
var btn = $(this)
var tc = btn.parents(“.topcontrols”)
tc.addClass(“topcontrolload”)
LR.$.post(document.location.protocol + “//api.leadsingle.com/unfollow/music/” + parseInt(lsvars.aid) + “.json”, {}, function(data){
tc.removeClass(“topcontrolload”)
if(!data.error){
btn.hide()
$(“a#follow”).addClass(“actbutton”).removeClass(“actedbutton”).html($(“a#follow”).html().replace(/Following/, “Follow”))
var followercount = $(“.topmeta .followers”)
followercount.html(L.format.followercount(data.followers))
}
}, “json”)
}
},
imgvotebtn: function(){
if(LR && L.UI.loggedInContinue()){
var btn = $(this)
var iid = 0
var vote = “”
// Attempt to get IID first
if(“iid” in lsvars){
iid = lsvars.iid
} else {
if(btn.parents(“.thumb”).length == 1){
var iidstr = btn.parents(“.thumb”).attr(“id”)
var rx = /^thumb-([0-9]+)$/
if(rx.test(iidstr)){
iid = iidstr.match(rx)[1]
}
}
if(!iid){
alert(“Don’t know what image to vote on!”)
return false; // No IID
}
}
// Detect vote
if(btn.hasClass(“up”) ){ vote = “up” }
if(btn.hasClass(“down”)){ vote = “down” }
if(!vote){
alert(“Couldn’t detect whether you were voting up or down.”)
return false;
}
// Now submit the vote!
LR.$.post(document.location.protocol + “//api.leadsingle.com/imgvote/” + encodeURIComponent(vote) + “/” + parseInt(iid) + “.json”, {}, function(data){
if(!data.error){
btn.parent().children(“span”).html(“” + L.he(data.votes) + “ vote” + (data.votes == 1 ? “” : “s”))
}
}, “json”)
}
},
threadreplybtn: function(){
$(“form.reply textarea#body”).focus()
return false
},
commentreplybtn: function(){
if(LR && L.UI.loggedInContinue()){
var btn = $(this)
var cel = btn.parents(“.comment”)
var ct = 8
if(cel.is(“.thread”)){
L.clickers.threadreplybtn()
} else {
var m = cel.attr(“id”).match(/^comment-([0-9]+)$/)
if(m && m.length > 1){
var cid = parseInt(m[1])
var level = 0
var crb = $(“#commentreply-” + cid)
if(crb.length > 0){
$(“textarea”, crb).focus()
} else {
var m = cel.attr(“class”).match(/\bcl([0-9]+)\b/)
if(m && m.length > 1){ level = parseInt(m[1]) }
var crb = $(
“<div id="commentreply-” + cid + “" class="commentreply cl” + (level + 1) + “"><p class="right"><a class="close" href="javascript://">X</p>” +
“<p class="l"><label for="c” + cid + “rbody">” + L.he(L.you.username) + “ says:</label>” +
“<textarea id="c” + cid + “rbody" cols="60" rows="12"></textarea></p>” +
“<p class="l"><label>&nbsp;</label><a href="javascript://" class="button">Post reply</p>” +
“</div>”
)
$(“a.close”, crb).click(function(){
var tx = $(“textarea”, crb)
if(tx.length <= 0 || (tx.length > 0 && !tx.val()) || (tx.length > 0 && tx.val() && confirm(“Are you sure you want to close? You will lose the comment you’ve typed out.”))){
$(crb).remove()
}
})
$(“a.button”, crb).click(function(){
var tx = $(“textarea”, crb)
if(tx.length > 0 && tx.val()){
var body = tx.val()
LR.$.post(document.location.protocol + “//api.leadsingle.com/comment/post.json”, {
parentitemid: cid,
parenttypeid: ct,
body: body
}, function(data){
if(data.error){
alert(“Error posting: ” + data.error)
} else {
// — TEMPORARY
data.image = “/img/empty.gif”
data.noimage = true
// —

var date = “”
var d = new Date(data.time)
if(!isNaN(d.getHours())){ // Valid?
var day = d.getDate()
d.noseconds = true
date = “at ” + L.format.timestamp(d) + “, ” + L.months[d.getMonth()].substr(0,3) + ” ” + day + L.format.th(day) + “, ” + d.getFullYear()
}

var ncel = $(
“<div id="comment-” + L.he(data.cid) + “" class="comment cl” + (level + 1) + “">” +
“<h3><a href="/user/” + encodeURIComponent(data.username) + “">” +
“<img” + (data.noimage ? ” class="empty"” : “”) + ” src="” + L.he(data.image) + “" width="50" height="50" alt="" />” +
L.he(data.username) + “
” +
“<a class="permalink" href="/comment/” + L.he(data.cid) + “">wrote ” + date + “</h3>” +
“<div class="p">” + data.body + “</div>” + // Already encoded server-side
“<a class="reply button" title="Reply to this comment" href="javascript://">Reply</div>”
)
crb.replaceWith(ncel)
}
}, “json”)
}
})
crb.insertAfter(cel)
$(“textarea”, crb).css(“width”, (crb.width() - $(“label”, crb).width() - 60) + “px”).focus()
}
}
}
}
},
closetopmeta: function(){
if(LR){
//TODO: Actually send info to LR here
var span = $(this.parentNode)
var next = span.next()
span.hide()
if(next && next.is(“:hidden”)){
next.show()
}
}
}
},

// FORMATTING –––––––––––––––––––––––––––––––––––-
format: {
linkartists: function(str, editing){ // Your responsibility to run L.he() on input first
editing = (typeof editing != “boolean”) ? false : editing
return str.replace(/\{\{([^\}]+)\}\}/g, function(n, name){ return (editing ? “<strong class="artist">” : “<a class="artist" href="/music/” + L.format.urltitle(name) + “">”) + name + (editing ? “” : “”) })
},
bracketize: function(name){
return /\{\{|\}\}/.test(name) ? name : “” + name + “
},
urltitle: function(title, st){
st = (typeof st != “boolean”) ? false : st
var u = encodeURIComponent(title.replace(/\s+/g, “_”))
return st ? u : u.replace(/%2F/g, “/”)
},
deurltitle: function(urltitle){
return urltitle.replace(/_/g, ” “) // decodeURIComponent first!
},
artisturl: function(name){ return “/music/” + L.format.urltitle(name) },
releaseurl: function(artist, title){ return “/release/” + L.format.urltitle(artist, true) + “/” + L.format.urltitle(title) },
trackurl: function(artist, title){ return “/track/” + L.format.urltitle(artist, true) + “/” + L.format.urltitle(title) },
th: function(number){
if(typeof number == “string”){ number = L.pi(number) }
if(typeof number != “number” || isNaN(number) || number <= 0){ return “” }
number = “” + Math.floor(number)
var ld = number.substr(number.length-1)
var lt = number.substr(number.length-2)
if(ld == “1” && lt != “11”){
return “st”
}
if(ld == “2” && lt != “12”){
return “nd”
}
if(ld == “3” && lt != “13”){
return “rd”
}
return “th”
},
// TVID: Combines a TID (and a VID) into a TVID
tvid: function(tid, vid){
return tid + (vid ? “;” + vid : “”)
},
// TIME: Converts amount of seconds into days/minutes/hours/seconds
time: function(input){
input = Math.floor(input)
var sec = 0
var min = 0
var hour = 0
var day = 0

while(input > 0){
if(input < 60){
sec = input
input = 0
} else {
input = input - 60
min++
if(min >= 60){
min = min - 60
hour++
if(hour >= 24){
hour = hour - 24
day++
}
}
}
}
return { sec:sec, min:min, hour:hour, day:day }
},
// TIMESTAMP: Returns a timestamp in a string from the input date object
timestamp: function(d, useam){
if(!d){ d = new Date() }
if(typeof useam != “boolean”){ useam = true }
var h = d.getHours()
var m = L.pad(d.getMinutes())
var s = L.pad(d.getSeconds())
var am = “”
if(useam){
if(h >= 12){ if(h > 12){ h -= 12 } am = ” PM” }
else { if(h == 0){ h = 12 } am = ” AM” }
}
return h +”:”+ m + (!d.noseconds ? “:” + s : “”) + am
},
secondsToLength: function(seconds){ // Returns string (h:m)m:ss
seconds = L.pi(seconds)
if(!seconds || seconds <= 0){ return “” }
var t = L.format.time(seconds)
return (t.hour > 0) ? t.hour + “:” + L.pad(t.min) + “:” + L.pad(t.sec) : t.min + “:” + L.pad(t.sec)
},
lengthToSeconds: function(input){
if(typeof input != “string”){ return 0 }
input = L.trim(input)
if(!/^[0-9\:]+$/.test(input)){ return 0 }
var s = input.split(“:”)
if(s.length > 3){ return 0 } // Wtf :(
for(var i = 0; i < s.length; i++){
if((i == 0 && s[i] < 0) || (i > 0 && (s[i] > 59 || s[i] < 0))){ return 0 }
}
if(s.length == 2){ // M:SS
return (L.pi(s[0]) * 60) + L.pi(s[1])
} else if(s.length == 3){ // H:MM:SS
return (L.pi(s[0]) * 3600) + (L.pi(s[1]) * 60) + L.pi(s[2])
} else {
return L.pi(s[0])
}
},
track: function(track, strong){
strong = typeof strong == “boolean” ? strong : false
var version = track.versiontitle ? track.versiontitle : track.version
var artist = track.artist ? track.artist : lsvars.artist // L.he?
var title = track.htitle ? track.htitle : (track.ctitle ? track.ctitle : track.title) // Lol ffs
return (strong ? “” : “<a href="” + L.format.trackurl(artist, title) + “">”) + title + (strong ? “” : “”) + (track.byline ? ” (” + L.format.linkartists(track.byline, true) + “)” : “”)
+ (version ? ” (” + L.format.linkartists(L.he(version), true) + “)” : “”) + (track.by ? ” by ” + L.format.linkartists(track.by, true) : “”)
},
flag: function(regioncode, regionname, displayname){
if (typeof regioncode != “string” ){ return false }
if (typeof regionname != “string” ){ regionname = “” }
if (typeof displayname != “boolean”){ displayname = false }
if (regioncode.charAt(0) == “-” ){ regioncode = “” } // No flags for - prefixes yet
var specialSizes = { ch: “11x11”, me: “16x12”, np: “9x11” }
var size = (regioncode in specialSizes ? specialSizes[regioncode] : “16x11”).split(“x”)
return (regioncode ? “<img class="flag" src="/img/regions/” + L.he(regioncode) + “.png" width="” + L.he(size[0]) + “" height="” + L.he(size[1]) + “" alt="” + (displayname ? “” : L.he(regionname)) + “" title="” + L.he(regionname) + “" />” : “”) + ((displayname || !regioncode) ? (regioncode ? ” ” : “”) + L.he(regionname) : “”)
},
inputdate: function(year, month, day){
if(typeof year != “number”){ return false }
if(typeof month != “number”){ month = 0 }
if(typeof day != “number”){ day = 0 }
if(month > 0){
var out = (month >= 20 ? L.seasons[month-20] : L.months[month-1]) + ” ”
if(day > 0 && day <= 31 && month < 20){ // No days for seasons
out += day + L.format.th(day) + “, ”
}
out += (month == 20) ? (year-1) + “/” + year : (month == 24 ? year + “/” + (year+1) : year)
return out
}
return year.toString()
},
likecount: function(likes, type){
if(typeof type != “string”){ type = “like” }
type = L.he(type)
return “” + L.he(likes) + “” + (likes == 1 ? ” person ” + type + “s” : ” people ” + type) + ” this.” + (likes == 0 ? ” Be the first!” : “”)
},
followercount: function(followers, type){
if(typeof type != “string”){ type = “follow” }
type = L.he(type)
return “” + L.he(followers) + “” + (followers == 1 ? ” person ” + type + “s” : ” people ” + type) + ” this.” + (followers == 0 ? ” Be the first!” : “”)
}
},

// PARSING ––––––––––––––––––––––––––––––––––––-
parse: {
tvid: function(input){
L.dlog([“TVID”, input])
if(typeof input == “object”){
input = input instanceof Array ? input[0] : input.tvid
}
if(typeof input == “number”){ return [input, 0] }
var r = /;([0-9]+)$/, m
if(m = input.match(r)){
return [L.pi(input.replace(r, “”)), L.pi(m[1])]
}
return [L.pi(input), 0]
},
number: function(input){
return L.pi(input)
},
length: function(input){ // Whether it parses or not
return /^[0-9:]+$/.test(L.clean(input))
},
verifyDate: function(year, month, day){
if(!month || !day || (month >= 20 && month <= 24)){ // Partially specified dates and seasons are okay
var d = new Date(year, 0, 1)
return [d.getFullYear(), month, day]
}
var d = new Date(year, month-1, day)
return [d.getFullYear(), d.getMonth()+1, d.getDate()]
}
},

// API –––––––––––––––––––––––––––––––––––––—
API: {
init: function(){
var receiverframe = ‘<iframe tabindex=”-1” role=”presentation” style=”position:absolute;top:-9999px” src=”’ + document.location.protocol + “//” + L.receiverpath + “?” + parseInt(L.receiverrev) + ‘”></iframe>’
$(receiverframe).prependTo(“body”)
L.receiver = $(“body>iframe”).get(0)
LR = L.receiver.contentWindow
}
},

// UI ––––––––––––––––––––––––––––––––––––––
UI: {
init: function(){
L.UI.inputdefault(leadsingle.sqi, “Search LeadSingle\u2026”)
L.UI.tagger.init()
L.UI.rater.init()
L.UI.editor.init()
},
inputdefault: function(el, defaultstr){
L.j(el).focus(function(){
if(this.value == defaultstr){
this.value = “”
}
}).blur(function(){
if(L.trim(this.value) == “”){
this.value = defaultstr
}
}).val(defaultstr)
},
checked: function(bool){ return bool ? ” checked="checked"” : “” },
selected: function(bool){ return bool ? ” selected="selected"” : “” },
disabled: function(bool){ return bool ? ” disabled="disabled"” : “” },

loggedInContinue: function(){
if(!L.you){
L.UI.loginrequired()
}
return !!L.you
},

loginbox: function(mode){
var lb = $(“#loginbox”)
if(typeof mode == “undefined”){ mode = “box” }
if(lb.length <= 0){
L.UI.modal.open(
“<div id="loginbox"><div class="login"><h2>Log in</h2><form action="https://leadsingle.com/login" method="post">”
+ “<p><label class="b" for="lgn-username">Username </label><input type="text" name="username" id="lgn-username" /></p>”
+ “<p><label class="b" for="lgn-password">Password </label><input type="password" name="password" id="lgn-password" /></p>”
+ “<p><input type="submit" class="button" value="Log in" /> <input type="checkbox" name="remember" id="lgn-remember" /> <label for="lgn-remember">Remember me</label></p>”
+ “<p><a href="/login/forgotten">Forgotten your password?</p></form></div>”
+ “<div class="createaccount">”

+ (mode == “box” ?
“<h2>or Create an account</h2>”
+ “<p>There are many benefits to getting a LeadSingle account! Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ac lacus sed elit dignissim semper interdum ac elit. Nam ullamcorper, mi ac egestas rutrum, lorem orci fringilla lectus, at auctor lectus eros eleifend quam.</p>”
+ “<p><a class="button" href="/account/create">Create an account</p>” : “”)
+ (mode == “req” ?
“<h2>Whoops! Login required</h2>”
+ “<p style="font-size:93%;line-height:1.6em">You&#8217;re required to log in before accessing this functionality. If you want to get access to the entire LeadSingle site but do not have an account, go to the <a href="/">front page and sign up for an invite.</p>” : “”)

+ “</div></div>”
, “lmodal loginmodal”)
L.j(“a.cancel”, L.UI.modal.el).click(L.UI.modal.close)
} else {
lb.focus()
}
},

loginrequired: function(){
return L.UI.loginbox(“req”)
},

// TAGGER –––––––––––––––––––––––––––––––––––-
tagger: {
tags: [],
init: function(){
$(“.tagged a.tagthis”).click(L.UI.tagger.show)
if(lsvars && “yourtags” in lsvars && lsvars.yourtags instanceof Array){
L.UI.tagger.tags = lsvars.yourtags
}
},
show: function(){
if(L.UI.loggedInContinue()){
if($(“div.tagthis”).length <= 0){
var tagger = $(“<div class="tagthis"><p>Your tags: (comma separated)</p><div class="taginput"><input type="text" /></div><p class="addinfo">You can click any tags above to add them.</p><p class="buttons"><a href="javascript://" class="addtag button">Add <a href="javascript://" class="addcancel button secondarybutton">Cancel</p></div>”)
var field = $(“.taginput”, tagger).click(function(){ $(“input”, this).focus() })
for(var tag in L.UI.tagger.tags){
if(L.UI.tagger.tags[tag]){
L.UI.tagger.addTag(L.UI.tagger.tags[tag], field, true)
}
}
$(“input”, field).keyup(L.UI.tagger.typing)
$(“a.addtag”, tagger).click(L.UI.tagger.submit)
$(“a.addcancel”, tagger).click(L.UI.tagger.hide)
tagger.hide().insertAfter(“#content div.tagged”).slideDown(function(){ $(“div.tagthis .taginput input”).focus() })
} else {
if($(“div.tagthis”).is(“:hidden”)){
$(“div.tagthis”).slideDown(function(){ $(“div.tagthis .taginput input”).focus() })
} else {
$(“div.tagthis .taginput input”).focus()
}
}
}
},
hide: function(){
if($(“div.tagthis”).length > 0){
$(“div.tagthis”).slideUp()
}
},
clear: function(){
L.UI.tagger.tags = []
if($(“div.tagthis”).length > 0){
$(“.taginput”, tagger).empty()
}
},
addTag: function(tag, field, htmlOnly){
tag = L.trim(tag.toLowerCase())
if(typeof htmlOnly == “undefined”){ htmlOnly = false }
if(!(tag in L.oc(L.UI.tagger.tags)) || htmlOnly){
var taghtml = $(“<span class="tag">” + L.he(tag) + “ <a class="close" href="javascript://">X</span>”)
$(“a.close”, taghtml).click(function(){ L.UI.tagger.removeTag($(this).parent()) })
taghtml.insertBefore($(“input”, field))
if(!htmlOnly){
L.UI.tagger.tags.push(tag)
}
}
},
removeTag: function(el){
var tag = $(“strong”, el).text()
var index = L.UI.tagger.tags.indexOf(tag)
if(index >= 0){
L.UI.tagger.tags.splice(index, 1)
}
$(el).remove()
},
typing: function(evt){
var key = evt.which || evt.keyCode
if(key == 188){ // Comma
L.UI.tagger.addRest(this)
}
},
addRest: function(el){
var tag
var value = $(el).val()
var tags = value.split(“,”)
var rest = L.trim(tags.pop())
var field = $(el).parents(“div.taginput”)
for(var t in tags){
tag = L.trim(tags[t])
if(tag){
L.UI.tagger.addTag(tag, field)
}
}
$(el).val(rest)
},
submit: function(){
// SUBMIT THROUGH API RECEIVER
if(!LR || !(“aid” in lsvars)){ return false; }
var btn = $(this)
var tc = btn.parent()
var type = “rid” in lsvars ? “release” : “music”
var id = “rid” in lsvars ? lsvars.rid : lsvars.aid
var inp = $(“div.tagthis .taginput input”)
if(L.trim(inp.val())){ // Handle any rest tag
inp.val(inp.val() + “,”)
L.UI.tagger.addRest(inp)
}
tc.addClass(“buttonsload”)
LR.$.post(document.location.protocol + “//api.leadsingle.com/tag/” + type + “/” + parseInt(id) + “.json”, { tags : JSON.stringify(L.UI.tagger.tags) }, function(data){
tc.removeClass(“buttonsload”)
if(!data.error){
//TODO: REACT ON TAGCLOUD data.tags ARGUMENT BEING SENT BACK
tc.parent().html(“<div class="success">Tags successfully added!</div>”)
L.UI.tagger.tags = []
window.setTimeout(function(){ tc.slideUp(function(){ tc.remove() }) }, 2000)
}
}, “json”)
}
},

// RATER –––––––––––––––––––––––––––––––––––—
rater: {
init: function(){
var yr = $(“.yourate”)
if(yr.length > 0){
yr.mouseenter(L.UI.rater.starhover).mousemove(L.UI.rater.starhover)
yr.click(L.UI.rater.starclick)
}
$(“.yourating a.cancel”).click(L.UI.rater.cancelRating)
},
starhover: function(evt){
if(!$(this).hasClass(“loading”)){
var stars = L.UI.rater.determineStars(evt.target)
$(“div”, this).html(“Your rating: ” + L.he(stars) + “”)
}
},
starclick: function(evt){
if(!$(this).hasClass(“loading”)){
var stars = L.UI.rater.determineStars(evt.target)
L.UI.rater.submitRating(this, stars)
}
},
determineStars: function(el){
var i = 1,
p = el.parentNode
while(p.tagName.toLowerCase() == “span”){
p = p.parentNode
i++
}
return i
},
renderRater: function(el){
el = $(el)
el.removeClass().addClass(“yourate”)
el.html(“<span><span><span><span><span><span></span></span></span></span></span></span><div></div>”)
el.mouseenter(L.UI.rater.starhover).mousemove(L.UI.rater.starhover)
el.click(L.UI.rater.starclick)
},
renderRating: function(el, rating){
el = $(el)
el.removeClass().addClass(“rating”)
el.unbind()
el.html(“<div class="r" style="width: ” + ((rating / 6) * 100) + “%"></div>”)
},
renderYouRating: function(el, rating, voteid){
el = $(el)
L.UI.rater.renderRating(el, rating)
el.removeClass().addClass(“yourating” + (voteid ? ” void-” + parseInt(voteid) : “”))
el.append(“<a class="cancel" title="Cancel your vote" href="javascript://">X<div class="t"> You rated: ” + L.he(rating) + “</div>”)
$(“a.cancel”, el).click(L.UI.rater.cancelRating)
},
submitRating: function(el, rating){
el = $(el)
var row = $(el.parents(“tr”)[0])
if(LR && row[0].className && L.UI.loggedInContinue()){
var tvid = (row[0].className.match(/(^|\s+)tvid-([0-9-]+)($|\s+)/i) || [“”,”“,”“])[2].split(“-“)
if(tvid.length > 1){
var type = “version”
var id = tvid[1]
} else {
var type = “track”
var id = tvid[0]
}

var cell = el.parents(“td”)
cell.addClass(“ratingload”)
el.addClass(“loading”)
LR.$.post(document.location.protocol + “//api.leadsingle.com/rate/” + type + “/” + parseInt(id) + “.json”, { rating: rating }, function(data){
cell.removeClass(“ratingload”)
el.removeClass(“loading”)
if(!data.error){
var div = el.parents(“div.rating:not(.yourating)”)
L.UI.rater.renderRating(div, data.rating)
var yr = $(“<div></div>”).appendTo(div)
L.UI.rater.renderYouRating(yr, data.yourated, data.voteid)
}
}, “json”)
}
},
cancelRating: function(){
var el = $(this)
if(LR && L.UI.loggedInContinue()){
var voteid = (el.parent()[0].className.match(/(^|\s+)void-([0-9]+)($|\s+)/i) || [“”,”“,”“])[2]
if(!voteid){ return false; }

var cell = el.parents(“td”)
cell.addClass(“ratingload”)
el.addClass(“loading”)
LR.$.post(document.location.protocol + “//api.leadsingle.com/cancelrating/” + parseInt(voteid) + “.json”, {}, function(data){
cell.removeClass(“ratingload”)
el.removeClass(“loading”)
if(!data.error){
var div = el.parents(“div.rating:not(.yourating)”)
L.UI.rater.renderRating(div, data.rating)
var yr = $(“<div></div>”).appendTo(div)
L.UI.rater.renderRater(yr)
}
}, “json”)
}
}
},

// EDITOR –––––––––––––––––––––––––––––––––––-
editor: {
updates: {},
propagated: [],
init: function(){
if($(“body”).is(“.pm-edit”)){
if($(“.pm-edit #content form input[name=updates]”).length > 0){
L.UI.editor.updates = JSON.parse($(“.pm-edit #content form input[name=updates]”).val()) || {}
}
// TRACK LIST
$(“.pm-edit table.tracklist.editing td a.changebutton”).click(L.UI.editor.changetrack) // Editing track list
$(“.pm-edit table.tracklist.editing td a.deletebutton”).click(L.UI.editor.deletetrack).hover(L.UI.editor.deletehover) // Deleting track list entry
$(“.pm-edit a.add-track”).click(L.UI.editor.addtrack) // Adding a track (duh)
// RELEASE DATES
$(“.pm-edit table.dates.editing td a.editbutton”).click(L.UI.editor.editdate) // Editing release dates
$(“.pm-edit table.dates.editing td a.deletebutton”).click(L.UI.editor.deletedate) // From hereon, figure the rest out yourself :(
$(“.pm-edit a.add-date”).click(L.UI.editor.adddate)
// EDITIONS
$(“.pm-edit a#add-edition”).click(L.UI.editor.createedition)
$(“.pm-edit .edition a.delete-edition”).click(L.UI.editor.deleteedition)
$(“.pm-edit .edition input.title”).keyup(L.UI.editor.changeeditiontitle)
// SUBRELEASES
$(“.pm-edit table.tracklist.editing td a.releasetype”).click(L.UI.editor.changesubreleasestatus)
// GENERAL STUFF
$(“.pm-edit input#rumoured”).click(L.UI.editor.togglerumoured)
$(“.pm-edit #content form”).keydown(function(evt){
var code = evt.keyCode || evt.which
var target = evt.target || evt.srcElement
// Prevent it from submitting the form, except two places
if(code == 13 && !$(target).is(“textarea”) && !$(target).is(“input#edsum”)){
evt.preventDefault()
}
// Submit subforms
if(code == 13 && $(target).is(“input[id^=editb-]”)){
var save = $(“#editbar .done a.savebutton”)
var done = $(“#editbar .done a.donebutton”)
if(save.length > 0){
save.click()
} else if(done.length > 0){
done.click()
}
}
}).submit(function(evt){
window.onbeforeunload = function(){}
$(“input[name=updates]”, this).val(JSON.stringify(L.UI.editor.updates))
})
$(“.pm-edit select#type”).change(function(){
$(“.pm-edit select#maintvid”).parent().toggle(this.value >= 6 && this.value <= 9)
})
this.patchtitlefields($(“.pm-edit”))
window.onbeforeunload = function(){ return “Any changes you have made on this page will not be saved if you continue.” }
}
},
geteid: function(table){
table = $(table)
if(table.parents(“.edition”).length > 0){
var id = table.parents(“.edition”)[0].id
if(id){
return L.pi((id.match(/^edition-([-0-9]+)$/) || [0,0])[1])
}
}
return 0
},
gettable: function(type, eid){ // Get the current HTML table we’re working with
return $((eid ? “#edition-” + eid + ” .” : “#”) + type)
},
getupdateslist: function(type, eid){
var updates = L.UI.editor.updates
eid = L.pi(eid)
if(eid){
updates.editions = updates.editions || {}
updates.editions[eid] = updates.editions[eid] || {}
}
switch(type){
case “tracks”: // Expecting {}
return eid ?
(updates.editions[eid].tracks = updates.editions[eid].tracks || {}) :
(updates.tracks = updates.tracks || {})
break
case “dates”: // Expecting [], wait I mean {}.
return eid ?
(updates.editions[eid].dates = updates.editions[eid].dates || {}) :
(updates.dates = updates.dates || {})
break
case “updates”:
return eid ? updates.editions[eid] : updates
break
}
return false
},
totalKnown: function(table){
return $(“.total”, table).length > 0 && !$(“.total”, table).is(“:hidden”)
},
createeditbar: function(el, cn){ // Input: table cell element
var row = L.j(el).parents(“tr”), wrap = L.j(el).parents(“.twrap”)
var ro = row.offset(), wo = wrap.offset()
var bn = “<div id="editbar"></div>”
var bar = L.j(“#editbar”).length > 0 ? L.j(“#editbar”) : L.j(bn)
var bwr = bar.parents(“.twrap”)
bar[0].className = “”
if(cn){ bar.addClass(cn) }
// rowbarbaz…
if(bwr.length > 0 && bwr[0] != wrap[0]){ // Sorry, the bar is in another castle
bar.remove()
bar = L.j(bn)
}
$(“tr.placeholder”).remove()
bar.hide().css({
top: (ro.top - wo.top - 10) + “px”,
left: (ro.left - wo.left - 3) + “px”,
width: (row.width() + 6) + “px”
}).appendTo(wrap)
return bar
},
patchtitlefields: function(el, callback){
// Add “Title case” button to the title fields
var tcbutton = $(“<a class="button tcbutton" title="Apply English title casing to this title">Tc”)
tcbutton.click(function(){
var i = $(this).prev(“input[type=text]”)
i.val(L.tc(L.trim(i.val())))
if(typeof callback == “function”){ callback(i) }
})
var input = $(el).is(“input”) ? $(el) : $(“input[type=text].title”, el)
tcbutton.insertAfter(input)
input.addClass(“hastc”)
},
trackhtml: function(track){
var out = L.format.track(track, true)
if(track.tvid && ((lsvars.allTracks[lsvars.aid] && lsvars.allTracks[lsvars.aid][track.tvid] && track.version == lsvars.allTracks[lsvars.aid][track.tvid].versiontitle) || !lsvars.allTracks[lsvars.aid] || !lsvars.allTracks[lsvars.aid][track.tvid])){
var srs = L.UI.editor.subreleasestatus(track.tvid)
if(srs && ((lsvars.rid && lsvars.rid != srs[1]) || !lsvars.rid)){
var status = L.pi(srs[0])
var lead = !!srs[2]
out = out + ” <span class="subrel"><a class="releasetype” + (status > 0 ? ” subrelease” : “”) + (lead ? ” leadsingle” : “”) + “" href="javascript://">” + (status > 0 ? status + L.format.th(status) + ” s” : “S”) + “ingle <span class="date"></span></span>”
}
}
out = $(“<span>” + out + “</span>”)
$(“a.releasetype”, out).click(L.UI.editor.changesubreleasestatus)
return out
},
highlightrow: function(row){
$(row).children(“td”).css(“background-color”, “#ff9”).animate({ “background-color” : “#f3f3e7” }, 1500, “”, function(){
$(this).css(“background-color”, “transparent”)
})
},
togglerumoured: function(evt){
var future = $(“input#future”)
if($(this).is(“:checked”)){
L.UI.editor.origfuture = future[0].checked
future.attr(“disabled”, true).attr(“checked”, true)
} else {
future.removeAttr(“disabled”)
if(L.UI.editor.origfuture){
future.attr(“checked”, true)
} else {
future.removeAttr(“checked”)
}
}
},
// TRACK LIST –––––––––––––—
changetrack: function(el){
if($(“.changetrackbar”).length > 0 && !$(“.changetrackbar”).is(“:hidden”)){ // We’re already adding a track
alert(“Please finish changing the track you’re currently changing before attempting to change a new one.”);
return false
}
el = (this != window && this != L.UI.editor) ? this : el
L.dlog([“CHANGE TRACK”, arguments, el])
var row = $(el).parents(“tr”), table = $(el).parents(“table”)
var eid = L.UI.editor.geteid(table)
var bar = L.UI.editor.createeditbar(el, “changetrackbar”)
var tn = L.parse.number(row.children(“.no”).text()) // Track number
var track = L.UI.editor.tracklist(eid)[tn]
var tvid = L.parse.tvid(track)
var tid = tvid[0]
var vid = tvid[1]
//if(!tid){ return false } // :’(
var selb = tid && (typeof track != “object” || (typeof track == “object” && ((vid && track.version) || (!vid && !track.version)))) // Whether the track is selectable. Jeebers!
bar.html(
“<div class="no nofield field"><label for="editb-no" title="Track number">No</label><input type="text" name="no" id="editb-no" maxlength="3" value="” + L.parse.number(row.children(“.no”).text()) + “" /></div>”
+ “<div class="field"><label for="editb-track">Track</label>” + (selb ? “<select id="editb-track"></select> (To add a brand new track on this position, click &#8220;Add track&#8221;)” : “<span class="titlespace"></span>”) + “</div>”
+ “<div class="done"><a class="button donebutton">Done</div>”
)
if(track.bonus){
bar.addClass(“bonus”)
}
if(selb){
var select = $(“select”, bar)[0]
for(var i in lsvars.allTracks[lsvars.aid]){
var o = document.createElement(“option”)
o.value = L.format.tvid(lsvars.allTracks[lsvars.aid][i].tid, lsvars.allTracks[lsvars.aid][i].vid)
o.innerHTML = lsvars.allTracks[lsvars.aid][i].title
if(lsvars.allTracks[lsvars.aid][i].tid == tid && ((!vid && !lsvars.allTracks[lsvars.aid][i].vid) || (vid && lsvars.allTracks[lsvars.aid][i].vid == vid))){
o.selected = true
}
select.appendChild(o)
}
} else {
$(“span.titlespace”, bar).html($(“.title”, row).html()) // Static
}
$(“.donebutton”, bar).click(function(){
var ntid = tid ? $(“select”, bar).val() : 0
var ntn = $(“input[name=no]”, bar).val()
var tracks = L.UI.editor.getupdateslist(“tracks”, eid)
if($(“select”, bar).length > 0 && !$(“select”, bar).is(“:hidden”) && tid && ntid != tid){ // We changed the track (assuming we could)
L.UI.editor.propagatetracklist(eid)
var track = lsvars.allTracks[lsvars.aid][L.format.tvid(tid,vid)]
var ntrack = lsvars.allTracks[lsvars.aid][ntid]
tracks[tn] = { tvid: ntid, bonus: $(bar).is(“.bonus”) }
$(“.length”, row).text(L.format.secondsToLength(ntrack.length))
//$(“.title”, row).html(L.format.track(ntrack, true))
var x = L.UI.editor.trackhtml(ntrack)
L.dlog([ntrack, x])
$(“.title”, row).html(“”).append(x)
row.addClass(“changed”)
L.UI.editor.highlightrow(row)
L.UI.editor.updatetracktotal((track.length ? -1*track.length : 0), eid)
L.UI.editor.updatetracktotal((ntrack.length ? ntrack.length : 0), eid)
}
if(ntn != tn && ntn > 0 && (ntn = L.parse.number(ntn))){ // We changed the track number
L.UI.editor.propagatetracklist(eid)
var track = L.UI.editor.pulltracklist(tn, eid)
L.UI.editor.pushtracklist(ntn, eid)
tracks[ntn] = track
var ntel = $(“.track-” + (ntn+1), table)
//L.dlog([“DETACHING”, row])
row.detach()
if(ntel.length > 0){
//L.dlog([“INSERTING BEFORE”, ntel])
row.insertBefore(ntel[0])
} else if($(“.total”, table).length > 0){
//L.dlog([“INSERTING BEFORE”, “total”])
row.insertBefore($(“.total”, table))
} else {
//L.dlog([“APPENDING TO”, table])
row.appendTo(table)
}
$(“.no”, row).text(ntn + “.”)
row.addClass(“changed”).removeClass(“track-” + tn + ” track-” + (tn+1) + ” track-” + (tn-1)).addClass(“track-” + ntn)
//L.dlog([“ALTERING CLASSES ON”, row])
L.UI.editor.highlightrow(row)
}
bar.remove()
})
bar.show()
},
addtrack: function(el){
if($(“.addtrackbar”).length > 0 && !$(“.addtrackbar”).is(“:hidden”)){ // We’re already adding a track
alert(“Please finish adding the track you’re currently adding before attempting to add a new one.”);
return false
}
el = (this != window && this != L.UI.editor) ? this : el
L.dlog([“ADD TRACK”, arguments, el])
var section = $(el).parents(“.section”)
var table = $(“table tbody”, section)
var eid = L.UI.editor.geteid(table)
var tracklist = L.UI.editor.tracklist(eid)
var wo = table.parents(“.twrap”).offset()
var placeholder = $(“<tr class="placeholder-new"><td class="no">&nbsp;</td><td class="title"></td><td class="length"></td><td class="editbtns"></td></tr>”).prependTo(table)
var bar = L.UI.editor.createeditbar($(“td”, placeholder)[0], “addtrackbar”)
var titleEl = “select[name=title]”, addhint = “(Click here to add featured artists, etc.)”, addvhint = “(Click here to add version)”
placeholder.removeClass(“placeholder-new”).addClass(“placeholder”)
// BAR ––––––––––—
bar.html(
“<div class="no nofield field"><label for="editb-no" title="Track number">No</label><input type="text" name="no" id="editb-no" maxlength="3" /></div>”
+ “<div class="field"><label for="editb-title">Title (excluding features and versions)</label><select id="editb-title" name="title"><option value="" class="noop">Select or type new…</option><option value="titletype" class="active">Add a non-listed track…</option></select><input type="text" name="titletype" class="title widetitle" id="editb-titletype" style="display:none" maxlength="255" /></div>”
+ “<div class="fieldarea" style="display:none"></div>”
+ “<div class="button" style="display:none"><a class="button addbutton" href="javascript://">Add field <span class="addhint">” + addhint + “</span></div>”
+ “<div class="field length"><label for="editb-length" title="Track length">H:MM:SS</label><input type="text" name="length" id="editb-length" maxlength="8" /></div>”
+ “<div class="done"><a class="button savebutton" href="javascript://">Add <a class="button cancelbutton" href="javascript://">Cancel</div>”
)
var select = $(“select”, bar)[0], tracks = lsvars.allTracks[lsvars.aid]
$(“.no input”, bar).val(L.ol(tracklist) + 1)
function inputshow(){
$(select.nextSibling).show().focus()
$(select).hide()
$(“.addhint”, bar).text(addhint)
$(“.addbutton”, bar).parent().show()
$(“input[name=length]”, bar).removeAttr(“disabled”).val(“”)
L.UI.editor.patchtitlefields(bar)
titleEl = “input[name=titletype]”
}
function trackselected(){
if(!isNaN(parseInt(this.value))){
var tvid = L.parse.tvid(this.value)
var tid = tvid[0], vid = tvid[1], ti = lsvars.allTracks[lsvars.aid][this.value]
if(vid){
$(“input[name=length]”, bar).attr(“disabled”, true).val(L.format.secondsToLength(ti.versionlength))
$(“.addhint”, bar).text(addhint)
$(“.addbutton”, bar).parent().hide()
} else {
$(“input[name=length]”, bar).removeAttr(“disabled”).val(L.format.secondsToLength(ti.length))
$(“.addhint”, bar).text(addvhint)
$(“.addbutton”, bar).parent().show()
}
} else {
inputshow()
}
}
//$(“option”, select).click(inputshow)
if(!L.oe(tracks)){ // We have other tracks by this artist stored
for(var i in tracks){
var o = document.createElement(“option”)
o.value = tracks[i].tvid ? tracks[i].tvid : L.format.tvid(tracks[i].tid, tracks[i].vid)
o.innerHTML = tracks[i].title
//$(o).click(trackselected)
select.appendChild(o)
}
$(select).change(trackselected)
} else {
inputshow() // No tracks stored, no need to have a dropdown
}
$(“div.length”, bar).css({ position: “absolute”, left: ($(“.length”).offset().left - wo.left) + 3 })
// MODAL ––––––––––
$(“.addbutton”, bar).click(function(){
var track = L.trim($(titleEl, bar).val()), tid = 0, vid = 0, ti = {}
var by, byline, version
// We have something typed in already (maybe this should be a loop someday?)
if($(“input[name=by]”)) { by = $(“input[name=by]”).val() }
if($(“input[name=byline]”)) { byline = $(“input[name=byline]”).val() }
if($(“input[name=version]”)){ version = $(“input[name=version]”).val() }
if(titleEl.substr(0,6) == “select”){ // We have something selected
var tvid = L.parse.tvid(track)
tid = tvid[0]
vid = tvid[1]
ti = lsvars.allTracks[lsvars.aid][track]
track = ti.title
by = by ? L.he(by) : ti.by // Populate if not already overwritten by the form fields
byline = byline ? L.he(byline) : ti.byline
version = version ? L.he(version) : ti.versiontitle
}
if(track != “”){
var length = L.trim($(“input[name=length]”, bar).val())
var versiondefault = (version && version in L.oc(L.defaultversions)), versions = “”, v
for(var i in L.defaultversions){
v = L.defaultversions[i]
versions += “<option” + (version == v ? ” selected="selected"” : “”) + “>” + v + “</option>”
}
L.UI.modal.open(
“<h2 class="title">Add field to new track</h2><div class="content">”
+ “<p class="nt">If your track matches any of the below edge cases, please fill out the appropriate information:</p>”
+ (!tid ? “<div class="subform"><h3>The track is a collaboration between multiple artists</h3>”
+ “<p class="l"><label for="addf-byline">Byline: </label>( <input type="text" id="addf-byline" name="byline" value="” + (byline ? byline : “”) + “" /> )<br />Add {{}} around the artist names. Example: featuring Beyoncé”//</p>”
+ “<br />Example: Telephone (<span class="highlight">featuring Beyoncé</span>) by Lady Gaga</p>”
+ “<p class="l"><label for="addf-by">By: </label><input type="text" id="addf-by" name="by" value="” + (by ? L.format.bracketize(by) : “” + lsvars.artist + “”) + “" /><br />Add {{}} around the artist names. Example: Brandy & Monica”//</p>”
+ “<br />Example: The Boy is Mine by <span class="highlight">Brandy &amp; Monica</span></p></div>” : “”)
+ (!vid ? “<div class="subform"><h3>The track I&#8217;m listing is a non-standard version (e.g. remix) of a track</h3>”
+ “<p class="l"><label for="addf-version">Version: </label>( <select id="addf-version" name="version"” + (version && !versiondefault ? ” style="display:none"” : “”) + “><option class="noop" value="">Select…</option>” + versions + “<option value="versiontype" class="active">Type your own…</option></select>”
+ “<input type="text" name="versiontype" id="addf-versiontype"” + (version && !versiondefault ? ” value="” + version + “"” : ” style="display:none"”) + ” /> )<br />Add {{}} around the artist names. Example: Passion Pit Remix</p></div>” : “”)
+ “<div class="extras"><input type="checkbox" name="bonus" id="addf-bonus" /> <label for="addf-bonus">Bonus track</label></div>”
+ “<div class="barhead">Preview</div>”
+ “<div id="addf-preview" class="preview bar"><div class="right">” + L.he(length) + “</div> <a href="javascript://nothing">” + (ti && ti.ctitle ? ti.ctitle : track) + “”
+ “<span class="feat">” + (byline ? ” (” + L.format.linkartists(byline, true) + “)” : “”) + “</span><span class="version">” + (version ? ” (” + L.format.linkartists(version, true) + “)” : “”) + “</span> by <span class="artist">” + (by ? L.format.linkartists(by, true) : “” + lsvars.artist + “”) + “</span></div>”
+ “<p class="buttons"><a class="button addbutton" href="javascript://">Add field<span class="or"> or <a class="cancel" href="javascript://">Cancel</span></p>”
+ “</div>”,
“track-addfield”
)
var modal = L.j(L.UI.modal.el)
$(“a.cancel”, modal).click(L.UI.modal.close)
if(!tid){
$(“input[name=byline]”, modal).keyup(function(){ var v = $(this).val(); $(“.preview .feat”, modal).html(L.format.linkartists((v ? ” (” + L.he(v) + “)” : “”), true)); byline = v?v:”“; L.UI.modal.position() })
$(“input[name=by]”, modal).keyup(function(){ var v = $(this).val(); $(“.preview .artist”, modal).html(v ? L.format.linkartists(L.he(v), true) : “” + lsvars.artist + “”); by = v?v:”“; L.UI.modal.position() })
}
if(!vid){
function versiontyped(el){
var v = $(typeof el != “undefined” && !(“target” in el) ? el : this).val()
$(“.preview .version”, modal).html(L.format.linkartists((v ? ” (” + L.he(v) + “)” : “”), true))
version = v?v:””
}
$(“select[name=version]”).change(function(){
var v = $(this).val()
if(v == “versiontype”){
$(this).hide()
$(this.nextSibling).show().focus()
L.UI.editor.patchtitlefields($(this.nextSibling), versiontyped)
} else {
$(“.preview .version”, modal).text(v ? ” (” + v + “)” : “”)
version = v?v:””
L.UI.modal.position()
}
})
var vtype = $(“input[name=versiontype]”, modal).keyup(versiontyped)
if(!vtype.is(“:hidden”)){
L.UI.editor.patchtitlefields(vtype, versiontyped)
}
}
$(“.addbutton”, modal).click(function(){
// Save this modal shiz!
// i : key
// f[i]: value
var f = { by:by, byline:byline, version:version }, fd = false, fa = $(“.fieldarea”, bar), hasVal
for(var i in f){
hasVal = !!f[i]
if(i == “by” && f[i] == “” + lsvars.artist + “”){ hasVal = false } // Getting rid of the default val
if(hasVal){
var p = (i == “byline” || i == “version”) // Parentheses?
var el = $(“input[name=” + i + “]”, fa)
if(el.length > 0){
el.val(f[i])
} else {
var field = $(“<div class="field"><label for="editb-” + i + “">” + L.ucf(i) + “</label>” + (p ? “( ” : “”) + “<input type="text" name="” + i + “" id="editb-” + i + “" />” + (p ? ” )” : “”) + “</div>”)
$(“input”, field).val(f[i])
field.appendTo(fa)
}
fd = true
}
}
if(fd){
$(“.addhint”, bar).hide()
fa.show()
}
if($(“input[name=bonus]”, modal).is(“:checked”)){ $(bar).addClass(“bonus”) }
L.UI.modal.close()
})
} else {
alert(“Please type a song name (without any featured artists or versions) in the field before adding a new field.”)
}
})
// SAVING –––––––––—
$(“.savebutton”, bar).click(function(){
var select = $(“select”, bar), input = $(“input[name=titletype]”, bar),
number = $(“input[name=no]”, bar), length = $(“input[name=length]”, bar), n
if((!select.is(“:hidden”) && select.val() && L.pi(select.val())) || (select.is(“:hidden”) && input.val())){ // Something typed or selected
if(number.val()){ // Something typed in number
if(n = L.parse.number(number.val())){ // Number makes sense
if(length.val() || (!length.val() && confirm(“You haven’t specified any track length. If this is because you don’t know the length, click OK to continue. If this was a mistake, click Cancel to go back.”))){
var lengthval = length.val().replace(/./g, “:”);
if(L.parse.length(lengthval) || L.trim(lengthval) === “”){
var tracks = L.UI.editor.propagatetracklist(eid)
// Fix older tracks with higher track numbers
L.UI.editor.pushtracklist(n, eid)
// The information we save about the track
var ntrack = {
tvid: “0”, // If …
tid: 0, // If we already know the tid
vid: 0, // If we already know the vid
title: “”, // If it’s a new track
by: “”,
byline: “”,
version: “”, // If it’s a new version
number: n,
length: 0,
// Album/edition-related metadata
//single: -1, // <— as in, I don’t really fuckin’ know. // We don’t do this here anymore
bonus: 0
}
if(!select.is(“:hidden”) && select.val() && L.pi(select.val())){ // SELEKTOOOOOR
L.dlog(“SELEKTORRRRR”)
var tvid = L.parse.tvid(select.val())
ntrack.tid = tvid[0]
ntrack.vid = tvid[1]
ntrack.tvid = select.val()
ntrack.title = lsvars.allTracks[lsvars.aid][ntrack.tvid].title // or tvid?
ntrack.ctitle = lsvars.allTracks[lsvars.aid][ntrack.tvid].ctitle // For fucks sake, another fucking redudancy or whatever the fuck fuck.
ntrack.by = lsvars.allTracks[lsvars.aid][ntrack.tvid].by
ntrack.byline = lsvars.allTracks[lsvars.aid][ntrack.tvid].byline //TXDO: WHAT ABOUT VERSION HERE?!
if(ntrack.vid){ // ANSWER: THIS?
ntrack.version = lsvars.allTracks[lsvars.aid][ntrack.tvid].versiontitle
} else {
ntrack.version = $(“input[name=version]”, bar) ? $(“input[name=version]”, bar).val() : “”
}
L.dlog(ntrack)
} else { // If we typed, it’s time to get the info
ntrack.title = L.ucf(input.val()) //TXDO: WHAT ABOUT L.HE?!?!
ntrack.htitle = L.he(ntrack.title) // ANSWER: THIS
ntrack.by = $(“input[name=by]”, bar) ? $(“input[name=by]”, bar).val() : “”
ntrack.byline = $(“input[name=byline]”, bar) ? $(“input[name=byline]”, bar).val() : “”
ntrack.version = $(“input[name=version]”, bar) ? $(“input[name=version]”, bar).val() : “”
}
ntrack.length = L.trim(lengthval)
ntrack.bonus = $(bar).is(“.bonus”)
tracks[n] = ntrack
// Update DOM
$(“.no”, placeholder).text(n + “.”)
$(“.length”, placeholder).text(ntrack.length ? ntrack.length : “”)
//$(“.title”, placeholder).html(L.format.track(ntrack, true))
L.dlog([ntrack, JSON.stringify(ntrack), L.UI.editor.trackhtml(ntrack)])
$(“.title”, placeholder).html(“”).append(L.UI.editor.trackhtml(ntrack))
$(“.editbtns”, placeholder).html(“<a class="button changebutton" href="javascript://">Change <a class="button deletebutton" href="javascript://">Delete”)
$(“.editbtns a.changebutton”, placeholder).click(L.UI.editor.changetrack)
$(“.editbtns a.deletebutton”, placeholder).click(function(){ L.UI.editor.deletetrack(this, eid) }).hover(L.UI.editor.deletehover)
// GUH-RINNNNNNNN :D
if($(“.track-” + (n+1), table).length > 0){
placeholder.insertBefore($(“.track-” + (n+1), table))
} else if($(“.total”, table).length > 0){
$(“.last:not(.total)”, table).removeClass(“last”)
placeholder.insertBefore($(“.total”, table))
if($(“.total”, table).is(“:hidden”)){
placeholder.addClass(“last”)
}
} else {
$(“.last”, table).removeClass(“last”)
placeholder.appendTo(table).addClass(“last”)
}
if(ntrack.bonus){ placeholder.addClass(“bonus”) }
L.UI.editor.updatetracktotal((ntrack.length ? L.format.lengthToSeconds(ntrack.length) : 0), eid)
placeholder.removeClass(“placeholder”).addClass(“changed track-” + n)
$(“.noop”, table).remove()
if(eid){ $(“a.copy-tracks”, section).remove() }
bar.remove()
L.UI.editor.highlightrow(placeholder)
// Auto add next track
L.UI.editor.addtrack(el)
} else {
alert(“The track length specified was not correct format. Accepted format is H:MM:SS. Example: 3:23. If you don’t know what the track length is, please leave the field empty.”)
}
}
} else {
alert(“Invalid track number specified.”)
}
} else {

Reply

MattMatt

This was unnecessary. :|

LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOL.

Reply

keenahnkeenahn

Well I’m just glad we can’t execute random javascript :D

‘” DROP DATABASE leadsingle;

Reply

mikkelmariusmikkelmarius

Locking this thread like a boss.

Reply

Show 1 reply

mikkelmariusmikkelmarius

How do I link to stuff? Those of you who understand Danish should really check out Ego by Per Vers.

Reply

fionafiona

I came here to insult Frits, as per the community guidelines.

Frits! Thou churlish toad-spotted bitch-wolf!

Reply

FritsFrits

Milk was spilled, Fiona. I hope you’re happy! :(

Reply

rotanerotane

Random first comment.
Boards of Canada rules!

Oh and Frits, feel insulted, kthxbai.

Reply

FritsFrits

YOU READ THE RULES! Fuck yeah.

Reply

fionafiona

I am disappointed at the lack of Frits insults in here. You guys are letting me down :(

Reply

rotanerotane

True. But it’s the bastard’s own fault for hiding this rule where no-one ever finds it.

Reply

Post a reply to this thread

Please create an account or log in in order to participate.