Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
blip@WTW

blip@WTW RegExps

Avatar autora blipnięcia

RegExp:

^<a [a-z0-9=:/\._"]* href="http://blip.pl/users/([a-z0-9]*)/dashboard" [a-z0-9=:/\._"]*>[a-z0-9]*</a>

Format:

<a href="http://blip.pl/users/$1/dashboard"><img border="0" src="http://blip.pl/users/$1/avatar/femto.jpg" title="$1" />$1</a>

Zaznaczenie opocji "Ignoruj wielkość znaków" jest obowiązkowe. Działa tylko dla statusów.

Domyślnie avatar ma rozmiary 15x15 px, można wyświetlać avatary w innych rozmiarach zamieniając femto.jpg na:

  • nano.jpg 30x30 px
  • pico.jpg 50x50 px
  • standard.jpg 90x90 px

Wyświetlanie obrazków w oknie rozmowy

RegExp:

\[FOTO\]( \| <a.*/(dm|s)/([0-9]*)".*>\[(dm|blip)\]</a>)$

Format:

<a href="#" onclick="var p=this.parentNode,j=document.getElementById('bwi_$3');if(j){var s=j.style.display;j.style.display=!s||s=='block'?'none':'block'}else{var i=new Image,b=document.createElement('br'),a=document.createElement('a');i.src='http://rimg.blipworld.pl/$3';i.id='bwi_$3';i.border='0';i.style.maxWidth='100%';a.href='http://rimg.blipworld.pl/$3';a.appendChild(i);p.appendChild(b);p.appendChild(a)};">[FOTO]</a>$1

Działa tylko dla statusów i wiadomości kierowanych (DM).

Wyświetlanie cytatów w oknie rozmowy

RegExp:

<a href="http://blip\.pl/s/([0-9]+)" [a-z0-9=:/\._"]* [a-z0-9=:/\._"]*>\[blip\]</a>

Format:

<a href="http://blip.pl/s/$1" title="Kliknij aby wyświetlić!" onclick="var f='https://gist.github.com/raw/988828/j3blip.js';if(!window._j3blip)window._j3blip=[];if(!window._j3blip_loading){window._j3blip_loading=!0;var d=document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0],s=document.createElement('script');s.type='text/javascript';s.src=f;s.async=!0;d.appendChild(s)}var e=document.createElement('div');this.parentNode.appendChild(e);this.setAttribute('onclick','');window._j3blip.push(['blip',$1,e]); return false;">[blip]</a>

RegExp ten załaduje do twojego okna rozmowy dodatkowy plik JS (dokładnie ten) który pomoże w rozwijaniu blipnięć.

Tym co jest poniżej tego napisu się nie interesuj, nie ma tam nic ciekawego ;).

j3blip={};j3blip.start=function(){window._j3blip_loading=!0;var a=window._j3blip,b;window._j3blip={push:j3blip.push};for(b=0;b<a.length;b++)j3blip.analyse(a[b])};j3blip.push=function(a){try{j3blip.analyse(a)}catch(b){alert("B\u0142\u0105d: "+b)}};j3blip.analyse=function(a){if(j3blip.a[a[0]])j3blip.a[a[0]](a)};j3blip.a={};
j3blip.a.blip=function(a){var b=a[1],a=a[2];if(j3blip.blip_waitlist[b])j3blip.blip_waitlist[b].push(a);else{j3blip.blip_waitlist[b]=[];j3blip.blip_waitlist[b].push(a);var a=document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0],c=document.createElement("script");c.type="text/javascript";c.src="http://api.blip.pl/statuses/"+b+".json?callback=j3blip.blip_req&include=pictures";a.appendChild(c)}};
j3blip.blip_req=function(a){try{if(j3blip.blip_waitlist[a.id]){var b,c,d;for(b=0;b<j3blip.blip_waitlist[a.id].length;b++){c=j3blip.blip_waitlist[a.id][b];d={id:b.id,body:a.body,autor:a.user_path.replace(/\/users\//,"")};if(a.pictures)d.image=a.pictures[0].id,d.image_full=a.pictures[0].url;d=j3blip.blipniecie(d);c.parentNode.replaceChild(d,c)}delete j3blip.blip_waitlist[a.id]}}catch(e){alert("B\u0142\u0105d: "+e)}};
j3blip.blipniecie=function(a){var b=document.createElement("div"),c=document.createElement("a"),d=new Image;document.createElement("br");var e=document.createTextNode("\u21d2"),f=document.createTextNode(" | "),i=document.createTextNode(a.autor),j=document.createTextNode(": "),g=document.createElement("a"),k=document.createTextNode(" "),h=document.createElement("span");d.src="http://blip.pl/users/"+a.autor+"/avatar/femto.jpg";d.border="0";c.appendChild(d);c.appendChild(i);c.href="http://blip.pl/users/"+
a.autor+"/dashboard";g.innerText="[blip]";g.href="http://blip.pl/s/"+a.id;h.innerHTML=j3blip_blipniecie_wiadomosc(a.body);b.appendChild(e);b.appendChild(c);b.appendChild(j);b.appendChild(h);if(a.image)c=document.createElement("a"),c.href="#",c.j3blip_imageurl=a.image_full,c.innerText="[FOTO]",c.onclick=j3blip.blipniecie_image,b.appendChild(k),b.appendChild(c);b.appendChild(f);b.appendChild(g);return b};
j3blip.blipniecie_image=function(){try{var a=this.j3blip_imageurl,b=this.j3blip_imageo;if(b)b.style.display=!b.style.display||b.style.display=="block"?"none":"block";else{var c=document.createElement("a"),d=new Image,e=document.createElement("br");c.href=a;d.src=a;d.style.maxWidth="100%";c.appendChild(d);this.parentNode.appendChild(e);this.parentNode.appendChild(d);this.j3blip_imageo=d}}catch(f){alert("B\u0142\u0105d: "+f)}};
j3blip_blipniecie_wiadomosc=function(a){var a=a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),b={link_rdir:{r: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: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: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: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:RegExp("#([0-9a-zA-Z-_\u0105\u0104\u0107\u0106\u0119\u0118\u0142\u0141\u0144\u0143\u00f3\u00d3\u015a\u015b\u017c\u017b\u017a\u0179]+)","g"),t2:'<a class="blipniecie_inmsg_tag" href="http://blip.pl/tags/$1" >#$1</a>'},email:{r: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:RegExp("\\^([0-9a-zA-Z-_]+)","g"),t2:'<a class="blipniecie_inmsg_mention" href="http://blip.pl/users/$1/dashboard">^$1</a>'}},c;for(c in b)c=b[c],a=a.replace(c.r,c.t2);return a};j3blip.blip_waitlist={};j3blip.start();
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, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.