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

    −3.2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    var obj=document.all.cont_small;
    obj.focus();
        if      (window.getSelection)   selected = window.getSelection().toString();      
        else if (document.getSelection) selected = document.getSelection();                
        else if (document.selection)   selected = document.selection.createRange();  
        selected.value = "[img]"+SmileId+"[/img]";

    Запостил: Santrex, 08 Марта 2010

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

    +10.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
    Element = function (AttributeName, AttributeValue) {
    	arr = [];
    	if (document.getElementsByTagName("*")[0] && document.getElementsByTagName("*")[0].getAttribute(AttributeName) == AttributeValue) arr.push(document.getElementsByTagName("*")[0]);
    	if (document.getElementsByTagName("*")[1] && document.getElementsByTagName("*")[1].getAttribute(AttributeName) == AttributeValue) arr.push(document.getElementsByTagName("*")[1]);
    	if (document.getElementsByTagName("*")[2] && document.getElementsByTagName("*")[2].getAttribute(AttributeName) == AttributeValue) arr.push(document.getElementsByTagName("*")[2]);
    	if (document.getElementsByTagName("*")[3] && document.getElementsByTagName("*")[3].getAttribute(AttributeName) == AttributeValue) arr.push(document.getElementsByTagName("*")[3]);
    
    ...
    
    if (document.getElementsByTagName("*")[997] && document.getElementsByTagName("*")[997].getAttribute(AttributeName) == AttributeValue) arr.push(document.getElementsByTagName("*")[997]);
    	if (document.getElementsByTagName("*")[998] && document.getElementsByTagName("*")[998].getAttribute(AttributeName) == AttributeValue) arr.push(document.getElementsByTagName("*")[998]);
    	if (document.getElementsByTagName("*")[999] && document.getElementsByTagName("*")[999].getAttribute(AttributeName) == AttributeValue) arr.push(document.getElementsByTagName("*")[999]);
    	return arr
    }

    Запостил: eval, 08 Марта 2010

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

    +12.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
    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
    function is_ie8(){
    var ua = navigator.userAgent.toLowerCase();
    var is_opera = ua.indexOf("opera") != -1;
    var is_opera5 = ua.indexOf("opera/5") != -1 || ua.indexOf("opera 5") != -1;
    var is_opera6 = ua.indexOf("opera/6") != -1 || ua.indexOf("opera 6") != -1;
    var is_opera7 = ua.indexOf("opera/7") != -1 || ua.indexOf("opera 7") != -1;
    var is_opera8 = ua.indexOf("opera/8") != -1 || ua.indexOf("opera 8") != -1;
    var is_opera9 = ua.indexOf("opera/9") != -1 || ua.indexOf("opera 9") != -1;
    var is_opera95 = ua.indexOf("opera/9.5") != -1 || ua.indexOf("opera 9.5") != -1;
    var is_opera96 = ua.indexOf("opera/9.6") != -1 || ua.indexOf("opera 9.6") != -1;
    var is_opera95up = is_opera95 || is_opera96;
    
    var is_ff = ua.indexOf("firefox") != -1 && !is_opera;
    var is_gecko = ua.indexOf('gecko') != -1 && !is_opera;
    
    var is_chrome = ua.indexOf('chrome') != -1;
    var is_safari = ua.indexOf('applewebkit') != -1 && !is_chrome;
    
        var is_ie = ua.indexOf("msie") != -1  && !is_opera;
        var is_ie4 = is_ie && ua.indexOf("msie 4") != -1;
        var is_ie5 = is_ie && ua.indexOf("msie 5") != -1;
        var is_ie50 = is_ie && ua.indexOf("msie 5.0") != -1;
        var is_ie55 = is_ie && ua.indexOf("msie 5.5") != -1;
        var is_ie5up = is_ie && !is_ie4;
        var is_ie6 = is_ie && ua.indexOf("msie 6") != -1;
        var is_ie6up = is_ie5up && !is_ie55 && !is_ie5;
        var is_ie7 = is_ie && ua.indexOf("msie 7") != -1;
        var is_ie7up = is_ie6up && !is_ie6;
        var is_ie7down = is_ie7 || is_ie6 || is_ie5 || is_ie4;
    
        var is_ie8 = is_ie && ua.indexOf("msie 8") != -1;
        var is_ie8up = is_ie8 && !is_ie7down;
        if (is_ie && !is_ie8up && !is_ie8) {
            return true;
        }else return false;
    }

    Детектим IE8

    Запостил: deraider, 06 Марта 2010

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

    +6.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
    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

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

    +9

    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

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

    +2.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
    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

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

    +10.1

    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)
  8. JavaScript / Говнокод #2704

    +9.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
    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

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

    −1.8

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

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

    Запостил: jericho, 02 Марта 2010

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

    −2.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
    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

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