w instrukcji zmienia się tylko kod dodawany do pliku public/js/ips.topic.js
/* ------------------------------ */
/**
* Parsing ISO 8601 date by Daniel http://dansnetwork.com/2008/11/01/javascript-iso8601rfc3339-date-parser/
*/
parseIsoDate: function(s){
var re=new RegExp(/(\d\d\d\d)\D?(\d\d)\D?(\d\d)\D?(\d\d)\D?(\d\d\D?(\d\d\.?(\d*))?)(Z|[+-]\d\d?(:\d\d)?)?/);
var a=re.exec(s).slice(1).map(function(x,i){
if (i==6 && x) x=parseInt(x,10)/Math.pow(10,x.length)*1000;
return parseInt(x,10)||0;
});
return new Date(
Date.UTC(a[0],a[1]-1,a[2],a[3]-(a[7]||0),a[4],a[5],a[6]));
},
/* ------------------------------ */
/**
* (Pav30) Selective quoting 1.0 by Pavulon
*/
selective_quote: function()
{
// looking for selection
var sel;
if (window.getSelection)
{
sel = window.getSelection();
}
else if (document.getSelection)
{
sel = document.getSelection();
}
else if (document.selection)
{
//IE suxxx
sel = document.selection.createRange();
}
else
return alert(ipb.lang['no_selection']);
if (sel.isCollapsed) { return alert(ipb.lang['no_selection']); }
var post, name, timestamp, date, content;
var parent = 0;
// litle IE "fix"
var parent1 = ( document.selection ) ? sel.parentElement() : sel.anchorNode.parentNode;
var parent2 = ( document.selection ) ? sel.parentElement() : sel.focusNode.parentNode;
// avoid infinite loop
var num = 20;
while ( ! parent && --num>0 )
{
// check 4 correct object at the begining
if ( !parent1.id || (parent1.id && !parent1.id.match(/post_id_/ ) ) )
{
if ( parent1.parentNode )
{
parent1 = parent1.parentNode;
}
else
{
break;
}
}
// and the end of selection
if ( !parent2.id || (parent2.id && !parent2.id.match(/post_id_/ ) ) )
{
if ( parent2.parentNode )
{
parent2 = parent2.parentNode;
}
else
{
break;
}
}
if ( parent1 == parent2 && parent1.id && parent1.id.match(/post_id_/ ) )
{
// we've got it =]
parent = parent1;
} else if ( parent1.id && parent1.id.match(/post_id_/ ) && parent2.id && parent2.id.match(/post_id_/ ) )
{
// starting post has another id than ending
break;
}
}
if ( parent )
{
post = parent.id.replace('post_id_', '');
if ( ! isNaN(post) )
{
// we got post id and we look 4 another infos
var childs = $('post_id_'+post).getElementsByTagName("a");
for (i = 0; i < childs.length; i++)
{
// poster name link should have correct class
if (childs[i].className == 'url fn')
{
name = childs[i].innerHTML;
}
}
childs = $('post_id_'+post).getElementsByTagName("abbr");
for (i = 0; i < childs.length; i++)
{
if (childs[i].className == 'published')
{
//convert ISO 8601 to timestamp
var t = ipb.topic.parseIsoDate(childs[i].title)
timestamp = t.getTime()/1000.0;
date = childs[i].innerHTML;
// another IE fix, cause "Internet Explorer for Windows does not support the <abbr> element"
if ( !date )
{
var re=new RegExp(/<abbr([^>]*)>([^<]*)<\/abbr>/i);
var b=re.exec($('post_id_'+post).innerHTML);
date = b[b.length-1];
}
}
}
}
content = ( document.selection ) ? sel.text : sel.toString();
} else {
return alert(ipb.lang['wrong_selection']);
}
// preparing content
var quote = '[quote';
if ( name ) { quote = quote + ' name=\'' + name + '\''; }
if ( date ) { quote = quote + ' date=\'' + date + '\''; }
if ( timestamp ) { quote = quote + ' timestamp=\'' + timestamp + '\''; }
if ( post ) { quote = quote + ' post=\'' + post + '\''; }
quote = quote + ']\n';
quote = quote + content;
quote = quote + '\n[/quote]'
if ( $('fast-reply_textarea') )
{
// load fast-reply editor if it is not created before
if( $('fast-reply_textarea').hasClassName('unloaded_editor') )
{
if( !in_use )
{
if( $('fast-reply_toolbar_1') ){
$('fast-reply_toolbar_1').show();
}
if( $('fast-reply_toolbar_2') ){
$('fast-reply_toolbar_2').show();
}
$('fast-reply_textarea').removeClassName('unloaded_editor').value = '';
// we're creating editor, so observing is no longer needed
Event.stopObserving( $('fast-reply_textarea'), 'focus' );
ipb.editors[ 'fast-reply' ] = new ipb.editor( 'fast-reply', USE_RTE );
$( ipb.editors['fast-reply'] ).resize_to( 250 );
try {
ipb.editors[ 'fast-reply' ].editor_window.focus();
} catch(err) { }
in_use = 1;
}
}
$('fast-reply_textarea').value = $('fast-reply_textarea').value + quote;
$('fast-reply_textarea').focus();
}
},