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

    +162

    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
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    var BrowserDetect={
    init: function () {
    this.browser=this.searchString(this.dataBrowser) || "An unknown browser";
    this.version=this.searchVersion(navigator.userAgent)
    || this.searchVersion(navigator.appVersion)
    || "an unknown version";
    this.OS=this.searchString(this.dataOS) || "an unknown OS";
    },
    searchString: function (data) {
    for (var i=0;i<data.length;i++) {
    var dataString=data[i].string;
    var dataProp=data[i].prop;
    this.versionSearchString=data[i].versionSearch || data[i].identity;
    if (dataString) {
    if (dataString.indexOf(data[i].subString) !=-1)
    return data[i].identity;
    }
    else if (dataProp)
    return data[i].identity;
    }},
    searchVersion: function (dataString) {
    var index=dataString.indexOf(this.versionSearchString);
    if (index==-1) return;
    return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
    },
    dataBrowser: [
    {
    string: navigator.userAgent,
    subString: "Chrome",
    identity: "Chrome"
    },
    {  string: navigator.userAgent,
    subString: "OmniWeb",
    versionSearch: "OmniWeb/",
    identity: "OmniWeb"
    },
    
    },
       ...... // сокращу 
    {
    string: navigator.userAgent,
    subString: "MSIE",
    identity: "Explorer",
    versionSearch: "MSIE"
    },
    {
    string: navigator.userAgent,
    subString: "Gecko",
    identity: "Mozilla",
    versionSearch: "rv"
    },
    {
    string: navigator.userAgent,
    subString: "Mozilla",
    identity: "Netscape",
    versionSearch: "Mozilla"
    }
    ],
    dataOS : [
    {
    string: navigator.platform,
    subString: "Win",
    identity: "Windows"
    },
    {
    string: navigator.platform,
    subString: "Mac",
    identity: "Mac"
    },
    {
    string: navigator.userAgent,
    subString: "iPhone",
    identity: "iPhone/iPod"
    },
    {
    string: navigator.platform,
    subString: "Linux",
    identity: "Linux"
    }
    ]
    };
    BrowserDetect.init();

    Самое интересное, что после сего мудозвонства в коде идет : google.load("jquery", "1"); ради одной карусельки.

    http://sng.garena.com/ - вот здесь этот стыд, и много-много чего еще интересного.

    jQuery, 09 Октября 2011

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

    +148

    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
    if(!count)
    		count=0;
    		
    	switch(type){
    		case 'writing':
    			count++;
    			break;
    		case 'stopWriting':
    			count--;
    			break;
    		default:
    			return;
    	}
    	
    	//Shit happens.
    	if(count<0)
    		count=0;

    хуита, 09 Октября 2011

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function checksubmit(obj){ 
    ds = obj.message.value; 
    while (ds.indexOf("[Результат выстрела.]") > -1) { 
    variant=7; 
    priz=Math.round(Math.random() * variant); 
       ds = ds.replace('[Результат выстрела.]',' [img]http://mystalker.at.ua/cub/cub'+priz+'.gif[/img] '); 
    } obj.message.value = ds; }

    Тут больше доставляет описание чем код )))
    Особенно "давно покрылся славой" и "Учесть,что скрипту более 4-х лет и он заслуживает уважения".
    http://u.to/a6k6AQ

    OJA, 08 Октября 2011

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

    +160

    1. 1
    2. 2
    3. 3
    dockedItems.splice(0, 0, {
    	xtype: 'mainmenubar'
    });

    Счас у себя увидел

    bildja, 06 Октября 2011

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

    +145

    1. 1
    alert("0"==0);

    Просто замечательный язык. Как строка может равняться нулю? Кому в голову могла прийти настолько плохая идея?
    Зачем программисту помнить, что есть ==, а есть ===? Почему не сделать ==2 и ==3.
    Почему так тупо?

    alexoy, 02 Октября 2011

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

    +169

    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 echeck(str) {
      var at="@"
      var dot="."
      var lat=str.indexOf(at)
      var lstr=str.length
      //  var ldot=str.indexOf(dot)
      if (str.indexOf(at)==-1){
        alert("Invalid E-mail ID");
        return false;
      }
      if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
        alert("Invalid E-mail ID");
        return false;
      }
      if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
        alert("Invalid E-mail ID");
        return false;
      }
      if (str.indexOf(at,(lat+1))!=-1){
        alert("Invalid E-mail ID");
        return false;
      }
      if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
        alert("Invalid E-mail ID");
        return false;
      }
      if (str.indexOf(dot,(lat+2))==-1){
        alert("Invalid E-mail ID");
        return false;
      }
      if (str.indexOf(" ")!=-1){
        alert("Invalid E-mail ID");
        return false;
      }
      return true;
    }

    если честно, дочитал где-то только до 15 строки

    marg, 30 Сентября 2011

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

    +159

    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
    48. 48
    var resizeTimer,calWidth,$BlockPath,widthLeftPart,widthRightPart,count;
    var $headBlock = $('div.hdr');
    var $rightBlock = $('li.userFullName');
    var $leftBlock = $('li.subMenu-title');
    
    $(document).ready(resizeLabels);
    $(window).resize(resizeLabels);
    
    function doResizeLabels($typeBlock) {
            count = 2;
            resultWidth = 0;
            if ($typeBlock==$leftBlock) {
                    $BlockPath=$('ul.subMenu li:not(.subMenu-title)');
            } else {
                    $BlockPath=$('ul.usersLink li:not(.userFullName)');
            };    
            $BlockPath.each(function() {
            eachPosition = $(this).position(); 
            eachWidth = $(this).width();  
            eachOuterWidth = $(this).outerWidth();
            count++;
            if ($typeBlock==$leftBlock) {
                    widthLeftPart = eachPosition.left + eachWidth;
                    widthPadding = eachOuterWidth - eachWidth;
            } else {
                    if (count==3) widthPadding = eachPosition.left;
                    widthRightPart = widthRightPart + eachOuterWidth;
            };              
            });    
            if ($typeBlock==$leftBlock) {
                    widthLeftPart = widthLeftPart + ((widthPadding / 2) * count);
                    resultWidth = headWidth/2 - widthLeftPart;
            } else {
                    rightWidth = headWidth/2 - widthRightPart;
                    resultWidth = rightWidth-(headWidth/2-widthPadding/2)/2;
            };        
            $typeBlock.width(resultWidth);
    }
    function resizeLabels() {
            $leftBlock.width(0);
            $rightBlock.width(0);
            headWidth = $headBlock.width();
            widthLeftPart = widthRightPart = 0;        
            headWidth = $headBlock.width();
            
            doResizeLabels($leftBlock);
            doResizeLabels($rightBlock);				
    };

    Serious_Andy, 30 Сентября 2011

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

    +172

    1. 1
    var id = document.getElementsById('color').id;

    омг

    jQuery, 29 Сентября 2011

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

    +157

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function fakePassword() {
    	$(":input:password").each(
    		function(i) {
    			$("#" + this.id + "-hidden-password").attr("name", this.name);
    			$("#" + this.id + "-hidden-password").attr("value", this.value);
    			$(this).removeAttr("value");
    			$(this).removeAttr("name");
    		}
    	);
        return true;
    }

    Connor, 28 Сентября 2011

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

    +160

    1. 1
    2. 2
    3. 3
    var messageDiv = document.getElementById("information-dialog");
    $(messageDiv).html(html);
    messageDiv.style.display = "block";

    Connor, 28 Сентября 2011

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