1. JavaScript / Говнокод #2702

    +151.2

    1. 1
    <body onload="blinkAfterSearch();setTimeout('loadDummyImg()', 590000);var ex; try { startUpTasks(); } catch(ex) {}" />

    Недавно отрыл в недрах нашего проекта! Try catch в onload!! :D

    jericho, 02 Марта 2010

    Комментарии (16)
  2. JavaScript / Говнокод #2701

    +150.7

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    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;
    		};

    Areks, 01 Марта 2010

    Комментарии (4)
  3. JavaScript / Говнокод #2695

    +152.5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function setTabs() {
           for(var i = 0; i < tabsNum; i++) {
               if(i === currentTab) {
                   $("#tabCont" + i).css("display","block");
               } else {
                   $("#tabCont" + i).css("display","none");
               };
           };
       };

    Нашел отличную функцию для скрытия/открытия табов

    Rpsl, 01 Марта 2010

    Комментарии (32)
  4. JavaScript / Говнокод #2693

    +166.2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    <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-формы.

    wwwguru, 01 Марта 2010

    Комментарии (6)
  5. JavaScript / Говнокод #2686

    +161.7

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    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

    Infamous, 27 Февраля 2010

    Комментарии (1)
  6. JavaScript / Говнокод #2667

    +163.2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    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

    turdman, 25 Февраля 2010

    Комментарии (7)
  7. JavaScript / Говнокод #2653

    +173.5

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    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;
    }

    fuckyounoob, 23 Февраля 2010

    Комментарии (3)
  8. JavaScript / Говнокод #2648

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    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());

    Банально, но все равно приятно :)

    wvxvw, 21 Февраля 2010

    Комментарии (12)
  9. JavaScript / Говнокод #2644

    +194.6

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    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);
    }

    Возведение числа в степень

    fuckyounoob, 20 Февраля 2010

    Комментарии (65)
  10. JavaScript / Говнокод #2635

    +159.3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    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>&nbsp;';
       // 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>&nbsp;';
       // 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>&nbsp;</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";*/
    }

    Яваскрипт от местного умельца:)

    HollyGeek, 18 Февраля 2010

    Комментарии (5)