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

    +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
    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
    case 'create': {
    								promisesCount.create++;
    								try {
    									var data = item.data;
    									data.status = 'new';
    
    									data.syncItemType = item.data.itemType;
    								} catch (e) {
    									console.log('create');
    									console.log(e);
    									console.log(e.stack);
    								}
    								return new vow.Promise(function(resolve, reject){
    									//resolve();
    									app.crud.create('items', data, req.user).then(function () {
    										resolve();
    									}, function (error) {
    										reject(error)
    									});
    								});
    							}
    							case 'update': {
    								promisesCount.update++;
    								try{
    									var data = item.actual;
    									data.citiesPrices = item.data.citiesPrices;
    									if (item.actual.type == 'brick') {
    										for(var key in data.citiesPrices) {
    											data.citiesPrices[key] = item.data.citiesPrices.brickAllRegion;
    										}
    									}
    									data.syncItemType = item.data.itemType;
    
    									if (item.actual.type && item.actual.status == 'site') {
    										if (item.actual.type == 'brick') {
    											if (!item.data.convertion || !item.data.convertion.piecesInPalette || !item.data.convertion.piecesPerMeter) {
    												/*console.log(item.actual.type, item.actual.subType, item.actual.axaptaItemId);
    												console.log(indexProducers[item.actual.producer].name, indexCollections[item.actual.collection].name);*/
    												wrongItems.push(item);
    												wrongItemsCount.brick++;
    											} else {
    												rightItemsCount.brick++;
    												data.countInPallet = item.data.convertion.piecesInPalette;
    												data.piecesPerMeter = item.data.convertion.piecesPerMeter;
    											}
    										} else {
    											if (item.data.measure && ['кв.м.', 'шт.'].indexOf(item.data.measure) != -1) {
    												switch(item.data.measure) {
    													case 'кв.м.': {
    														if (!item.data.convertion || !item.data.convertion.metersInPalette || !item.data.convertion.metersInBox || !item.data.convertion.metersInPiece) {
    															/*console.log(item.actual.type, item.actual.subType, item.actual.axaptaItemId);
    															console.log(indexProducers[item.actual.producer].name, indexCollections[item.actual.collection].name);*/
    															wrongItems.push(item);
    															wrongItemsCount.clinkerItems++;
    														} else {
    															rightItemsCount.clinkerItems++;
    															data.countInPallet = parseInt(item.data.convertion.metersInPalette / item.data.convertion.metersInBox);
    															data.countInPack = parseInt(item.data.convertion.metersInBox / item.data.convertion.metersInPiece);
    														}
    														break;
    													}
    													case 'шт.': {
    														if (!item.data.convertion || !item.data.convertion.piecesInBox) {
    															/*console.log(item.actual.type, item.actual.subType, item.actual.axaptaItemId);
    															console.log(indexProducers[item.actual.producer].name, indexCollections[item.actual.collection].name);*/
    															wrongItems.push(item);
    															wrongItemsCount.clinkerMeters++;
    														} else {
    															rightItemsCount.clinkerMeters++;
    															data.countInPack = item.data.convertion.piecesInBox;
    														}
    														break;
    													}
    												}
    											}
    										}
    									}
    								} catch(e) {
    									console.log('update');
    									console.log(e);
    									console.log(e.stack);
    								}

    Хороший, читабельный код от предыдущих разрабов

    jetcock, 09 Сентября 2015

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

    +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
    $tel = Number::clearPhone(trim($info['telephone']));
                $allowed_chars = '1234567890';
                if (!Number::clearPhone($tel)) {
                    $errors['error'] = "Введите телефонный номер";
                    $errors[] = 'telephone';
                }
                for ($i = 0; $i < mb_strlen($tel); $i++) {
                    if (mb_strpos($allowed_chars, mb_strtolower($tel[$i])) === false) {
                        $errors['error'] = "В номере должны быть только числа";
                        $errors[] = 'telephone';
                    }
                }

    ну вот можно же было просто как-то так написать:

    preg_match('^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$', $tel)

    NotFake, 09 Сентября 2015

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

    +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
    var promise = new Promise(function (reject, resolve) {
    			$.ajax({
    				url: url,
    				method: method,
    				contentType: 'application/json',
    				headers: headers,
    				data: JSON.stringify(data),
    				success: function (response) {
    					resolve(response); 
    				},
    				error: function (error) {
    					reject(error);
    				}
    			});
    
    		});

    kon_simeonov, 08 Сентября 2015

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    var getVisualizerCount = function() {
        var count = 0;
        if (visualizerConfig && visualizerConfig.visualizers) {
            for (var i = 0; i < visualizerConfig.visualizers.length; i++) {
                count = count + 1;
            }
        }
        return count;
    };

    Достался проект от индусов. И такого коровьего д****а, хоть ж***й жуй. По мере нахождения запощу еще.

    uusb, 08 Сентября 2015

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

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    header .phone .icons .vk {
            background: url(/images/design/vk.png) rgba(221, 221, 221, 0.22);
    }
    
    header .phone .icons .vk:hover {
    	background-color:rgba(221, 221, 221, 0);
    	display:none;
    }

    Если пользователь нашёл элемент, прячем его

    tutov2013, 08 Сентября 2015

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function blinker() {
        $('.js_blick').fadeOut(900);
        $('.js_blick').fadeIn(900);
    }
    
    setInterval(blinker, 1000); //Runs every second

    maderwin, 08 Сентября 2015

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

    +1

    1. 1
    [\s\S]+?

    3_14dar, 08 Сентября 2015

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $('#razmer-pizzi li').click(function(){
                if($(this) === $('#razmer-pizzi li:first-child')){
                    $('.table-chto-vishlo tr:first-child').html('<td>РАЗМЕР ПИЦЦЫ 25 СМ</td>');
                }else if($(this) === $('#razmer-pizzi li:nth-child(2)')){
                    $('.table-chto-vishlo tr:first-child').html('<td>РАЗМЕР ПИЦЦЫ 30 СМ</td>');
                }else if($(this) === $('#razmer-pizzi li:nth-child(3)')){
                    $('.table-chto-vishlo tr:first-child').html('<td>РАЗМЕР ПИЦЦЫ 40 СМ</td>');
                };
            });

    С тостера.

    Сослепу прочитал слово razmer-pizzi как... в общем не так. :-\

    Arris, 07 Сентября 2015

    Комментарии (9)
  9. PHP / Говнокод #18684

    +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
    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
    <?
    require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
    $APPLICATION->SetTitle("Новости");
    ob_start();
    
    $APPLICATION->IncludeComponent("bitrix:news", "news-lenta", array(
    	"IBLOCK_TYPE" => "press",
    	"IBLOCK_ID" => "12",
    # вырезано: просто вызывается компонент Битрикс "список новостей"
    );
    
    # веселье тут. Шах и мат, Битрикс!
    $html_code = ob_get_contents();
    ob_end_clean();
    $doc = new DOMDocument();
    
    $html_code = mb_convert_encoding('<meta charset="utf-8">'.$html_code, 'HTML-ENTITIES', "UTF-8");
    if($doc->loadHTML($html_code))
    {
    	$xpath = new DOMXpath($doc);
    }
    // Элемент
    $element_list = $xpath->query(".//descendant::div[@id='element']");
    if($element_list->length > 0)
    {?>
        <div class="container"><?
    	for($i=0;$i<$element_list->length;$i++)
    	{
    		echo $doc->saveHTML($element_list->item($i));
    	}
    	?></div><?}
    
    // Новости
    $blog_post_list = $xpath->query(".//descendant::div[@id='res']/div[@class='blog margin-bottom-40']");
    if($blog_post_list->length > 0)
    {
    	?><div class="container blog-full-width"><?
    	for($i=0;$i<$blog_post_list->length;$i++)
    	{
    		
    		echo $doc->saveHTML($blog_post_list->item($i));
    		
    	}
    	?></div><?
    }
    // Пагинатор
    $pagination_list = $xpath->query(".//descendant::ul[@class='pagination']");
    if($pagination_list->length > 0)
    {
    	?><div class="text-center"><?
    	for($i=0;$i<$pagination_list->length;$i++)
    	{
    		
    		echo $doc->saveHTML($pagination_list->item($i));
    		
    	}
    	?></div><?
    }
    ?>
    
     <? require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>

    Шах и мат, Битрикс!

    nik757, 07 Сентября 2015

    Комментарии (7)
  10. PHP / Говнокод #18681

    +3

    1. 1
    protected  $MIN_PHOTO_COUNT = 10; #Используется для того, чтобы определить что это фотоотчёт а не детский утренник, хотя если честно сомнительно

    Рабочий сервис с фотоотчётами городских мероприятий...

    bit0rez, 07 Сентября 2015

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