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

    +155

    1. 1
    2. 2
    if(rradiocheck.test(elem.type)&&!jQuery.support.checkOn){return elem.getAttribute("value")===null?"on":elem.value;}
    return(elem.value||"").replace(rreturn,"");}

    http://govnokod.ru/media/ddd20ce56acf1d9ebadd126322495087.js
    Говно так и льется.

    gost, 23 Марта 2014

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

    +157

    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
    postToAgent: function(n) {
    	var _this = this,
    	i = _this.arCache.decIndex,
    	dlgText = '......'; //тут текст убран, чтоб не злить дядек.
    
    	$('#paydataform').attr('action', _this.arPayAgentsList[n].target);
    	$('#paydataform').append('<input type="hidden" name="postdate" value="'+ _this.arDecisList[i].DatePost +'"/>');
    	$('#paydataform').append('<input type="hidden" name="postnum" value="'+ _this.arDecisList[i].NumPost +'"/>');
    	$('#paydataform').append('<input type="hidden" name="postsum" value="'+ _this.arDecisList[i].Summa +'"/>');
    	$('#paydataform').append('<input type="hidden" name="divid" value="'+ _this.arDecisList[i].Division +'"/>');
    	$('#paydataform').append('<input type="hidden" name="uin" value="'+ _this.arDecisList[i].SupplierBillID +'"/>');
    	$('#paydataform').append('<input type="hidden" name="'+_this.arPayAgentsList[n].addpnam+'" value="'+ _this.arPayAgentsList[n].addpval +'"/>');
    		
    	if(confirm(dlgText)) {
    		$('#paydataform').submit();
    		var wnd = BX.WindowManager.Get();
    		if(wnd && !wnd.unclosable)wnd.Close();
    	}
    },

    - Сериализация и jQuery.post
    - Не слышал

    n0cte, 21 Марта 2014

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

    +165

    1. 1
    objects = objects.concat([something]);

    альтернатива для push наконец найдена

    strax, 21 Марта 2014

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

    +153

    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
    if($(".column.fixed").size() && !pageStyle.tablet && !pageStyle.touch) {
    		var maxOffset = $("div[class='column3']").height() + $("div[class='column3']").offset().top;
    		var columnFixed = $(".column.fixed");
    		var column3Offset = columnFixed.offset().top;
    		// debug
    		if(false) {
    			$("body").append("<div id='walla'></div>");
    			var div = $("#walla");
    			div.css({
    				width: "100%",
    				height: "10px",
    				background: "green",
    				position: "absolute",
    				top: maxOffset
    			});
    		}
    
            console.log(maxOffset);
    
    		wnd.scroll(function() {
    			var top = wnd.scrollTop();
    			var position = (top - column3Offset + 85) > 0 ? "fixed" : "static";
    
    			var marginTop = 0;
    
    			if(position == "fixed") {
    				marginTop = (-1) * column3Offset + 85;
    
                    // debug
    
                    //console.log(top);
    				// console.log(maxOffset);
    
    				if(top + columnFixed.height() + 150 > maxOffset) {
    					marginTop = marginTop - (top + columnFixed.height() + 150 - maxOffset);
    					// console.log('sdfsdf');
    				}
    			}
    
    			columnFixed.css({
    				marginTop: marginTop,
    				position: position
    			});
    		});
    	}

    Прилипающий блок при скролле (без учета увеличения контента).... особенно мне нравится if(false)

    farit_slv, 20 Марта 2014

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

    +155

    1. 1
    $(obj).parent().parent().parent().append('<div class="add_new_comment"><div class="add_comment added">'+c_area+"</div></div>");

    Очень быстрый код, оптимальный алгоритм обращения к селектору.

    Gordun, 19 Марта 2014

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

    +166

    1. 1
    2. 2
    if (value) return (value != null)
               else return false;

    Из кода проекта.... Автор уволился

    alex123098, 17 Марта 2014

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

    +166

    1. 1
    window.__debugMode = true; // Don't turn it off

    vk.com/js/al/common.js

    UnnamedUser, 15 Марта 2014

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

    +154

    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
    var SE = document.getElementsByTagName("a");
    for (var i = 0; i < SE.length; i++)
    {
        if (SE[i].href.indexOf('http://www.govnokod.ru/ratings/comment/') == 0
    	    && SE[i].href.indexOf('on') != -1)
    	{
    		plusIT(SE[i].href);
    		console.log(SE[i].href);
    	}
    }
    
    function plusIT(ID)
    {
    	$.get(
        ID,
        {},
        function(x) {
        });
    }

    gost, 15 Марта 2014

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

    +156

    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
    // MiniNews
       if($(".news_sl-column.gallery").size()) {
            $(".minigal-nav .counter").text("1 из " + $(".news_sl-column.gallery").find("li").size());
    
            $(".minigal-nav li.next").on("click", function() {
                var index = $(".news_sl-column.gallery li.current").index();
                index++;
    
                if(index > $(".news_sl-column.gallery").find("li").size() - 1) {
                    index = 0;
                }
    
                switchImage(index);
            });
            if (window.isWindowsPhone){
            	$(".news_sl-column.gallery img").attr("onclick", '$(".minigal-nav li.next").trigger("click");');
            } else {
            	$(".news_sl-column.gallery img").on("click", function() {
            	    $(".minigal-nav li.next").trigger("click");
            	});
            }
    
            if (window.isWindowsPhone){
            	$(".minigal-nav li.prev").attr("onclick", 'var index = $(".news_sl-column.gallery li.current").index(); index--; if(index < 0) { index = $(".news_sl-column.gallery").find("li").size() - 1;} switchImage(index);');
            } else {
            	$(".minigal-nav li.prev").on("click", function() {
            	    var index = $(".news_sl-column.gallery li.current").index();
            	    index--;
            	    if(index < 0) {
            	        index = $(".news_sl-column.gallery").find("li").size() - 1;
            	    }
            	    switchImage(index);
            	});
            }
    
            var switchImage = function(index) {
                $(".news_sl-column.gallery li.current").fadeOut(function() {
                    $(this).removeClass("current");
                    $(".news_sl-column.gallery").find("li").eq(index).fadeIn().addClass("current");
                });
    
                $(".minigal-texts li.current").fadeOut(function() {
                    $(this).removeClass("current");
                    $(".minigal-texts").find("li").eq(index).fadeIn().addClass("current");
                });
    
                $(".minigal-nav .counter").text(index + 1 + " из " + $(".news_sl-column.gallery").find("li").size());
            }
        }
        // endof MiniNews

    Это проект меня убивает....

    farit_slv, 13 Марта 2014

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

    +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
    window.checkPluginVersion = function(id, version) {
        if (!(plugin(id) && plugin(id).valid)) return false;
        var plugin_version = plugin(id).version.split('.');
        var portal_version = version.split('.');
        if (isNaN(parseInt(plugin_version[0]))) return false;
        if (isNaN(parseInt(plugin_version[1]))) return false;
        if (isNaN(parseInt(plugin_version[2]))) return false;
        if (isNaN(parseInt(portal_version[0]))) return false;
        if (isNaN(parseInt(portal_version[1]))) return false;
        if (isNaN(parseInt(portal_version[2]))) return false;
        if (parseInt(plugin_version[0]) > parseInt(portal_version[0])) return true;
        if (parseInt(plugin_version[0]) < parseInt(portal_version[0])) return false;
        if (parseInt(plugin_version[1]) > parseInt(portal_version[1])) return true;
        if (parseInt(plugin_version[1]) < parseInt(portal_version[1])) return false;
        if (parseInt(plugin_version[2]) > parseInt(portal_version[2])) return true;
        if (parseInt(plugin_version[2]) < parseInt(portal_version[2])) return false;
        return true;
    }

    Код с Госуслуг. Nuff said

    dmgl, 13 Марта 2014

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