скрипты:
скрипты
Сообщений 1 страница 4 из 4
Поделиться22010-03-23 15:01:32
цветовыделение:
<script type="text/javascript">
inColor("red", new Array("Duka", "Admin"))
inColor("blue", new Array("AmiRa", "Impuls 101"))
inColor("green", new Array("likka"))
inColor("gray", new Array("rps"))
inColor("yellow", new Array("Шмель", "Изя", "DART"))
function inColor(color, myarray){
var a=document.links
for(i=0;i<a.length;i++){
for(q=0;q<myarray.length;q++){
if(a[i].innerHTML==myarray[q]){
a[i].innerHTML="<span style=\"color: "+color+";\">"+myarray[q]+"</span>"
}}}}
</script>
Копируем то, что выделено курсивом столько, сколько нужно
Ставить в HTMLниз
Cкрипт универсального цветовыделения на 6 групп
Вставляем в ХТМЛ-низ
Через запятую, в кавычках, пишем имена, а то, что выделено меняем на свои цвета.
<script type="text/javascript">
var arr=document.links
var arr1=new Array ("", "")
var arr2=new Array ("", "", "", "")
var arr3=new Array ("", "", "", "")
var arr4=new Array ("", "", "", "", "")
var arr5=new Array ("", "", "", "", "")
var arr6=new Array ("", "", "", "", "")
for (x in arr)
{for (y in arr1)
{if (arr[x].innerHTML==arr1[y])
{
arr[x].innerHTML="<font color='red'>"+arr[x].innerHTML+"</font>"}
}}
for (x in arr)
{for (j in arr2)
{if (arr[x].innerHTML==arr2[j])
{
arr[x].innerHTML="<font color='blue'>"+arr[x].innerHTML+"</font>"}}}
for (x in arr)
{for (l in arr3)
{if (arr[x].innerHTML==arr3[l])
{
arr[x].innerHTML="<font color='orange'>"+arr[x].innerHTML+"</font>"}}}
for (x in arr)
{for (j in arr4)
{if (arr[x].innerHTML==arr4[j])
{
arr[x].innerHTML="<font color='green'>"+arr[x].innerHTML+"</font>"}}}
for (x in arr)
{for (p in arr5)
{if (arr[x].innerHTML==arr5[p])
{
arr[x].innerHTML="<font color='yellow'>"+arr[x].innerHTML+"</font>"}}}
for (x in arr)
{for (s in arr6)
{if (arr[x].innerHTML==arr6[s])
{
arr[x].innerHTML="<font color='pink'>"+arr[x].innerHTML+"</font>"}}}
</script>
1) Красный
2) Синий
3) Оранжевый
4) Зеленый
5) Желтый
6) Розовый
Поделиться32010-03-23 15:12:07
Скрытие тем от гостей.
Ставить в Объявление.
<script>
if (GroupID == 3 && (document.URL.indexOf("viewtopic.php")!=-1)){
alert ('Администратор запретил Вам просматривать темы');
history.go(-1);
}
</script>
Если вы хотите скрыть какую то определённую тему то в скрипт надо прописать так.
<script>
if (GroupID == 3 && (document.URL.indexOf("viewtopic.php?id=4")!=-1)){
alert ('Администратор запретил Вам просматривать темы');
history.go(-1);
}
</script>
Выделенную часть берём из адреса темы в адресной строке.
Поделиться42010-03-23 15:16:07
Спойлер, переделанный под новую форму ответа Карпова.
Форма ответа была изменена,поэтому многие старые скрипты в ней не работают.
Но благодаря Duka теперь есть рабочие версии этих скриптов.
Выделить код
<!--Спойлер-->
<style type="text/css">
#button-spoiler {background-image:url('https://upforme.ru/uploads/0000/12/13/488-1.gif'); background-repeat: no-repeat; margin-left: 13рх}
</style>
<script>
function addSpoiler(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;
str=str.substring(0,pos)+makeSpoiler(str.substring(pos+9,pos2))+str.substring(pos2+10,str.length)
if( str.indexOf("[spoiler]")!=-1 && internal==false) str=addSpoiler(str,0,false)
return str}
function makeSpoiler(txt){
txt="<div class=quote-box style='padding:1px'><cite style='width:100%'>Спойлер <input style='width:60px;margin-left:70%;font-size:10px;' type='button' value='Показать' onclick='hideSpoiler(this)'></cite><blockquote style='display:none'>"+txt+"</blockquote></div>"
return txt}
function hideSpoiler(sp){
spoiler=sp.parentNode.parentNode.getElementsByTagName("blockquote")[0]
if(spoiler.style.display=='none'){
spoiler.style.display='inline'
sp.value='Скрыть'}
else{
spoiler.style.display='none'
sp.value='Показать'}}
if(document.URL.indexOf("viewtopic.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(19).innerHTML="<img id=\"button-spoiler\" title=\"Спойлер\" onclick=\"bbcode('[spoiler]','[/spoiler]')\" src=\"/i/blank.gif\" />"
</script>Ставить в HTML низ или форму ответа
Спойлер с отображением в предварительном просмотре сообщения.
Выделить код
<style type="text/css">
#button-spoiler {background-image:url('https://upforme.ru/uploads/0000/12/13/488-1.gif'); padding:0; line-height:0; background-position:center; background-repeat:no-repeat}
</style>
<script>
function addSpoiler(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;
str=str.substring(0,pos)+makeSpoiler(str.substring(pos+9,pos2))+str.substring(pos2+10,str.length)
if( str.indexOf("[spoiler]")!=-1 && internal==false) str=addSpoiler(str,0,false)
return str}
function makeSpoiler(txt){
txt="<div class=quote-box style='padding:1px'><cite style='width:100%'>Спойлер <input style='width:60px;margin-left:70%;font-size:10px;' type='button' value='Показать' onclick='hideSpoiler(this)'></cite><blockquote style='display:none'>"+txt+"</blockquote></div>"
return txt}
function hideSpoiler(sp){
spoiler=sp.parentNode.parentNode.getElementsByTagName("blockquote")[0]
if(spoiler.style.display=='none'){
spoiler.style.display='inline'
sp.value='Скрыть'}
else{
spoiler.style.display='none'
sp.value='Показать'}}
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(19).innerHTML="<img id=\"button-spoiler\" title=\"Спойлер\" onclick=\"bbcode('[spoiler]','[/spoiler]')\" src=\"/i/blank.gif\" />"
</script>
Переделанный мною скрипт спойлера, чуть более компактный
Выделить код
<script type="text/javascript">
function addSpoiler()
{
var elm = document.getElementById("pun-main").getElementsByTagName("div");
for (x in elm)
if (elm[x].className == "post-content")
elm[x].innerHTML = elm[x].innerHTML.replace(/\[spoiler\]/g, "<div class='quote-box'><cite onclick='hideSpoiler(this)' style='cursor:pointer;cursor:hand;'><b><u>» Нажмите, для отображения текста «</u></b></cite><blockquote style='display:none'>").replace(/\[\/spoiler\]/g, "</blockquote></div>");
if(form = document.getElementById("form-buttons"))
form.getElementsByTagName("tr")[0].insertCell(14).innerHTML = "<img style='width:37px;height:21px;' onclick=\"bbcode('[spoiler]', '[/spoiler]')\" src='https://upforme.ru/uploads/0003/41/8c/1728-1.gif' alt='Спойлер' />";
}
function hideSpoiler(sp)
{
if (spoiler = sp.parentNode.getElementsByTagName("blockquote")[0])
{
if (spoiler.style.display == "none") spoiler.style.display = "inline";
else spoiler.style.display = "none";
}
}
addSpoiler();
</script>
Обновленный спойлер
(с)mkusher
В HTML верх
<script type="text/javascript" src="http://help4us.ru/include/js/jquery.js"></script>
Возможно этот скрипт у вас уже стоит, если вы к примеру делали выплывающее меню от rps
В HTML низ или форма ответа
Выделить код
<style>
#button-spoiler {background-image:url('https://upforme.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='';
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 = 'Скрыть спойлер';
}
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>
Обновлённый спойлер с возможностью задать текст на кнопке.
В HTML верх
<script type="text/javascript" src="http://help4us.ru/include/js/jquery.js"></script>
В HTML низ или форма ответа
Выделить код
<!--Скрипт спойлера-->
<style>
#button-spoiler {background-image:url('https://upforme.ru/uploads/000a/45/08/94-4.png'); 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='';
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 = 'Закрыть';
}
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:180px;font-size:11px; margin:0;" type="button" value="'+close+'"></cite><blockquote class="quote-box" style="display:none; width: 90%;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>