|
j3blip = {}; |
|
j3blip.start = function() { |
|
//alert('zaladowano'); |
|
window._j3blip_loading = true; |
|
var act = window._j3blip, i; |
|
window._j3blip = { |
|
push: j3blip.push |
|
}; |
|
for(i=0; i< act.length; i++) { |
|
j3blip.analyse(act[i]); |
|
} |
|
} |
|
j3blip.push = function(t) { |
|
//alert('push'); |
|
try { |
|
j3blip.analyse(t); |
|
} catch(e) { |
|
alert('Błąd: '+e); |
|
} |
|
} |
|
j3blip.analyse = function(t) { |
|
if(j3blip.a[t[0]]) { |
|
j3blip.a[t[0]](t); |
|
} |
|
} |
|
j3blip.a = {}; |
|
//wyświetlanie blipnięcia: |
|
j3blip.a.blip = function(t) { |
|
//alert('Starting...'); |
|
var b = t[1], e = t[2]; |
|
if(!j3blip.blip_waitlist[b]) { |
|
//alert('pobieranie '+b) |
|
j3blip.blip_waitlist[b] = []; |
|
j3blip.blip_waitlist[b].push(e); |
|
var d = (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]), s = document.createElement('script'); |
|
s.type = 'text/javascript'; |
|
s.src = 'http://api.blip.pl/statuses/'+b+'.json?callback=j3blip.blip_req&include=pictures'; |
|
d.appendChild(s); |
|
} else { |
|
j3blip.blip_waitlist[b].push(e); |
|
} |
|
} |
|
j3blip.blip_req = function(t) { |
|
//alert('odp'); |
|
try { |
|
if(j3blip.blip_waitlist[t.id]) { |
|
var i, e, nb; |
|
for(i=0; i<j3blip.blip_waitlist[t.id].length; i++) { |
|
e = j3blip.blip_waitlist[t.id][i]; |
|
nb = { |
|
id: i.id, |
|
body: t.body, |
|
autor: t.user_path.replace(/\/users\//, '') |
|
} |
|
if(t.pictures) { |
|
nb.image = t.pictures[0].id |
|
nb.image_full = t.pictures[0].url |
|
} |
|
nb = j3blip.blipniecie(nb); |
|
e.parentNode.replaceChild(nb, e); |
|
} |
|
delete j3blip.blip_waitlist[t.id]; |
|
} |
|
} catch(e) { |
|
alert('Błąd: '+e); |
|
} |
|
} |
|
j3blip.blipniecie = function(t) { |
|
var d = document.createElement('div'), a = document.createElement('a'), img = new Image(), br = document.createElement('br'), |
|
tn1 = document.createTextNode('\u21d2'), tn2 = document.createTextNode(' | '), login = document.createTextNode(t.autor), |
|
tn3 = document.createTextNode(': '), a2 = document.createElement('a'), tn4 = document.createTextNode(' '),b = document.createElement('span'); |
|
|
|
img.src = 'http://blip.pl/users/'+t.autor+'/avatar/femto.jpg'; |
|
img.border = '0'; |
|
a.appendChild(img); |
|
a.appendChild(login); |
|
a.href = 'http://blip.pl/users/'+t.autor+'/dashboard'; |
|
|
|
a2.innerText = '[blip]'; |
|
a2.href = 'http://blip.pl/s/'+t.id; |
|
|
|
b.innerHTML = j3blip_blipniecie_wiadomosc(t.body); |
|
|
|
d.appendChild(tn1); |
|
d.appendChild(a); |
|
d.appendChild(tn3); |
|
d.appendChild(b); |
|
|
|
if(t.image) { |
|
var f = document.createElement('a') |
|
f.href = '#'; |
|
f.j3blip_imageurl = t.image_full; |
|
f.innerText = '[FOTO]'; |
|
f.onclick = j3blip.blipniecie_image; |
|
d.appendChild(tn4); |
|
d.appendChild(f); |
|
} |
|
|
|
//d.appendChild(); |
|
d.appendChild(tn2); |
|
d.appendChild(a2) |
|
return d; |
|
} |
|
j3blip.blipniecie_image = function() { |
|
try { |
|
var url = this.j3blip_imageurl, img = this.j3blip_imageo; |
|
if(!img) { |
|
var a = document.createElement('a'), i = new Image(), br = document.createElement('br'); |
|
a.href = url; |
|
i.src = url; |
|
i.style.maxWidth='100%'; |
|
a.appendChild(i); |
|
this.parentNode.appendChild(br); |
|
this.parentNode.appendChild(i); |
|
this.j3blip_imageo = i; |
|
return; |
|
} |
|
if(!img.style.display || img.style.display == 'block') { |
|
img.style.display = 'none'; |
|
} else { |
|
img.style.display = 'block'; |
|
} |
|
} catch(e) { |
|
alert('Błąd: '+e); |
|
} |
|
} |
|
j3blip_blipniecie_wiadomosc = function(msg) { |
|
msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); |
|
var regexps = { |
|
/*link: { |
|
r: new RegExp('(https{0,1}://[^rdir\.pl][^blip\.pl][^ ]+)', 'g'), |
|
t2: ['<a class="blipniecie_inmsg_linko" href="$1" target="_blank">$1</a>'] |
|
},*/ |
|
link_rdir: { |
|
r: new RegExp('http://rdir\.pl\/([0-9a-zA-Z]+)', 'g'), |
|
t2: '<a class="blipniecie_inmsg_link" href="http://rdir.pl/$1">[link]</a>' |
|
}, |
|
blip_s: { |
|
r: new RegExp('http://w?w?w?\.?blip\.pl\/s\/([0-9]+)', 'g'), |
|
t2: '<a class="blipniecie_inmsg_blips" href="http://blip.pl/s/$1">[blip]</a>' |
|
}, |
|
blip_dm: { |
|
r: new RegExp('http://w?w?w?\.?blip\.pl\/dm\/([0-9]+)', 'g'), |
|
t2: '<a class="blipniecie_inmsg_blipdm" href="http://blip.pl/dm/$1">[blip-dm]</a>' |
|
}, |
|
blip_pm: { |
|
r: new RegExp('http://w?w?w?\.?blip\.pl\/pm\/([0-9]+)', 'g'), |
|
t2: '<a class="blipniecie_inmsg_blippm" href="http://blip.pl/pm/$1" target="_blank" >[blip-pm]</a>' |
|
}, |
|
tag: { |
|
r: new RegExp('#([0-9a-zA-Z-_ąĄćĆęĘłŁńŃóÓŚśżŻźŹ]+)', 'g'), |
|
t2: '<a class="blipniecie_inmsg_tag" href="http://blip.pl/tags/$1" >#$1</a>' |
|
}, |
|
email: { |
|
r: new RegExp('([0-9a-zA-Z_.-]+)@([0-9a-zA-Z-]+).([a-zA-Z]+)', 'g'), |
|
t2: '<a class="blipniecie_inmsg_email" href="mailto:$1@$2.$3">$1@$2.$3</a>' |
|
}, |
|
mention: { |
|
r: new RegExp('\\^([0-9a-zA-Z-_]+)', 'g'), |
|
t2: '<a class="blipniecie_inmsg_mention" href="http://blip.pl/users/$1/dashboard">^$1</a>' |
|
} |
|
}, i; |
|
|
|
for(i in regexps) { |
|
i = regexps[i]; |
|
msg = msg.replace(i.r, i.t2); |
|
} |
|
return msg; |
|
} |
|
j3blip.blip_waitlist = {}; |
|
//koniec wyświetlania blipnięcia |
|
j3blip.start(); |