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

    +165

    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
    function ShowButton(name, link, target,img,id,style){
    	         {/<TD align = "right" width=1>/}
    				{/<SPAN id=" %id " title=" %name " style=" %style ">/}
    				{/<TABLE style="CURSOR: pointer" height=16 cellSpacing=0 cellPadding=0 border=0>/}
    				{/<TBODY>/}
    				{/<TR height=3>/}
    					{/<TD vAlign=top width=7><IMG height=3 src=" %pPath() left_top_button" width=7 border=0></TD>/}
    					{/<TD class=spacer vAlign=top background= %pPath() bg_top_button>&nbsp;</TD>/}
    					{/<TD vAlign=top width=7><IMG height=3 src=" %pPath() right_top_button" width=7 border=0></TD></TR>/}
    				{/<TR style="CURSOR: pointer">/}
    					{/<TD class=spacer vAlign=top width=7 background= %pPath() left_button>&nbsp;</TD>/}
    					{/<TD onClick = " %link " class=buttonLink vAlign=center noWrap align=middle background= %pPath() bg_button>/}
    					if(img!=null){
    						Image(img, null, null, null, name); 
    					}else{
    						{/<a href=#> %name </a>/}	
    					}
    					{/</TD>/}
    					{/<TD class=spacer vAlign=top width=7 background= %pPath() right_button>&nbsp;</TD></TR>/}
    				{/<TR style="CURSOR: pointer" height=3>/}
    					{/<TD class=spacer vAlign=top width=7><IMG src=" %pPath() left_bot_button" border=0></TD>/}
    					{/<TD class=spacer background= %pPath() bg_bot_button height=3>&nbsp;</TD>/}
    					{/<TD class=spacer vAlign=top width=7><IMG src=" %pPath() right_bot_button" border=0></TD></TR>/}
    					{/</TBODY>/}
    				{/</TABLE>/}
                  {/</SPAN>/}
                {/</TD>/}
    }

    Из одной говносистемы документооборота:

    вот из этого километра говноразметки - получается обычная кнопочка, почти ничем не отличающаяся от input type="button"

    GeX, 04 Марта 2010

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

    +166.3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function smla(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':)';}
    function smls(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='>( ';}
    function smld(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':D';}
    function smlf(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='B)';}
    function smlg(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='%)';}
    function smlh(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':(';}
    function smlj(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':o';}
    function smlw(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='^_^';}
    function smlk(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='<_<';}
    function smll(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=';)';}
    function smlq(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':p';}

    Ещё один китаец. Вставляет смайлы в текстовое поле вот таким вот кодом. Источник — http://mirtorrent.ru/css/pppm.js

    Infamous, 03 Марта 2010

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

    +159.8

    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
    function check_date() {
    	var	message = "Дата невалидна.";
    		days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    
    	var str = $('#registration-form [name="birthday"]').val();
    
    	var m = str.match(/(\d*)\.(\d*)\.(\d*)(.*)/);
    
    	if (!m ||
    		!m[1] ||
    		!m[2] ||
    		!m[3] ||
    		m[4] ||
    		parseInt(m[2], 10) < 1 ||
    		parseInt(m[2], 10) > 12 ||
    		parseInt(m[1], 10) < 1 ||
    		parseInt(m[1], 10) > days[parseInt(m[2], 10)-1] ||
    		parseInt(m[3], 10) < 1920 ||
    		parseInt(m[3], 10) > 2000 ) {
    		tooltip($('#registration-form [name="birthday"]').get(0), message);
    	} else {
    		removett($('#registration-form [name="birthday"]').get(0));
    	}
    }

    Не очень говно, но вполне себе код.

    ixth, 03 Марта 2010

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

    +167.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
    function BOOK_list() {
     document.getElementById('rbLoadedId_list').style.display='block';
     document.getElementById('rbLoadedId_blogs').style.display='none';
     document.getElementById('rbLoadedId_free').style.display='none';
     document.getElementById('rbLoadedId_add').style.display='none';
     document.getElementById('rbLoadedId_friend').style.display='none';
     document.getElementById('rbLoadedId_award').style.display='none';
    
     document.getElementById('0rbLoadedId_list').className='act';
     document.getElementById('0rbLoadedId_blogs').className='book';
     document.getElementById('0rbLoadedId_free').className='book';
     document.getElementById('0rbLoadedId_add').className='book';
     document.getElementById('0rbLoadedId_friend').className='book';
     document.getElementById('0rbLoadedId_award').className='book';
        }
    
      function BOOK_blogs() {
     document.getElementById('rbLoadedId_list').style.display='none';
     document.getElementById('rbLoadedId_blogs').style.display='block';
     document.getElementById('rbLoadedId_free').style.display='none';
     document.getElementById('rbLoadedId_add').style.display='none';
     document.getElementById('rbLoadedId_friend').style.display='none';
     document.getElementById('rbLoadedId_award').style.display='none';
    
     document.getElementById('0rbLoadedId_list').className='book';
     document.getElementById('0rbLoadedId_blogs').className='act';
     document.getElementById('0rbLoadedId_free').className='book';
     document.getElementById('0rbLoadedId_add').className='book';
     document.getElementById('0rbLoadedId_friend').className='book';
     document.getElementById('0rbLoadedId_award').className='book';
        }

    JS-табы по-китайски. Взято отсюда — http://vkurse.net.ru/js/info.js
    Это только первые 2 функции, в источнике ещё больше

    Infamous, 03 Марта 2010

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

    +166.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function  trim(text) {
      if (text.length == 0) {
        return text;
      }
      if (text.charAt(0) == ' ') {
        return '';
      }
      if (text.charAt(text.length-1) == ' ') {
        text = text.substring(0, text.length-1);
      }
      return text;
    }

    суровый китайский trim...

    ClintEastwood, 02 Марта 2010

    Комментарии (17)
  6. 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)
  7. 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)
  8. 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)
  9. 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)
  10. 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)