Ja mogę napisać skrypt .js, ale do was należy:
-
stworzenie obrazka wielokrotnego cytatu [bo cytuj przenosi do pisania odpowiedzi tylko z tym postem], a w zasadzie dwoch obrazkow => on i off (zeby pokazac ktory post zostal dodany do listy cytowanych).
-
obrazek powinien miec id w formacie "quote_" . $id_posta
PHP mogę naskrobać jeśli potrzeba ;-). Generalnie wygląda to następująco:
użytkownik naciska przycisk, id posta dodawane jest do ciasteczka coyote_quotes ktory czytany jest pozniej przez posting.php [uwaga! musi zostac najpierw odpowiednio wyczyszczony]
// edit, mam:
1: proponuje stworzyc plik common.js z nastepujacymi funkcjami, ktore obsluguja rozne sposoby pobierania elementow w przegladarkach jak i dodaja funkcjonalnosc typu in_array znane z PHP.
function get_object(objectid)
{
if (document.getElementById)
{
return document.getElementById(objectid);
}
else if (document.all)
{
return document.all[objectid];
}
else if (document.layers)
{
return document.layers[objectid];
}
else
{
return null;
}
}
function get_tags(tagsparent, tag)
{
if (tagsparent == null)
{
return new Array();
}
else if (typeof tagsparent.getElementsByTagName != 'undefined')
{
return tagsparent.getElementsByTagName(tag);
}
else if (tagsparent.all && tagsparent.all.tags)
{
return tagsparent.all.tags(tag);
}
else
{
return new Array();
}
}
function get_cookie(name)
{
cookie_name = name + '=';
cookie_length = document.cookie.length;
cookie_begin = 0;
while (cookie_begin < cookie_length)
{
value_begin = cookie_begin + cookie_name.length;
if (document.cookie.substring(cookie_begin, value_begin) == cookie_name)
{
var value_end = document.cookie.indexOf(';', value_begin);
if (value_end == -1)
{
value_end = cookie_length;
}
return unescape(document.cookie.substring(value_begin, value_end));
}
cookie_begin = document.cookie.indexOf(' ', cookie_begin) + 1;
if (cookie_begin == 0)
{
break;
}
}
return null;
}
function in_array(ineedle, haystack, caseinsensitive)
{
var needle = new String(ineedle);
if (caseinsensitive)
{
needle = needle.toLowerCase();
for (var i in haystack)
{
if (haystack[i].toLowerCase() == needle)
{
return i;
}
}
}
else
{
for (var i in haystack)
{
if (haystack[i] == needle)
{
return i;
}
}
}
return -1;
}
2: sam kod odpowiedzialny za przyciski cytatów. powinno mieć id = "quote_" . $id_posta , a obrazki [kolejno aktywny i nieaktywny przycisk] quote_on i quote_off
function quotes_init(obj)
{
var postid;
var cookie_ids = get_cookie('coyote_quotes');
cookie_ids = (cookie_ids != null && cookie_ids != '') ? cookie_ids.split(',') : new Array();
var images = get_tags(obj, 'img');
for (var i = 0; i < images.length; i++)
{
if (images[i].id && images[i].id.substr(0, 6) == 'quote_')
{
postid = images[i].id.substr(6);
images[i].onclick = function(e)
{
return quote_click(this.id.substr(6));
};
switch_quote_img(postid, (in_array(postid, cookie_ids) > -1 ? true : false));
}
}
}
function quote_click(postid)
{
var cookie_ids = get_cookie('coyote_quotes');
var cookie_text = new Array();
var selected = false;
if (cookie_ids != null && cookie_ids != '')
{
cookie_ids = cookie_ids.split(',');
for (i in cookie_ids)
{
if (cookie_ids[i] == postid)
{
selected = true;
}
else if (cookie_ids[i])
{
cookie_text.push(cookie_ids[i]);
}
}
}
switch_quote_img(postid, (selected ? false : true));
if (!selected)
{
cookie_text.push(postid);
}
set_cookie('coyote_quotes', cookie_text.join(','));
return false;
}
function switch_quote_img(postid, state)
{
var quote_obj = get_object('quote_' + postid);
quote_obj.src = (state == true) ? quote_obj.src.replace(/\/quote_off\.([a-zA-Z]+)$/, '/quote_on.$1') : quote_obj.src.replace(/\/quote_on\.([a-zA-Z]+)$/, '/quote_off.$1');
}
quotes_init(get_object('post-list'));
Tabela zawierajaca posty powinna miec tez id = "post-list"