1. Список говнокодов пользователя unicorn

    Всего: 7

  2. JavaScript / Говнокод #25702

    +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
    var XMLHttpRequest = function(XHR, type, listener) {
    	return function() {
    		var xhr = new XHR;
    		xhr.addEventListener(type, listener);
    		return xhr;
    	};
    }(XMLHttpRequest, 'loadend', function(e) {
    	if (this.status == 0) {
    		console.log(e.type, 'network error');
    	} else {
    		console.log(e.type, this.status);
    	}
    });
    
    // js-library code...

    unicorn, 06 Июля 2019

    Комментарии (3)
  3. Куча / Говнокод #25640

    −1

    1. 1
    2. 2
    3. 3
    http://korzinka.byethost9.com/?i=1
    
    Какой багор))) Качает всю базу и картинки... сайт весит более 350 МБ и ещё качает...

    unicorn, 25 Мая 2019

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

    +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
    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
    /* ... */
      if  (kindmusic64[7].checked == true)
      {
        var number = Math.floor(Math.random() * 41);
        switch(number)
        {
          case 0: redradio[0].checked = true; greenradio[0].checked = true; blueradio[1].checked = true;  break;
          case 1: redradio[0].checked = true; greenradio[1].checked = true; blueradio[0].checked = true;  break;
          case 2: redradio[0].checked = true; greenradio[1].checked = true; blueradio[1].checked = true;  break;
          case 3: redradio[1].checked = true; greenradio[0].checked = true; blueradio[0].checked = true;  break;
          case 4: redradio[1].checked = true; greenradio[0].checked = true; blueradio[1].checked = true;  break;
          case 5: redradio[1].checked = true; greenradio[1].checked = true; blueradio[0].checked = true;  break;
          case 6: redradio[1].checked = true; greenradio[1].checked = true; blueradio[2].checked = true;  break;
          case 7: redradio[1].checked = true; greenradio[2].checked = true; blueradio[1].checked = true;  break;
          case 8: redradio[1].checked = true; greenradio[2].checked = true; blueradio[2].checked = true;  break;
          case 9: redradio[2].checked = true; greenradio[1].checked = true; blueradio[1].checked = true;  break;
          case 10: redradio[2].checked = true; greenradio[1].checked = true; blueradio[2].checked = true;  break;
          case 11: redradio[2].checked = true; greenradio[2].checked = true; blueradio[1].checked = true;  break;
          case 12: redradio[2].checked = true; greenradio[2].checked = true; blueradio[3].checked = true;  break;
          case 13: redradio[2].checked = true; greenradio[3].checked = true; blueradio[2].checked = true;  break;
          case 14: redradio[2].checked = true; greenradio[3].checked = true; blueradio[3].checked = true;  break;
          case 15: redradio[3].checked = true; greenradio[2].checked = true; blueradio[2].checked = true;  break;
          case 16: redradio[3].checked = true; greenradio[2].checked = true; blueradio[3].checked = true;  break;
          case 17: redradio[3].checked = true; greenradio[3].checked = true; blueradio[2].checked = true;  break;
          case 18: redradio[0].checked = true; greenradio[0].checked = true; blueradio[2].checked = true;  break;
          case 19: redradio[0].checked = true; greenradio[2].checked = true; blueradio[0].checked = true;  break;
          case 20: redradio[0].checked = true; greenradio[2].checked = true; blueradio[1].checked = true;  break;
          case 21: redradio[1].checked = true; greenradio[0].checked = true; blueradio[2].checked = true;  break;
          case 22: redradio[1].checked = true; greenradio[1].checked = true; blueradio[3].checked = true;  break;
          case 23: redradio[1].checked = true; greenradio[3].checked = true; blueradio[1].checked = true;  break;
          case 24: redradio[1].checked = true; greenradio[3].checked = true; blueradio[2].checked = true;  break;
          case 25: redradio[2].checked = true; greenradio[0].checked = true; blueradio[0].checked = true;  break;
          case 26: redradio[2].checked = true; greenradio[1].checked = true; blueradio[0].checked = true;  break;
          case 27: redradio[2].checked = true; greenradio[1].checked = true; blueradio[3].checked = true;  break;
          case 28: redradio[3].checked = true; greenradio[1].checked = true; blueradio[1].checked = true;  break;
          case 29: redradio[3].checked = true; greenradio[2].checked = true; blueradio[1].checked = true;  break;
          case 30: redradio[0].checked = true; greenradio[0].checked = true; blueradio[0].checked = true;  break;
          case 31: redradio[1].checked = true; greenradio[1].checked = true; blueradio[1].checked = true;  break;
          case 32: redradio[2].checked = true; greenradio[2].checked = true; blueradio[2].checked = true;  break;
          case 33: redradio[3].checked = true; greenradio[3].checked = true; blueradio[3].checked = true;  break;
          case 34: redradio[0].checked = true; greenradio[3].checked = true; blueradio[2].checked = true;  break;
          case 35: redradio[0].checked = true; greenradio[2].checked = true; blueradio[2].checked = true;  break;
          case 36: redradio[1].checked = true; greenradio[3].checked = true; blueradio[3].checked = true;  break;
          case 37: redradio[2].checked = true; greenradio[0].checked = true; blueradio[2].checked = true;  break;
          case 38: redradio[3].checked = true; greenradio[1].checked = true; blueradio[3].checked = true;  break;
          case 39: redradio[2].checked = true; greenradio[2].checked = true; blueradio[0].checked = true;  break;
          case 40: redradio[3].checked = true; greenradio[3].checked = true; blueradio[1].checked = true;  break;
          case 41: redradio[2].checked = true; greenradio[0].checked = true; blueradio[3].checked = true;  break;
          case 42: redradio[0].checked = true; greenradio[1].checked = true; blueradio[2].checked = true;  break;
          case 43: redradio[1].checked = true; greenradio[2].checked = true; blueradio[3].checked = true;  break;
          case 44: redradio[0].checked = true; greenradio[3].checked = true; blueradio[1].checked = true;  break;
          case 45: redradio[1].checked = true; greenradio[0].checked = true; blueradio[3].checked = true;  break;
          case 46: redradio[1].checked = true; greenradio[2].checked = true; blueradio[0].checked = true;  break;
          case 47: redradio[2].checked = true; greenradio[3].checked = true; blueradio[1].checked = true;  break;
          case 48: redradio[2].checked = true; greenradio[0].checked = true; blueradio[1].checked = true;  break;
          case 49: redradio[3].checked = true; greenradio[1].checked = true; blueradio[2].checked = true;  break;
          case 48: redradio[3].checked = true; greenradio[1].checked = true; blueradio[0].checked = true;  break;
          case 49: redradio[3].checked = true; greenradio[2].checked = true; blueradio[0].checked = true;  break;
    /* ... */

    https://olgusha.ru/javascript/colors.htm, да ещё написано, что попробуйте протестировать способность вашего компьютера сочинять музыку и выбирать случайным образом цвета.

    unicorn, 18 Мая 2019

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

    0

    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
    $('.checkboxwrap').on('mousedown',e => {
        if($(e.target)[0].tagName == 'LABEL' && $(e.target).children('input').prop('checked')  || $(e.target)[0].tagName == 'INPUT' && $(e.target).prop('checked')){
            conf($(e.target));
        } else {
          console.log(12)
        }
    });
    
    function conf(e){
        let check = confirm('Точно?'),
            input = $('.checkboxwrap input');
    
        if(e[0].tagName == 'LABEL'){
            if(check) {
              input.eq($('label').index(e)).prop('checked',false);
              console.log(13)
            } else {
              input.eq($('label').index(e)).prop('checked',true);
            }
        }
        else{
            if(check) {
              input.eq($('input').index(e)).prop('checked',false);
              console.log(14)
            } else {
              input.eq($('input').index(e)).prop('checked',true);
            }
        }
    }

    Автор скрипта написал, что не во всех браузерах работает... наверно ожидал, что ещё добавят!

    А тут...

    $(".checkbox").on("change", ({ target }) => {
    if(!target.checked)
    target.checked = !confirm('Точно?');
    });


    Однако!

    P. S. Скрипт к таким фрагментам...

    <label class="checkboxwrap">
    <input type="checkbox" class="checkbox">
    Husband
    </label>

    unicorn, 30 Марта 2019

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

    0

    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
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>Calendar</title>
    </head>
    <body>
    
    <style>
    .month, .month.vert .week, .day { display:inline-block; }
    .month.vert .day { display:block; }
    .day { border:1px solid #ccc; width:30px; line-height:30px; text-align:center; }
    </style>
    
    <div class="month"></div>
    
    <script>
    var calendar = {
        update: function (year, month) {
            this.days.length = 7;
            var stepDay = new Date(year, month, 1);
            stepDay.setDate(1 - stepDay.getDay());
            var lastDay = new Date(year, month + 1, 0);
            lastDay.setDate(lastDay.getDate() + 6 - lastDay.getDay());
            while (stepDay <= lastDay) {
                this.days.push(stepDay.getDate());
                stepDay.setHours(24);
            }
        },
        render: function () {
            var html = '';
            for (var i = 0, j = 0; i < this.days.length; j = ++i % 7) {
                if (j == 0) html += '<div class="week">';
                html += '<div class="day">' +  this.days[i] + '</div>';
                if (j == 6) html += '</div>';
            }
            this.element.innerHTML = html;
        },
        toggle: function () {
            this.element.classList.toggle('vert');
        }
    };
    var today =  new Date, thisYear = today.getFullYear(), thisMonth = today.getMonth();
    calendar.days = ['S', 'M', 'T', 'W', 'T', 'F', 'S'];
    calendar.element = document.querySelector('.month');
    calendar.element.addEventListener('click', function () { calendar.toggle() });
    calendar.update(thisYear, thisMonth);
    calendar.render();
    </script>
    
    </body>
    </html>

    unicorn, 16 Февраля 2019

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function plusD() {
    	var data_plus = new Date(1000 * 60 * 60 * 24),
    	us_Mill = data_plus.getTime();
    	return us_Mill;
    }

    unicorn, 10 Февраля 2019

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

    −2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function okruglik(num) {
    	if(isNaN(num)){
    		summi = summi;
    	} else {
    		summi = Math.floor(num);
    	}
    	return summi;
    }

    Притом функция нигде не используется и переменная не объявлена

    unicorn, 10 Ноября 2018

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