- 1
- 2
- 3
img[src=""]{
display:none;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+5
img[src=""]{
display:none;
}
Super-genius
+2
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);
}
Хороший, читабельный код от предыдущих разрабов
+1
$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)
+1
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);
}
});
});
+1
var getVisualizerCount = function() {
var count = 0;
if (visualizerConfig && visualizerConfig.visualizers) {
for (var i = 0; i < visualizerConfig.visualizers.length; i++) {
count = count + 1;
}
}
return count;
};
Достался проект от индусов. И такого коровьего д****а, хоть ж***й жуй. По мере нахождения запощу еще.
+4
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;
}
Если пользователь нашёл элемент, прячем его
+1
function blinker() {
$('.js_blick').fadeOut(900);
$('.js_blick').fadeIn(900);
}
setInterval(blinker, 1000); //Runs every second
+1
[\s\S]+?
+1
$('#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 как... в общем не так. :-\
+1
<?
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");?>
Шах и мат, Битрикс!