- 1
<body onload="blinkAfterSearch();setTimeout('loadDummyImg()', 590000);var ex; try { startUpTasks(); } catch(ex) {}" />
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+151.2
<body onload="blinkAfterSearch();setTimeout('loadDummyImg()', 590000);var ex; try { startUpTasks(); } catch(ex) {}" />
Недавно отрыл в недрах нашего проекта! Try catch в onload!! :D
+150.7
var Scroller = function (scroll_left,scroll_right,visible_part,scroll_part) {
this.scroll_right = jQuery(scroll_left); //scroll to left
this.scroll_left = jQuery(scroll_right); //scroll to right
this.slider = jQuery(scroll_part); //scroll element
this.visible_part = jQuery(visible_part);
this.width_slider_elements = this.slider.width();
this.width_slider_element = this.slider.find('li:eq(0)').width();
this.width_visible_part = this.visible_part.width();
this.temp_process = true;
if(this.width_slider_elements < this.width_visible_part) {temp_process = false;}
var self = this;
this.scroll_left.click(function()
{
if (self.temp_process) {
self.temp_process = false;
self.slide(true);
}
return false;
});
this.scroll_right.click(function()
{
if (self.temp_process) {
self.temp_process = false;
self.slide(false);
}
return false;
});
return this;
};
Scroller.prototype.slide = function (side) {
var self = this;
var shift = (self.width_visible_part - self.width_slider_element)/2;
var current_shift = Math.abs(self.slider.css('left').replace('px',''));
if (side) { //left
shift = (current_shift+shift+self.width_visible_part) > self.width_slider_elements ? self.width_slider_elements - current_shift - self.width_visible_part : shift;
self.slider.animate({left: '-='+shift+'px'}, 1000, function(){ self.temp_process = true;});
} else { //right
shift = shift > current_shift ? current_shift : shift;
self.slider.animate({left: '+='+shift+'px'}, 1000, function(){ self.temp_process = true;});
}
return shift;
};
+152.5
function setTabs() {
for(var i = 0; i < tabsNum; i++) {
if(i === currentTab) {
$("#tabCont" + i).css("display","block");
} else {
$("#tabCont" + i).css("display","none");
};
};
};
Нашел отличную функцию для скрытия/открытия табов
+166.2
<form name='change_form'
enctype='multipart/form-data'
method='post'
onSubmit='if (!checkfilled(document.change_form,"name")) return false;
if (!checkfilled(document.change_form,"email")) return false;
if (!checkfilled(document.change_form,"text")) return false;
if (!checkfilled(document.change_form,"company")) return false;
if (!checkfilled(document.change_form,"phone")) return false;
if (!checkint(document.change_form,"city_code", -2147483648, 2147483648)) return false;
'
action='/request/?do=add'>
Гениальное решение для проверки html-формы.
+161.7
function payForFiles(){
var hid,tak,elems,num,pat,j,i;
hid = document.getElementById("hidden");
tak = new Array();
elems = document.getElementsByTagName('A');
num = elems.length;
pat = new RegExp("(^|\\b)(takru)(\\b|$)");
j = 0;
for (i=0;i<num;i++){
if(pat.test(elems[i].className)){
elems[i].setAttribute('target','_blank');
if (elems[i].addEventListener)
elems[i].addEventListener("click", function(){hid.style.display = ""}, false);
else if (elems[i].attachEvent)
elems[i].attachEvent("onclick", function(){hid.style.display = ""});
else elems[i].onclick = function(){hid.style.display = ""};
j++;}
}
};
Типа "скачивание после клика на рекламу". Было найдено здесь — http://troiua-alfa.3dn.ru/publ/ucoz_skript_skachivanie_posle_nazhatija_ na_reklamu/27-1-0-99
+163.2
var idTa; //id of the textarea (param to makeWhizzyWig)
//OTHER GLOBALS
var oW, sel, rng, papa, trail, ppw, wn=window; //Whizzy contentWindow, current sel, range, parent, DOM path, popwindow;
var sels='';
var buts='';
var vals=new Array();
var opts=new Array();
var dobut=new Array();
//...
w('<div style="width:'+taWidth+'" onmouseover="c(\''+idTa+'\')"><div id="CONTROLS'+idTa+'" class="wzCtrl" unselectable="on">');
//...
function c(id) {//set current whizzy
if (id=="" || whizzies.join().indexOf(id)=='-1') return;
if (id!=idTa){
idTa=id;
try {oW=o("whizzy"+id).contentWindow;} catch(e){alert('set current: '+id);}
if (oW) {if(oW.focus)oW.focus();wn.status=oW.document.body.id; }
}
}
//...
Хтоническое порождение сумрачного гения
Все параметры редакторы лежат в global'ах. Но что делать если редакторов на странице несколько?
Правильно: mouse over!
http://www.unverse.net/wysiwyg.html
+173.5
toSmallFont = function ( e )
{
c = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]; n = c.length;
r = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
while (n--) e = e.replace(c[n], r[n]);
return e;
}
toBigFont = function ( i )
{
c = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]; n = c.length;
r = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
while (n--) i = i.replace(c[n], r[n]);
return i;
}
+160
var today = new Date();
var d_names = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var d_postfix = new Array("never_used","st", "nd", "rd", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th", "th", "th");
document.write(d_names[today.getDay()]+", "+m_names[today.getMonth()]+" "+today.getDate()+d_postfix[today.getDate()]+", "+today.getFullYear());
Банально, но все равно приятно :)
+194.6
inExp = function (dig, exp) {
if (exp == 1) return alert(dig);
if (exp == 2) return alert(dig*dig);
if (exp == 3) return alert(dig*dig*dig);
if (exp == 4) return alert(dig*dig*dig*dig);
if (exp == 5) return alert(dig*dig*dig*dig*dig);
if (exp == 6) return alert(dig*dig*dig*dig*dig*dig);
if (exp == 7) return alert(dig*dig*dig*dig*dig*dig*dig);
if (exp == 8) return alert(dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 9) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 10) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 11) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 12) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 13) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 14) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 15) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 16) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 17) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 18) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 19) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 20) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 21) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 22) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 23) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 24) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 25) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 26) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 27) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 28) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 29) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
if (exp == 30) return alert(dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig*dig);
}
Возведение числа в степень
+159.3
var res_html = "";
for (var i = 0; i < title_section.length; i++)
{
if (title_section[i].id == sel) {
res_html += '<div class="'+prefix+'section_title" onmouseover="section_sel(this,\''+ prefix +'\')" onmouseout="section_unsel(this,\''+ prefix +'\')"' +
'onclick="section_choise(this,'+'\''+url+'\'' + ')"' +
'id='+'"'+title_section[i].id+'" '
+'style='+'"font-weight: bold"'+'>'+
'<span class="'+ prefix +'dashed_anchor">' + title_section[i].name + '</span> ';
// res_html += '(' + number_section[i] + ')';
res_html += '</div>';
}
else{
res_html += '<div class="'+prefix+'section_title" onmouseover="section_sel(this,\''+ prefix +'\')" onmouseout="section_unsel(this,\''+ prefix +'\')"' +
'onclick="section_choise(this,'+'\''+url+'\'' + ')"' +
'id='+'"'+title_section[i].id+'" '
+'>'+
'<span class="'+ prefix +'dashed_anchor">' + title_section[i].name + '</span> ';
// res_html += '(' + number_section[i] + ')';
res_html += '</div>';
}
}
document.getElementById(prefix + "sections").innerHTML += res_html;
document.getElementById(prefix + "sections").innerHTML += '<a href='+'"?id=all"'+'><div class="'+prefix+'all_sections"><img src="media/img/01/arrow.jpg" alt=""/>' +
'<span style="color:black">Все разделы</span> </div></a>';
document.getElementById(prefix + "column_sections").style.width = (max_length + 7) + "ex";
/* document.getElementById(prefix + "green_sector").style.height = (document.getElementById(prefix + "column_other").offsetHeight - 14) + "px";*/
}
Яваскрипт от местного умельца:)