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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    $('.vse-zaeblo').click(function() {
            $.fancybox($(this));
            return false;
        });

    Получил задачу пофиксить сайт созданный другой компанией, заглянул в код и увидел самую первую функцию

    Xases, 05 Декабря 2014

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

    +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
    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
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    jQuery(document).ready(function(){ 
    jQuery("a.m1_show").click(function(){ 
    jQuery('div#emul_1').addClass('mshow').show();
    jQuery('div#emul_2').addClass('minvis').hide();
    jQuery('div#emul_3').addClass('minvis').hide();
    jQuery('div#emul_4').addClass('minvis').hide();
    jQuery('div#emul_5').addClass('minvis').hide();
    //jQuery('li#emul_6').addClass('minvis').hide();
    });
    });
    
    jQuery(document).ready(function(){ 
    jQuery("a.m2_show").click(function(){ 
    jQuery('div#emul_2').addClass('mshow').show();
    jQuery('div#emul_1').addClass('minvis').hide();
    jQuery('div#emul_3').addClass('minvis').hide();
    jQuery('div#emul_4').addClass('minvis').hide();
    jQuery('div#emul_5').addClass('minvis').hide();
    //jQuery('li#emul_6').addClass('minvis').hide();
    });
    });
    
    
    jQuery(document).ready(function(){ 
    jQuery("a.m3_show").click(function(){ 
    jQuery('div#emul_3').addClass('mshow').show();
    jQuery('div#emul_1').addClass('minvis').hide();
    jQuery('div#emul_2').addClass('minvis').hide();
    jQuery('div#emul_4').addClass('minvis').hide();
    jQuery('div#emul_5').addClass('minvis').hide();
    //jQuery('li#emul_6').addClass('minvis').hide();
    });
    });
    
    jQuery(document).ready(function(){ 
    jQuery("a.m4_show").click(function(){ 
    jQuery('div#emul_4').addClass('mshow').show();
    jQuery('div#emul_1').addClass('minvis').hide();
    jQuery('div#emul_3').addClass('minvis').hide();
    jQuery('div#emul_2').addClass('minvis').hide();
    jQuery('div#emul_5').addClass('minvis').hide();
    //jQuery('li#emul_6').addClass('minvis').hide();
    });
    });
    
    jQuery(document).ready(function(){ 
    jQuery("a.m5_show").click(function(){ 
    jQuery('div#emul_5').addClass('mshow').show();
    jQuery('div#emul_1').addClass('minvis').hide();
    jQuery('div#emul_3').addClass('minvis').hide();
    jQuery('div#emul_2').addClass('minvis').hide();
    jQuery('div#emul_4').addClass('minvis').hide();
    //jQuery('li#emul_6').addClass('minvis').hide();
    });
    });
    
    function but_1 () {
     	jQuery('span#emul_img_1').addClass('img_none').hide();
    	jQuery('span#emul_img_2').addClass('img_inline').show();
    	jQuery('span#emul_img_3').addClass('img_inline').show();
    	jQuery('span#emul_img_4').addClass('img_inline').show();
    	jQuery('span#emul_img_5').addClass('img_inline').show();
    	
    	
    	jQuery('span#emul_img_none_1').addClass('img_inline').show();
    	jQuery('span#emul_img_none_1').addClass('current_tab').show();
    	
    	jQuery('span#emul_img_none_2').addClass('img_none').hide();
    	jQuery('span#emul_img_none_3').addClass('img_none').hide();
    	jQuery('span#emul_img_none_4').addClass('img_none').hide();
    	jQuery('span#emul_img_none_5').addClass('img_none').hide();
    }
    
    function but_2 () {
     	jQuery('span#emul_img_2').addClass('img_none').hide();
    	jQuery('span#emul_img_1').addClass('img_inline').show();
    	jQuery('span#emul_img_3').addClass('img_inline').show();
    	jQuery('span#emul_img_4').addClass('img_inline').show();
    	jQuery('span#emul_img_5').addClass('img_inline').show();
    	
    	jQuery('span#emul_img_none_2').addClass('img_inline').show();
    	jQuery('span#emul_img_none_2').addClass('current_tab').show();
    	
    	jQuery('span#emul_img_none_1').addClass('img_none').hide();
    	jQuery('span#emul_img_none_3').addClass('img_none').hide();
    	jQuery('span#emul_img_none_4').addClass('img_none').hide();
    	jQuery('span#emul_img_none_5').addClass('img_none').hide();
    	
    }
    ...

    На работе сказали поправить табы, зашел увидел это =)
    Вот такая реализация, Там еще html очень "забавный" =)

    JAZzmiX, 05 Декабря 2014

    Комментарии (9)
  3. Java / Говнокод #17260

    +76

    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
    /**
     * all object cocomponents must be not the same objects in dump - to eliminate strange situations:
     * 
     * @param copySet
     */
    private void createAllNewComplexObjects(HashMap copySet) {
    	if (copySet != null) {
    		for (Iterator i = copySet.keySet().iterator(); i.hasNext();) {
    			Object key = i.next();
    			Object o = copySet.get(key);
    			Object newObject = madeNewObect(o);
    			copySet.put(key, newObject);
    		}
    	}
    }
    
    /**
     * create new instance of the object - if it is of known type. Hashes will bethe same
     * 
     * @param oldObject
     * @return
     */
    private Object madeNewObect(Object oldObject) {
    	if (oldObject instanceof String) {
    		return new String((String) oldObject);
    	}
    	if (oldObject instanceof Point) {
    		return new Point((Point) oldObject);
    	}
    	if (oldObject instanceof Vector2D) {
    		return new Vector2D((Vector2D) oldObject);
    	}
    	if (oldObject instanceof RGBA) {
    		RGBA c = (RGBA) oldObject;
    		return new RGBA(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
    	}
    	if (oldObject instanceof Integer) {
    		return new Integer(((Integer) oldObject).intValue());
    	}
    	if (oldObject instanceof Double) {
    		return new Double(((Double) oldObject).doubleValue());
    	}
    	if (oldObject instanceof Boolean) {
    		return new Boolean(((Boolean) oldObject).booleanValue());
    	}
    	if (oldObject instanceof Float) {
    		return new Float(((Float) oldObject).floatValue());
    	}
    
    	if (oldObject instanceof HashMap) {
    		createAllNewComplexObjects((HashMap) oldObject);
    		return oldObject;
    	}
    
    	return oldObject;
    
    }

    В продолжение темы конструктора String(String).

    someone, 05 Декабря 2014

    Комментарии (5)
  4. Java / Говнокод #17259

    +84

    1. 1
    List selection = new ArrayList((s != null) ? s : new ArrayList());

    Больше мусора для бога сборщика мусора!

    someone, 05 Декабря 2014

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

    +86

    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
    const n=10;
    
    type
         xfl = record x: double; fl: longint; end;
      ar_xfl = array[1..2*n] of xfl;
    var
      i: longint;
      x,y,r: double;
      a: ar_xfl;
      f: text;
    
    
    procedure qsort(var a: ar_xfl; lo,hi: longint);
        procedure sort(l,r: longint);
        var
          i,j,k: longint;
          tmp: xfl;
        begin
          i:=l;
          j:=r;
          k:=(l+r) div 2;
          repeat
            while a[i].x<a[k].x do inc(i);
            while a[k].x<a[j].x do dec(j);
            if i<=j then
              begin
                tmp:=a[i];
                a[i]:=a[j];
                a[j]:=tmp;
                inc(i);
                dec(j);
              end;
          until i>j;
          if l<j then sort(l,j);
          if i<r then sort(i,r);
        end;
    begin
    sort(lo,hi);
    end;

    За такие названия переменных надо руки завязывать узлом. Да и помимо этого..

    Cynicrus, 05 Декабря 2014

    Комментарии (21)
  6. C++ / Говнокод #17257

    +53

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    //
    // 'compare_keywords()' - Compare two keywords...
    //
    
    extern "C" {
      int
      compare_keywords(const void *a,
                       const void *b) {
        return (strcmp(*((const char **)a), *((const char **)b)));
      }
    }

    govnokod3r, 04 Декабря 2014

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

    +158

    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
    // Пара функций в глобальном скоупе прям
    
    function imageOn(imageName)
    {
    	if(document.images)
    	{
    		document[imageName].src=eval(imageName+"On.src");
    	}
    }
    
    
    function imageOff(imageName)
    {
    	if(document.images)
    	{
    		document[imageName].src=eval(imageName+"Off.src");
    	}
    }
    
    
    // Затем по такому файлику на каждую страницу
    
    if(document.images)
    {
    	imagePath= contextImages;
    
    	displaySessionInfoOn=new Image();
    	displaySessionInfoOn.src=imagePath+"ShowSessionStatusOn.gif";
    	displaySessionInfoOff=new Image();
    	displaySessionInfoOff.src=imagePath+"ShowSessionStatusOff.gif";
    
    	...
    }
    
    
    // И, наконец, пример использования в HTML:
    
    <a href="DisplaySessionInfo?PropertyId=FILBB" onmouseover="imageOff('displaySessionInfo')" onmouseout="imageOn('displaySessionInfo')">
        <img src="/resources/images/ShowSessionStatusOn.gif" name="displaySessionInfo" alt="ShowSessionStatus" border="3"/>
    </a>

    madhead, 04 Декабря 2014

    Комментарии (0)
  8. C# / Говнокод #17255

    +134

    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
    string pars_param(string data) 
            {
                HtmlAgilityPack.HtmlDocument html = new HtmlAgilityPack.HtmlDocument();
                html.LoadHtml(data);
                HtmlNodeCollection qw = html.DocumentNode.SelectNodes(@"//input[@name=""k""]");
                if (qw != null)
                {
                    foreach (HtmlNode n in qw)
                    {
                        if (n.Attributes["value"] != null)
                        {
                            return n.Attributes["value"].Value;
                        }
                    }
                }
            }

    Error 1 'trcli.Form1.pars_param(string)': not all code paths return a value D:\zMyDoc\igl\Documents\Visual Studio 2013\Projects\trcli\trcli\Form1.cs 651 16 trcli


    не магу разобраться в своем говнокоде, не хочет возвращать n.Attributes["value"].Value

    igl, 04 Декабря 2014

    Комментарии (15)
  9. 1C / Говнокод #17254

    −125

    1. 1
    2. 2
    Движение = Движения.Добавить();
    Движение.СчетДт = ПланыСчетов.Хозрасчетный.НайтиПоКоду(Счет.Код);

    facepeeler, 04 Декабря 2014

    Комментарии (17)
  10. 1C / Говнокод #17253

    −122

    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
    Для Индекс = 1 По 4 Цикл
    
    	Если Индекс = 1 Тогда
    		<Действие1...>;
    	ИначеЕсли Индекс = 2 Тогда
    		<Действие2...>;
    	ИначеЕсли Индекс = 3 Тогда
    		<Действие3...>;
    	ИначеЕсли Индекс = 4 Тогда
    		<Действие4...>;
    	КонецЦикла;	
    
    КонецЦикла

    facepeeler, 04 Декабря 2014

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