Не знаю, надо ли было это писать в соответствующей теме (Спойлер)
Ну если, что надеюсь не будете на меня сердиться
Вот у меня скрипт нужного мне спойлера
<style> #button-spoiler {background-image:url('https://forumupload.ru/uploads/0000/12/13/488-1.gif'); padding:0; line-height:0; background-position:center; background-repeat:no-repeat; height:26px; width:100%} </style> <script type="text/javascript"> function tag_spolier() {var FoundErrors = ''; var enterTITLE = prompt("Введите описание спойлера", 'Спойлер'); bbcode('[spoiler]',('|'+enterTITLE+'[/spoiler]'));} if(form=document.getElementById("form-buttons")) form.getElementsByTagName("tr")[0].insertCell(19).innerHTML="<img src='/i/blank.gif' title='Вставить спойлер' id='button-spoiler' onclick=\"tag_spolier()\">" function addSpoilerSpoiler(str,from,internal){ var pos=0,pos2=0,newpos=0 if((pos=str.indexOf("[spoiler]",from))==-1) return str; if((pos2=str.indexOf("[/spoiler]"),pos+9)==-1) return str; newpos=str.indexOf("[spoiler]",pos+9) if(newpos<pos2 && newpos!=-1) str=addSpoiler(str,pos+9,true) if((pos2=str.indexOf("[/spoiler]",pos+9))==-1) return str; txt = str.substring(pos+9,pos2); if((sepPos=txt.indexOf("|",0))==-1) return str; str=str.substring(0,pos)+makeSpoilerSpoiler(txt.substring(0,sepPos),txt.substring(sepPos+1,txt.length))+str.substring(pos2+10,str.length) if( str.indexOf("[spoiler]")!=-1 && internal==false) str=addSpoilerSpoiler(str,0,false) return str} function makeSpoilerSpoiler(txt1,txt2){ txt='<div class="quote-box" style="padding:1px;background: none;border: 0;"><cite style="width:100%;margin:0;"><input class="spoiler-button" style="width:140px;font-size:10px; margin:0; cursor: pointer" type="button" value="'+txt2+'"></cite><blockquote class="quote-box" style="display:none; width: 80%;border: 1px solid black;margin:0;">'+txt1+'</blockquote></div>' return txt} $(document).ready(function(){ $("div.quote-box > cite > input.spoiler-button").click(function(){ $(this).parents("div.quote-box").find("blockquote.quote-box").toggle("normal"); }); }); if((document.URL.indexOf("viewtopic.php")!=-1) || (document.URL.indexOf("post.php")!=-1)){ elm=document.getElementById("pun-main").getElementsByTagName("div") for(x in elm) if(elm[x].className=="post-content"){ var post=elm[x] post.innerHTML=addSpoilerSpoiler(post.innerHTML,0,false)}} </script>
Дело в том, что если давать длинное название спойлера, кнопки не хватает и название получается обрезанное, вот не могли бы вы тыкнуть мне на ту строчку, где тут максимальная длинна?
Мне предложили вот этот код
<style> #button-spoiler {background-image:url('https://forumupload.ru/uploads/0000/12/13/488-1.gif'); padding:0; line-height:0; background-position:center; background-repeat:no-repeat; height:26px; width:100%} </style> <script type="text/javascript"> function tag_spoiler(){ var y = prompt("Введите описание закрытой кнопки",''); if(y!='null' && y!='' && typeof(y)!='object' && typeof(y)!='undefined'){ var x = prompt("Введите описание открытой кнопки",''); if(x=='null' || x=='' || typeof(x)=='object' || typeof(x)=='undefined') bbcode('[spoiler='+y+']','[/spoiler]'); else bbcode('[spoiler='+y+'|'+x+']','[/spoiler]');} else bbcode('[spoiler]','[/spoiler]') } function addSpoiler(str,from,internal){ var pos=0,pos2=0,pos_c=0,pos_l=0,newpos=0,string='',close='',open='', max_length=19; if((pos=str.indexOf("[spoiler",from))==-1) return str; if((pos2=str.indexOf("[/spoiler]"),pos+9)==-1) return str; if(((pos_c=str.indexOf("]",pos+8))!=-1) && ((pos_c!=pos+8)&&(pos_c!=pos+9))){ string = str.substring(pos+9,pos_c); if((pos_l = string.indexOf("|"))!=-1){ close = string.substring(0,pos_l); open = string.substring(pos_l+1,string.length); } else{ close = string; open = string; } } else{ close = 'Показать спойлер'; open = 'Скрыть спойлер'; } open = (open.length > max_length) ? open.substring(0, max_length) : open; close = (close.length > max_length) ? close.substring(0, max_length) : close; newpos=str.indexOf("[spoiler",pos+9) if(newpos<pos2 && newpos!=-1) str=addSpoiler(str,pos+9,true) if((pos2=str.indexOf("[/spoiler]",pos+9))==-1) return str; str=str.substring(0,pos)+makeSpoiler(str.substring(pos_c+1,pos2),open,close)+str.substring(pos2+10,str.length) if( str.indexOf("[spoiler")!=-1 && internal==false) str=addSpoiler(str,0,false) return str; } function makeSpoiler(txt,open,close){ txt='<div class="quote-box" style="padding:1px;background: none; border: 0;"><cite style="width:100%;margin:0;"><input id="'+open+'" class="spoiler-button" style="width:140px;font-size:10px; margin:0;" type="button" value="'+close+'"></cite><blockquote class="quote-box" style="display:none; width: 80%;border: 1px solid black;margin:0;">'+txt+'</blockquote></div>' return txt; } $(document).ready(function(){ $("div.quote-box > cite > input.spoiler-button").click(function(){ $(this).parents("div.quote-box:first").find("blockquote.quote-box:first").toggle("slow"); var a = $(this).attr('value');$(this).attr('value',$(this).attr('id'));$(this).attr('id',a); }); }); if((document.URL.indexOf("viewtopic.php")!=-1) || (document.URL.indexOf("post.php")!=-1)){ elm=document.getElementById("pun-main").getElementsByTagName("div") for(x in elm) if(elm[x].className=="post-content"){ var post=elm[x] post.innerHTML=addSpoiler(post.innerHTML,0,false) } } if(form=document.getElementById("form-buttons")) form.getElementsByTagName("tr")[0].insertCell(16).innerHTML="<img id=\"button-spoiler\" title=\"Спойлер\" onclick=\"tag_spoiler('[spoiler]','[/spoiler]')\" src=\"/i/blank.gif\" />" </script>
находим строку "max_length=19;" Число 19 меняем на свое - это максимальное количество символов на кнопке, остальное обрежет
Но это не то, что мне нужно, а в 1 скрипте (который мне нужен) нету такой строчки