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

    +161

    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
    function getDateOfNextDay(datestring, separator, nozero)	{
    
      if(!separator)	{
        separator="-";//="yyyy-dd-mm" format
      }
    
      var a_date = datestring.split(separator);
      var myday = new Date(a_date[0]+'/'+a_date[1]+'/'+a_date[2]);
      myday.setDate(myday.getDate()+1);
    
      var next_day_year = myday.getFullYear();
      var next_day_month = myday.getMonth()+1;
    
      if(!nozero)	{
        next_day_month = (parseInt(next_day_month)<10)?"0"+next_day_month:next_day_month;
      }
    
      var next_day_day = myday.getDate();
      next_day_day = (parseInt(next_day_day)<10)?"0"+next_day_day:next_day_day;
    
      return next_day_month+"-"+next_day_day+"-"+next_day_year;
    }

    Первое что нашел гугл по запросу "javascript next day offset", автор "Arvind Kumar Thakur. I am a web developer with 7 years of hands on experience", ссылка http://www.devarticles.in/javascript/getting-next-day-date-in-javascript
    А всего-то навсего необходимо было сделать:
    >>> dt = new Date('2012-12-31')
    >>> dt.setTime(dt.getTime()+86400000) /* 1000 * 60 * 60 * 24, ms*sec*min*hour = day offset */
    Индейцы =\

    lilfox, 10 Марта 2012

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    LostFocus = function() {
      if (!IE) { // Этот код только для взрослых. Браузерам до 18 сюда нельзя!
          // ...
      }
    }

    Комментарий просто убил.

    DropWorld, 08 Марта 2012

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

    +200

    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
    for (k = 0; k < xl; k += 16) {
            AA = a;
            BB = b;
            CC = c;
            DD = d;
            a = _FF(a, b, c, d, x[k + 0], S11, 0xD76AA478);
            d = _FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
            c = _FF(c, d, a, b, x[k + 2], S13, 0x242070DB);
            b = _FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
            a = _FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
            d = _FF(d, a, b, c, x[k + 5], S12, 0x4787C62A);
            c = _FF(c, d, a, b, x[k + 6], S13, 0xA8304613);
            b = _FF(b, c, d, a, x[k + 7], S14, 0xFD469501);
            a = _FF(a, b, c, d, x[k + 8], S11, 0x698098D8);
            d = _FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
            c = _FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
            b = _FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
            a = _FF(a, b, c, d, x[k + 12], S11, 0x6B901122);
            d = _FF(d, a, b, c, x[k + 13], S12, 0xFD987193);
            c = _FF(c, d, a, b, x[k + 14], S13, 0xA679438E);
            b = _FF(b, c, d, a, x[k + 15], S14, 0x49B40821);
            a = _GG(a, b, c, d, x[k + 1], S21, 0xF61E2562);
            d = _GG(d, a, b, c, x[k + 6], S22, 0xC040B340);
            c = _GG(c, d, a, b, x[k + 11], S23, 0x265E5A51);
            b = _GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
            a = _GG(a, b, c, d, x[k + 5], S21, 0xD62F105D);
            d = _GG(d, a, b, c, x[k + 10], S22, 0x2441453);
            c = _GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
    <40 строк поспипано>
            b = _II(b, c, d, a, x[k + 9], S44, 0xEB86D391);
            a = addUnsigned(a, AA);
            b = addUnsigned(b, BB);
            c = addUnsigned(c, CC);
            d = addUnsigned(d, DD);
    }

    http://phpjs.org/downloads/phpjs.commonjs.js.
    Там оказалось реально много жира. Я сначала подумал, что сеть Фейштеля, но потом-таки разглядел MD5.
    Говносути это конечно не меняет.

    3.14159265, 07 Марта 2012

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

    +197

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.an)!==-1;},ctype_alpha:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.al)!==-1;},ctype_cntrl:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.ct)!==-1;},ctype_digit:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.dg)!==-1;},ctype_graph:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.gr)!==-1;},ctype_lower:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.lw)!==-1;},ctype_print:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.pr)!==-1;},ctype_punct:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.pu)!==-1;},ctype_space:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.sp)!==-1;},ctype_upper:function(text){if(typeof text!=='string'){return false;}
    this.setlocale('LC_ALL',0);return text.search(this.php_js.locales[this.php_js.localeCategories.LC_CTYPE].LC_CTYPE.up)!==-1;},ctype_xdigit:function(text){if(typeof text!=='string'){return false;}

    При беглом просмотре бросился мне тут в глаза кусочек из http://phpjs.org/downloads/php.common.min.js

    3.14159265, 06 Марта 2012

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

    +158

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function SetCeilingType(Txt) {
    
        if (Txt == "1") {
            document.getElementById("сeilType").value = Txt //"Одноуровневый";
        }
        else {
            document.getElementById("сeilType").value = Txt //"Двухуровневый";
        }
        createLink();
    }

    Сраная школота уходит в буддизм.
    Вот такая сентенция была найдена за flash-кодером, хуже всего что функция глобальна, так как дергается ИЗ ФЛЕША при изменении в нем данных. Творческое прочтение паттерна инверсии зависимости, сцуко!

    Meettya, 06 Марта 2012

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

    +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
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    function getLatin(str){
    	  str = str.replace(/\?/g,'');
    	  str = str.replace(/\:/g,'');
    	  str = str.replace(/\;/g,'');
    	  str = str.replace(/\|/g,'');
    	  str = str.replace(/\</g,'');
    	  str = str.replace(/\>/g,'');
    	  str = str.replace(/\}/g,'');
    	  str = str.replace(/\{/g,'');
    	  str = str.replace(/\[/g,'');
    	  str = str.replace(/\]/g,'');
    	  str = str.replace(/\//g,'');
    	  str = str.replace(/\\/g,'');
    	  str = str.replace(/\+/g,'');
    	  str = str.replace(/\-/g,'');
    	  str = str.replace(/\=/g,'');
    	  str = str.replace(/\~/g,'');
    	  str = str.replace(/\#/g,'');
    	  str = str.replace(/\@/g,'');
    	  str = str.replace(/\$/g,'');
    	  str = str.replace(/\^/g,'');
    	  str = str.replace(/\&/g,'');
    	  str = str.replace(/\*/g,'');
    	  str = str.replace(/\(/g,'');
    	  str = str.replace(/\)/g,'');
    	  str = str.replace(/%/g,'');
    	  str = str.replace(/\"/g,'');
    	  str = str.replace(/\'/g,'');
    	  str = str.replace(/,/g,'');
    	  str = str.replace(/\./g,'');
    	  str = str.replace(/!/g,'');
    	  str = str.replace(/ /g,'_');
    	  str = str.replace(/а/g,'a');
    	  str = str.replace(/б/g,'b');
    	  str = str.replace(/в/g,'v');
    	  str = str.replace(/г/g,'g');
    	  str = str.replace(/д/g,'d');
    	  str = str.replace(/е/g,'e');
    	  str = str.replace(/ё/g,'e');
    	  str = str.replace(/ж/g,'zh');
    	  str = str.replace(/з/g,'z');
    	  str = str.replace(/и/g,'i');
    	  str = str.replace(/й/g,'j');
    	  str = str.replace(/к/g,'k');
    	  str = str.replace(/л/g,'l');
    	  str = str.replace(/м/g,'m');
    	  str = str.replace(/н/g,'n');
    	  str = str.replace(/о/g,'o');
    	  str = str.replace(/п/g,'p');
    	  str = str.replace(/р/g,'r');
    	  str = str.replace(/с/g,'s');
    	  str = str.replace(/т/g,'t');
    	  str = str.replace(/у/g,'u');
    	  str = str.replace(/ф/g,'f');
    	  str = str.replace(/х/g,'h');
    	  str = str.replace(/ц/g,'c');
    	  str = str.replace(/ч/g,'ch');
    	  str = str.replace(/ш/g,'sh');
    	  str = str.replace(/щ/g,'sh');
    	  str = str.replace(/ъ/g,'');
    	  str = str.replace(/ы/g,'y');
    	  str = str.replace(/ь/g,'');
    	  str = str.replace(/э/g,'e');
    	  str = str.replace(/ю/g,'yu');
    	  str = str.replace(/я/g,'ya');
    
    	  str = str.replace(/А/g,'a');
    	  str = str.replace(/Б/g,'b');
    	  str = str.replace(/В/g,'v');
    	  str = str.replace(/Г/g,'g');
    	  str = str.replace(/Д/g,'d');
    	  str = str.replace(/Е/g,'e');
    	  str = str.replace(/Ё/g,'e');
    	  str = str.replace(/Ж/g,'zh');
    	  str = str.replace(/З/g,'z');
    	  str = str.replace(/И/g,'i');
    	  str = str.replace(/Й/g,'j');
    	  str = str.replace(/К/g,'k');
    	  str = str.replace(/Л/g,'l');
    	  str = str.replace(/М/g,'m');
    	  str = str.replace(/Н/g,'n');
    	  str = str.replace(/О/g,'o');
    	  str = str.replace(/П/g,'p');
    	  str = str.replace(/Р/g,'r');
    	  str = str.replace(/С/g,'s');
    	  str = str.replace(/Т/g,'t');
    	  str = str.replace(/У/g,'u');
    	  str = str.replace(/Ф/g,'f');
    	  str = str.replace(/Х/g,'h');
    	  str = str.replace(/Ц/g,'c');
    	  str = str.replace(/Ч/g,'ch');
    	  str = str.replace(/Ш/g,'sh');
    	  str = str.replace(/Щ/g,'sh');
    	  str = str.replace(/Ъ/g,'');
    	  str = str.replace(/Ы/g,'y');
    	  str = str.replace(/Ь/g,'');
    	  str = str.replace(/Э/g,'e');
    	  str = str.replace(/Ю/g,'yu');
    	  str = str.replace(/Я/g,'ya');

    И снова перед вами алфавит. Это код с реального сайта, http://ruskino29.ru/content/js/main.js.

    YetAnotherName, 05 Марта 2012

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

    +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
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    $('#panAll').click( function(){
    	                $(this).addClass('panactive');
    	                
    	                $('#panPan').removeClass('panactive');
    	                $('#pan3D').removeClass('panactive');
    	                $('#panVtour').removeClass('panactive');
    	                
    	                $('#AllDesc').css('display', 'block');
    	                $('#PanDesc').css('display', 'none');
    	                $('#3DDesc').css('display', 'none');
    	                $('#VtourDesc').css('display', 'none');
    	            }); 
    	            
    	            $('#panPan').click( function(){
    	                $(this).addClass('panactive');
    	                
    	                $('#panAll').removeClass('panactive');
    	                $('#pan3D').removeClass('panactive');
    	                $('#panVtour').removeClass('panactive');
    	                
    	                $('#AllDesc').css('display', 'none');
    	                $('#PanDesc').css('display', 'block');
    	                $('#3DDesc').css('display', 'none');
    	                $('#VtourDesc').css('display', 'none');
    	            }); 
    	            
    	            $('#pan3D').click( function(){
    	                $(this).addClass('panactive');
    	                
    	                $('#panAll').removeClass('panactive');
    	                $('#panPan').removeClass('panactive');
    	                $('#panVtour').removeClass('panactive');
    	                
    	                $('#AllDesc').css('display', 'none');
    	                $('#PanDesc').css('display', 'none');
    	                $('#3DDesc').css('display', 'block');
    	                $('#VtourDesc').css('display', 'none');
    	            }); 
    	            $('#panVtour').click( function(){
    	                $(this).addClass('panactive');
    	                
    	                $('#panAll').removeClass('panactive');
    	                $('#panPan').removeClass('panactive');
    	                $('#pan3D').removeClass('panactive');
    	                
    	                $('#AllDesc').css('display', 'none');
    	                $('#PanDesc').css('display', 'none');
    	                $('#3DDesc').css('display', 'none');
    	                $('#VtourDesc').css('display', 'block');
    	            });

    Висит задание в црм - доделать ***.
    Таким вот образом был реализован функционал
    переключения между 4мя дивами, содержащими в себе данные.

    denum, 05 Марта 2012

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

    +209

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    const evalScript = "with (__win__.__scope__.vars) { with (__win__.__scope__.api) { with (__win__.__scope__.userVars) { with (__win__) {" +
        "try {" +
            "__win__.__scope__.callback(eval(__win__.__scope__.expr));" +
        "} catch (exc) {" +
            "__win__.__scope__.callback(exc, true);" +
        "}" +
    "}}}}";

    http://code.google.com/p/fbug/source/browse/branches/firebug1.2/content/firebug/commandLine.js?r=444

    3.14159265, 03 Марта 2012

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

    +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
    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
    function trySearch(form)
    {
    	var loc = "/?";
    	
    	var query_len = $.trim(form.query.value).length;
    	
    	if(form.game.value !== "all")
    	{
    		loc += 'game='+form.game.value;
    	}
    	
    	if(!query_len && form.search_by.value !== 'hostname' && form.search_by.value !== 'mode')
    	{
    		$('#display').slideDown();
    		Timer.set(function(){$('#display').slideUp();},5000);
    		
    		form.query.focus();
    		var msg = '';
    		
    		switch(form.search_by.value)
    		{
    			case 'map':
    				msg = 'Введите название карты которую хотите найти, например: <a href="#" onclick="$(\'#query\').val(\'de_dust2,de_inferno\').submit(); return false;">de_dust2,de_inferno</a>';
    				break;
    			case 'player':
    				msg = 'Введите имя игрока которого хотите найти';
    				break;
    			case 'rules':
    				msg = 'Введите настройку которую хотите найти, например: <a href="#" onclick="$(\'#query\').val(\'amxmodx_version 1.8.2-dev\').submit(); return false;">amxmodx_version 1.8.2-dev</a>';
    				break;
    			case 'ip':
    				msg = 'Введите ип-адрес который хотите найти';
    				break;
    		}
    		
    		$('#Msg').html(msg);
    		
    		return false;
    	}
    	if(query_len > 0 || form.search_by.value !== 'hostname')
    		loc += (form.game.value !== "all" ? '&' : '')+"search_by="+form.search_by.value;
    	if(query_len > 0)
    	{
    		loc += "&query="+escape(form.query.value);
    	}
    	
    	location.href = loc;
    	return false;
    }

    Zend, 24 Февраля 2012

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

    +164

    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
    <script language="JavaScript">
                    <!--
                        document.write('<a href="#top" onclick="takeThis(\'<?php echo $PMA_Theme; ?>\'); return false;">');
                        document.write('<img src="<?php echo $screen_directory; ?>/screen.png" border="1" ');
                        if (document.getElementById) {
                            document.write('style="border: 1px solid #000000;" ');
                        }
                        document.write('alt="<?php echo htmlspecialchars(addslashes($theme_name)); ?>" ');
                        document.write('title="<?php echo htmlspecialchars(addslashes($theme_name)); ?>" />');
                        document.write('</a><br />');
                        document.write('[ <b><a href="#top" onclick="takeThis(\'<?php echo $PMA_Theme; ?>\'); return false;">');
                        document.write('<?php echo addslashes($strTakeIt); ?>');
                        document.write('</a></b> ]');
                    //-->
                    </script>

    Чужая самописная CMF. Файл themes в админке.

    zii, 22 Февраля 2012

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