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

    +165

    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
    // Обновление надписи "Мои покупки"
    var file_f_basket = "/personal/cart/basket.php";
    
    //удаление пробелов, возврата каретки
    function trim(string)
    {
    	return string.replace(/(^\s+)|(\s+$)/g, "");
    }
    
    function BasketDeleteByID(id) {
    	BX.showWait();
    	jQuery.get(file_f_basket,{action:"DELETE",ID:id}, 
    	 function(data) 
    			{
    				if (trim(data) == "Success") 
    				{
    					var old = document.getElementById("record_" + id);
    					old.parentNode.removeChild(old);
    					SaleBasketUpdateTotal();
    				}
    				else if (trim(data) == "Empty")
    				{
    					var old = document.getElementById("goods");
    					old.parentNode.removeChild(old);
    					var old = document.getElementById("basket");
    					var mes = old.parentNode;
    					old.parentNode.removeChild(old);
    					var text = document.createTextNode("");
    					text.nodeValue = "Ваша корзина пуста.";
    					var elem = document.createElement("font");
    					elem.appendChild(text);
    					document.body.appendChild(elem);
    					elem.className="errortext";
    					mes.appendChild(elem);
    				}
    				
    				BasketUpdateLine();
    				BX.closeWait();
    				}
    				
    	);
    }
    function SaleBasketUpdateTotal() {
    
        var meForm   = document.getElementById('goods');
    
        var spanArray  = meForm.getElementsByTagName('span');
    
        var allSumm = 0;
    
        for (j = 0; j < spanArray.length; j++) {
            if (spanArray[j].className == "goodtotal")
               allSumm = allSumm + parseFloat(spanArray[j].innerHTML);
        }
    
        document.getElementById('total_sum').innerHTML = allSumm;
    }
    /*
     * Входные параметры функции:
     *    quant     - количество товара
     *    prise     - стоимость за единицу
     *    updElemId - идентификатор элемента, в котором требуется обновить данные (по конкретному товару)
     **/
     function SaleBasketUpdateTotalById(quant, price, updElemId)
     {
           
         var anum = /(^\d+$)|(^\d+\.\d+$)/;
         if (!anum.test(quant)) {
           
             alert('Введенное значение не является числом!');
             return;
         }
           
         goodSum = quant * price;
      
         document.getElementById(updElemId).innerHTML = goodSum;
    
    	 SaleBasketUpdateTotal();     
     }
     function isNumKeyPressed(_this,_event) {
    		if (!_event) _event = event;
    		var q = _this;
    		
    		if ((_event.keyCode > 8 || _event.keyCode < 57) & (_event.keyCode != 0)) return true;
    		if ((_event.charCode < 8 || _event.charCode > 57)) return false;
    		if (q.value.length >= 2) return false;	
    	}
    
    function BasketUpdateLine()
    {
    	jQuery.get(file_f_basket, {action: "COUNT"}, function(data)
    			{
    				if (parseInt(trim(data)) > 0 )
    					jQuery("#basket_line").html("<a href='/personal/cart/' class='basket-line'>Мои покупки (" + trim(data) + ")</a>");
    				else
    					jQuery("#basket_line").html("Мои покупки");
    			}
    	);

    Это мой гавнокодище... хыххы

    Ded_Maksim, 23 Августа 2010

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

    +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
    function BBCalign(value) {
     var txtarea = document.post.message;
     if ((clientVer >= 4) && is_ie && is_win) {
      theSelection = document.selection.createRange().text;
      if (theSelection != '') {
      document.selection.createRange().text = "[align="+value+"]" + theSelection + "[/align]";
      document.post.message.focus();
      return;
      }
     }
     else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
     {
      mozWrap(txtarea, "[align="+value+"]", "[/align]");
      return;
     }
     if (value == 'justify')
     {
      if (justify == 0) {
       ToAdd = "[align=justify]";
       $(document.post.justify).addClass('bold');
       justify = 1;
      } else {
       ToAdd = "[/align]";
       $(document.post.justify).removeClass('bold');
       justify = 0;
      }
        }
        else if (value == 'right')
        {
         if (right == 0) {
       ToAdd = "[align=right]";
       $(document.post.right).addClass('bold');
       right = 1;
      } else {
       ToAdd = "[/align]";
       $(document.post.right).removeClass('bold');
       right = 0;
      }
        }
        else if (value == 'center')
        {
         if (center == 0) {
       ToAdd = "[align=center]";
       $(document.post.center).addClass('bold');
       center = 1;
      } else {
       ToAdd = "[/align]";
       $(document.post.center).removeClass('bold');
       center = 0;
      }
        }
        else if (value == 'left')
        {
         if (left == 0) {
       ToAdd = "[align=left]";
       $(document.post.left).addClass('bold');
       left = 1;
      } else {
       ToAdd = "[/align]";
       $(document.post.left).removeClass('bold');
       left = 0;
      }
        }
     mozWrap2(txtarea, ToAdd);
    }

    jQuery + Dom

    PandoraBox2007, 22 Августа 2010

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

    +166

    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
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
      <title> Определение браузера </title>
    
    <script type='text/javascript'>
    function BrowserName()
    {
      var span = document.getElementById('browser');
      if(window.opera) { span.innerHTML = 'Opera'; }
      if(document.all) { span.innerHTML = 'IE'; }
      if(document.layers) {  span.innerHTML = 'NN4'; }
      if(window.XMLHttpRequest) { span.innerHTML = 'Mozilla (FireFox)'; }
      span.innerHTML = 'неизвестный браузер';
      return true;
    }
    </script>
    
    </head>
    
    <body onload='BrowserName()'>
    
      Ваш браузер: <span id='browser'></span>
    
    </body>
    </html>

    Блуждая в поисках откопал ещё вот такое...

    istem, 22 Августа 2010

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

    +167

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    <script>T=new Array();A=new Array();C=new Array();D=new Array();D[0]='Причастие ИСПУГАННЫЙ образовано от глагола совершенного вида ИСПУГАТЬ (ЧТО СДЕЛАТЬ?), кроме этого имеет приставку ИС- , поэтому пишется с двумя буквами Н';C[0]=2;T[0]=new Array('_н','н','нн');
    D[1]='Причастие ОБРАДОВАННЫЙ образовано от глагола совершенного вида ОБРАДОВАТЬ (ЧТО СДЕЛАТЬ?), кроме этого, имеет суффикс -ОВА- , поэтому пишется с двумя буквами Н';C[1]=2;T[1]=new Array('_н','н','нн');
    D[2]='Причастие ОСНОВАННОЕ имеет зависимые слова НИ НА ЧЕМ, поэтому пишется с двумя буквами Н';C[2]=2;T[2]=new Array('_н','н','нн');
    D[3]='Причастие НЕПРИГЛАШЕННЫЙ образовано от глагола совершенного вида ПРИГЛАСТЬ (ЧТО СДЕЛАТЬ?), поэтому пишется с двумя буквами Н';C[3]=2;T[3]=new Array('_н','н','нн');
    D[4]='Слово ВЛЮБЛЕННОЙ образовано от глагола совершенного вида ВЛЮБИТЬСЯ (ЧТО СДЕЛАТЬ?), поэтому пишется с двумя буквами Н';C[4]=2;T[4]=new Array('_н','н','нн');
    D[5]='Это одно из тех слов, написание которых необходимо запомнить. В нем пишется две буквы Н. ';C[5]=2;T[5]=new Array('_н','н','нн');
    // Еще очень много букв и подобных строк, написанных, по-видимому, копипастом и единой строкой (разделил построчно я для удобства чтения)
    D[30]='Слово РАЗГНЕВАННУЮ образовано от глагола совершенного вида РАЗГНЕВАТЬ (ЧТО СДЕЛАТЬ?), кроме этого, имеет приставку РАЗ- , поэтому пишется с двумя буквами Н';C[30]=2;T[30]=new Array('_н','н','нн');
    D[31]='Слово НЕУГНЕТЕННЫЙ имеет приставку У- , поэтому пишется с двумя буквами Н.';C[31]=2;T[31]=new Array('_н','н','нн');</script>
    
    					<div id="notearea"><p align="justify">Выберите правильные варианты ответов. Для проверки выполненного задания нажмите кнопку «Проверить».</p></div><br>
    					<script>if (window.opera) {var d=document.createElement('div');d.innerHTML='<p class="error">К сожалению, Ваш браузер не поддерживается. Программа работает в браузерах Internet Explorer и Mozilla Firefox.</p>';document.getElementById("notearea").appendChild(d);}</script>

    Государственный портал о русском языке Грамота.ру.
    Интерактивный диктант.

    7ion, 22 Августа 2010

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function getBranch(sender, command, param1, param2, param3)
    
    {
    
      doLoad(sender, command, param1, param2, param3)
    
    }

    Без этой функции ну никак не обоитись:)

    moonie, 21 Августа 2010

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

    +144

    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
    Draggable.prototype.move = function(event){		
    		var event = Runic.event.getEvent(event),
    			mLeft = (this.direction == 'both' || this.direction == 'horizontal') ? (Runic.event.getEventX(event) - this.mdiffX) : this.element.offsetLeft,
    			mTop = (this.direction == 'both' || this.direction == 'vertical') ? (Runic.event.getEventY(event) - this.mdiffY) : this.element.offsetTop,
    		//get cursor position
    			curx = Runic.event.getEventX(event),
    			cury = Runic.event.getEventY(event);
    		if (this.box) {
    			if (this.direction == 'horizontal' || this.direction == 'both') {
    				if (curx > this.fromX && curx < this.toX) {
    					this.element.style.left = mLeft  + 'px';
    				} else if (curx <= this.fromX && this.direction) {
    					if (this.boxCSSPosition == 'relative' || this.boxCSSPosition=='absolute') {
    						this.element.style.left = 0 + 'px'
    						this.element.style.right = 'auto'
    					} else {
    						this.element.style.left = this.box.offsetLeft + 'px'
    					}
    				} else if (curx >= this.toX) {
    					if (this.boxCSSPosition == 'relative' || this.boxCSSPosition=='absolute') {
    						this.element.style.right = 0 + 'px'
    						this.element.style.left = 'auto'
    					} else {
    						this.element.style.left = this.box.offsetLeft + this.box.clientWidth - this.element.clientWidth + 'px'
    					}
    				}
    			}
    			if (this.direction == 'vertical' || this.direction == 'both') {
    				if (cury > this.fromY && cury < this.toY) {
    					this.element.style.top = mTop + 'px';
    				} else if (cury <= this.fromY) {
    					if (this.boxCSSPosition == 'relative' || this.boxCSSPosition=='absolute') {
    						this.element.style.top = 0 + 'px';
    						this.element.style.bottom = 'auto'
    					} else {
    						this.element.style.top = this.box.offsetTop + 'px'
    					}		
    				} else if (cury >= this.toY) {
    					if (this.boxCSSPosition == 'relative' || this.boxCSSPosition=='absolute') {
    						this.element.style.bottom = 0 + 'px';
    						this.element.style.top = 'auto'
    					} else {
    						this.element.style.top = this.box.offsetTop + this.box.clientHeight - this.element.clientHeight + 'px'
    					}
    				}
    			}
    		} else {
    			this.element.style.left = mLeft  + 'px';
    			this.element.style.top = mTop + 'px';
    		}
    		//run callback funciton
    		if (this.onDrag != undefined && typeof this.onDrag.func == 'function') {
    			if (this.onDragCount < this.onDrag.count || this.onDrag.count == 0) {
    				this.onDragCount++;
    				this.onDrag.func();
    			}
    		}
    	}

    наговнокодил

    kubynek, 20 Августа 2010

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

    +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
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    function countdown() {
    		var today = new Date();
    		var start = new Date();
    		start.setTime(Math.ceil(Время ближайшей трансляции будет скоро объявлено * 1000));
    		var remains = new Date();
    		remains.setTime(start - today);
    		//window.status = remains;
    		var d = remains.getUTCDate() - 1;
    		var h = remains.getUTCHours();
    		var m = remains.getUTCMinutes();
    		
    		d = textize(d, 'день', 'дня', 'дней');
    		h = textize(h, 'час', 'часа', 'часов');
    		m = textize(m, 'минуту', 'минуты', 'минут');
    		
    		if (remains.getUTCHours() == 0 && remains.getUTCMinutes() < 5) {
    			document.getElementById('remains').innerHTML="Трансляция начнется с минуты на минуту";
    		} else if (remains.getTime() < 0) {
    			document.getElementById('remains').innerHTML="Трансляция идет";
    			//if (!document.getElementById('hll')) {
    			//	location.reload(true);
    			//}
    		} else {
    			document.getElementById('remains').innerHTML="Ближайшая трансляция — через <b>"+d+" "+h+" "+m+"</b>";
    		}
    	
    		t = setTimeout('countdown()',500);
    	}

    взято с сайта http://kultu.ru/

    kubynek, 20 Августа 2010

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

    +173

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function jsPlay(soundobj) {
     var thissound= eval("document."+soundobj);
     try {
     thissound.Play(); // играй!!!
     }
     catch (e) {
     thissound.DoPlay(); // играй СЦУКО!!!!!!!!!!!
     }
    }

    http://rabota2009.ucoz.ru/
    вот так надо использовать try-catch если вы не знали.

    Alfred, 20 Августа 2010

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function rnd(){
    var randscript = -1;
    var num = banners.length;
    while (randscript < 0 || randscript > parseInt(num/col)-1 || isNaN(randscript)){
            randscript = parseInt(Math.random()*(num+1))
    }
    return randscript
    }

    http://earninguide.biz/top.js
    генераторы бывают случайные и псевдослучайные.
    но есть еще и псевдо_ХУ_евые!
    вот один из них...

    Alfred, 20 Августа 2010

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

    +162

    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 urldecode(code) {
    code = escape(code);
    code = code.replace(/\+/g,' ');
    code = code.replace(/%21/g,'!');
    code = code.replace(/%22/g,'"');
    code = code.replace(/%23/g,'#');
    code = code.replace(/%24/g,'$');
    code = code.replace(/%2D/g,'-');
    code = code.replace(/%5E/g,'^');
    code = code.replace(/%26/g,'&');
    code = code.replace(/%B9/g,'?');
    code = code.replace(/%3B/g,';');
    code = code.replace(/%25/g,'%');
    code = code.replace(/%3A/g,':');
    code = code.replace(/%3F/g,'?');
    code = code.replace(/%28/g,'(');
    code = code.replace(/%29/g,')');
    
    /*...70 строк такого же говна...*/
    
    return code;
    }

    http://informer.gismeteo.ru/js/decode.js
    Прошу прощения если баян.

    Vindicar, 18 Августа 2010

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