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

    +159.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
    // Create new script element and start loading.
    _obtainScript: function(id, href) { with (document) {
        var span = null;
        // Oh shit! Damned stupid fucked Opera 7.23 does not allow to create SCRIPT 
        // element over createElement (in HEAD or BODY section or in nested SPAN - 
        // no matter): it is created deadly, and does not respons on href assignment.
        // So - always create SPAN.
        var span = createElement("SPAN");
        span.style.display = 'none';
        body.appendChild(span);
        span.innerHTML = 'Text for stupid IE.<s'+'cript></' + 'script>';
        setTimeout(function() {
            var s = span.getElementsByTagName("script")[0];
            s.language = "JavaScript";
            if (s.setAttribute) s.setAttribute('src', href); else s.src = href;
        }, 10);
        this._id = id;
        this._span = span;
    }},

    коммент жжот, грубо, но справедливо

    via xeonix

    striker, 12 Октября 2009

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

    +161.4

    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 brname=navigator.appName, BrVer='';
    if(brname.substring(0,2)=="Mi")
        BrVer='E';
    
    //реализация
     function showElement(elName)
    {
        if(BrVer!='E') return; //не осёл? и пошли нафиг!
        for (i = 0; i < document.all.tags(elName).length; i++)
        {
            //блаблабла
        }
    }

    типа выпадающее меню. типа только для IE.

    Ad_Astra, 12 Октября 2009

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

    +188

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    <noscript>
    <script language="Javascript">
    alert('Что бы пользоваться всеми возможностями сайта включите JavaScript!');
    </script>
    <noscript>

    Вот такое встретил на одном сайте xD.

    nico-izo, 06 Октября 2009

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

    +150

    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
    var currentDate = new Date();
    var currentDay = currentDate.getDay();
    var currentMonth = currentDate.getMonth();
    var currentYear = currentDate.getYear();
    var currentHour = currentDate.getHours();
    var currentMinute = currentDate.getMinutes();
    var currentSecond = currentDate.getSeconds();
    if (currentMonth < 10) {
    	currentMonth = '0' + currentMonth;
    }
    if (currentDay < 10) {
    	currentDay = '0' + currentDay;
    }
    if (currentHour < 10) {
    	currentHour = '0' + currentHour;
    }
    if (currentMinute < 10) {
    	currentMinute = '0' + currentMinute;
    }
    if (currentSecond < 10) {
    	currentSecond = '0' + currentSecond;
    }

    говно

    Sadie, 25 Сентября 2009

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

    +159.1

    1. 1
    paramsObj.templateName = templateNewWindow.items.items[0].items.items[0].items.items[0].items.items[0].getValue();

    Получение значения ExtJS'ного контрола, который спрятан глубоко в дереве.

    stan, 22 Сентября 2009

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

    +157.3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function SetStyleForFilterOver(this2) {
        this2.style.border = "1px solid #ea0000";
        this2.style.color = "white";
        this2.style.background = "#404040";
    }
    function SetStyleForFilterOut(this2) {
        this2.style.border = "1px solid #404040";
        this2.style.color = "#ea0000";
        this2.style.color = "#ea0000";
        this2.style.background = "#eeeeee";
    }

    Тс-с-с-с... Только не говорите автору про css и селектор ":hover" :о)

    Ordos, 21 Сентября 2009

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

    +158.1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    case 'down':
    	if (parseInt(pageTop) + parseInt(pageHeight) - parseInt(elementTop) - parseInt(elementHeight) - parseInt(elementBorderTop) - parseInt(elementBorderBottom) >= parseInt(stepOfMove)) {
    		var topParam = parseInt(elementTop) - 0 + parseInt(stepOfMove) + 'px';
    		elementToMove.style.top = topParam;
    		this.updateElementsParams(id,'top',topParam);
    	} else {
    		stepOfMoveElement.value = parseInt(pageTop) - 0 + parseInt(pageHeight) - parseInt(elementTop) - parseInt(elementHeight) - parseInt(elementBorderTop) - parseInt(elementBorderBottom);
    	}
    break;

    и так миллион тыщ раз...

    Sadie, 21 Сентября 2009

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

    +163.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    //Я ТИПА ЗДЕСЬ СДЕЛАЛ НА ГАЛЕРЕЕ 4 КАРТИНКИ
                   if(this.id=='gallery') {
                        this.previewCount = 4;
                   } else {
                        this.previewCount = 4;
                   }

    Недавно код пересматривали. Авторы долго отнекивались

    hagnar, 19 Сентября 2009

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

    +152.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    Перл #1:
     ...
     setCityId(getCityId()); 
     ...
    
    Перл #2:
    function performOrgSearch(){
      // ...
      cityId = getCityId(); // функция getCityId вычищает всё из некого input type=text

    yvu, 18 Сентября 2009

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

    +162.5

    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
    //было:
    
      if(this.focusCount == this.blurCount + 1)
       {
         this.counter++;
       }
    
    //стало:
    
       if(this.focusCount == this.blurCount + 1)
       {
         this.counter++;
       }
       else this.counter++;

    Надо было из функции убрать проверку условия.

    psychos, 17 Сентября 2009

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