- 1
- 2
- 3
$('input[name="global_option[1]"]').each(function () {
$('input[name="global_option[1]"]').attr('checked', 'checked');
});
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+2
$('input[name="global_option[1]"]').each(function () {
$('input[name="global_option[1]"]').attr('checked', 'checked');
});
+2
Searching 43077 files for "PROPERTY_96"
D:\OpenServer\domains\aproject.local\public_html\bitrix\templates\aproject\components\aproject\catalog.section\list\template.php:
19 // говнокод, говнокодом не испортить :)
20 $itSitno = 0;
21: if ($arElement['PROPERTY_96'] > 0)
22 {
23 $itSitno = 1;
замечательный проект.. Искал тут свойство в интернет магазине (типа макдака), которое отвечает за тип добавки к заказу (соус, мясо, и т.п.).
Называется это свойство вот так: PROPERTY_96 встречается в нескольких местах, в самом проекте 43077 файлов.
вообщем у меня бомбануло через 30 минут когда я его таки смог найти.
да это битрикс :(
+2
if(itemsCount <= 2)
{
if(iteration == 1)
{
dragItemPos = new Vector3(-20, -55, 0);
}else if(iteration == 2){
dragItemPos = new Vector3(145, 75, 0);
}
}else if(itemsCount == 3){
if(iteration == 1)
{
dragItemPos = new Vector3(60, -170, 0);
}else if(iteration == 2){
dragItemPos = new Vector3(245, -45, 0);
}else if(iteration == 3){
dragItemPos = new Vector3(20, 90, 0);
}
}else if(itemsCount == 4){
if(iteration == 1)
{
dragItemPos = new Vector3(60, -170, 0);
}else if(iteration == 2){
dragItemPos = new Vector3(245, -45, 0);
}else if(iteration == 3){
dragItemPos = new Vector3(-80, 2, 0);
}else if(iteration == 4){
dragItemPos = new Vector3(140, 160, 0);
}
}
else{
if(iteration == 1)
{
dragItemPos = new Vector3(60, -170, 0);
}else if(iteration == 2){
dragItemPos = new Vector3(245, -45, 0);
}else if(iteration == 3){
dragItemPos = new Vector3(-100, -45, 0);
}else if(iteration == 4){
dragItemPos = new Vector3(25, 95, 0);
}else if(iteration == 5){
dragItemPos = new Vector3(190, 180, 0);
}
}
Определяем позиции объекта по их количеству и по номеру итерации. Массивы? не не слышал.
+2
url = Ext.String.format('<a href="https://www.mql5.com/en/signals/' + record.get('foreign_id') + '" target="_blank" class="value_bill type_link">{0}</a>', record.get('foreign_id'))
+2
$d = getdate();
$formatMon = '';
if ($d['mon'] < 10) {
$formatMon = '0';
}
$formatMday = '';
if ($d['mday'] < 10) {
$formatMday = '0';
}
$formatHour = '';
if ($d['hours'] < 10) {
$formatHour = '0';
}
$formatMinutes = '';
if ($d['minutes'] < 10) {
$formatMinutes = '0';
}
$formatSeconds = '';
if ($d['seconds'] < 10) {
$formatSeconds = '0';
}
$today = $formatMday . $d['mday'] . '.' . $formatMon . $d['mon'] . '.' . $d['year'] . ' ' . $formatHour . $d['hours'] . ':' . $formatMinutes . $d['minutes'] . ':' . $formatSeconds . $d['seconds'];
Форматирование датывремени
+2
bool isLiveLine = false;
bool isQALine = false;
if (lineInfo.IndexOf("QL") != -1)
{
isLiveLine = true;
isQALine = true;
}
else if (lineInfo.IndexOf("Q") != -1)
{
isLiveLine = false;
isQALine = true;
}
else if (lineInfo.IndexOf("L") != -1)
{
isLiveLine = true;
isQALine = false;
}
else
{
isLiveLine = false;
isQALine = false;
}
+2
<ul class="top-level-menu">
<li style="width:14.185714285714%;" class="with-img" id="m_2641231722"> <span class="top-level-label"><a href="/catalog/plitnye_materialy_1/" title="Плитные материалы">Плитные материалы</a></span>
</li>
<li style="width:14.185714285714%;" class="with-img" id="m_1862201143"> <span class="top-level-label"><a href="/catalog/mebelnaya_furnitura_1/" title="Мебельная фурнитура">Мебельная фурнитура</a></span>
</li>
<li style="width:14.185714285714%;" class="with-img" id="m_2776938111"> <span class="top-level-label"><a href="/catalog/kromka_i_plastiki_1/" title="Кромка и пластики">Кромка и пластики</a></span>
</li>
<li style="width:14.185714285714%;" class="with-img" id="m_2757459272"> <span class="top-level-label"><a href="/catalog/stoleshnitsy_stenpaneli_1/" title="Столешницы, стенпанели">Столешницы, стенпанели</a></span>
</li>
<li style="width:14.185714285714%;" class="with-img" id="m_3136652235"> <span class="top-level-label"><a href="/catalog/razdvizhnye_sistemy_1/" title="Раздвижные системы">Раздвижные системы</a></span>
</li>
<li style="width:14.185714285714%;" class="with-img" id="m_3746925619"> <span class="top-level-label"><a href="/catalog/fasadnoe_napolnenie_1/" title="Фасадное наполнение">Фасадное наполнение</a></span>
</li>
<li style="width:14.185714285714%;" class="with-img" id="m_133346203"> <span class="top-level-label"><a href="/catalog/uslugi_1/" title="Услуги">Услуги</a></span>
</li>
</ul>
+2
public static byte[] HMACSHA256(ProtectedData key, byte[] data)
{
using (var _key = key.Get())
using (var hmac = new HMACSHA256(_key))
return hmac.ComputeHash(data);
}
public static byte[] HMACSHA256(ProtectedData key, Stream stream)
{
using (var _key = key.Get())
using (var hmac = new HMACSHA256(_key))
return hmac.ComputeHash(stream);
}
public static byte[] HMACSHA256(byte[] key, byte[] data)
{
using (var hmac = new HMACSHA256(key))
return hmac.ComputeHash(data);
}
public static byte[] HMACSHA256(byte[] key, Stream stream)
{
using (var hmac = new HMACSHA256(key))
return hmac.ComputeHash(stream);
}
public static byte[] MD5(byte[] data)
{
using (var h = System.Security.Cryptography.MD5.Create())
{ return h.ComputeHash(data); }
}
public static byte[] MD5(Stream stream)
{
using (var h = System.Security.Cryptography.MD5.Create())
{ return h.ComputeHash(stream); }
}
public static byte[] SHA1(byte[] data)
{
using (var h = System.Security.Cryptography.SHA1.Create())
return h.ComputeHash(data);
}
public static byte[] SHA1(Stream stream)
{
using (var h = System.Security.Cryptography.SHA1.Create())
return h.ComputeHash(stream);
}
public static byte[] SHA256(byte[] data)
{
using (var h = System.Security.Cryptography.SHA256.Create())
return h.ComputeHash(data);
}
public static byte[] SHA256(Stream stream)
{
using (var h = System.Security.Cryptography.SHA256.Create())
return h.ComputeHash(stream);
}
public static byte[] SHA384(byte[] data)
{
using (var h = System.Security.Cryptography.SHA384.Create())
return h.ComputeHash(data);
}
public static byte[] SHA384(Stream stream)
{
using (var h = System.Security.Cryptography.SHA384.Create())
return h.ComputeHash(stream);
}
public static byte[] SHA512(byte[] data)
{
using (var h = System.Security.Cryptography.SHA512.Create())
return h.ComputeHash(data);
}
public static byte[] SHA512(Stream stream)
{
using (var h = System.Security.Cryptography.SHA512.Create())
return h.ComputeHash(stream);
}
Психанул
+2
using Microsoft.VisualBasic;
public string ConvertEnoviaNameForDB1(string name, char Separ = '%')
{
string functionReturnValue = null;
functionReturnValue = name;
//input filename
//check ENOVIA filenames (example c0234244 --.catpart or c0234244--.catpart)
//output filename in DB format for operator LIKE(c0234244 --.catpart -> c0234244%.catpart)
int i = 0;
int loc1 = Strings.InStr(name, ".CATP", CompareMethod.Text);
bool NeedToConvert = false;
char Chr1 = '1';
char ChrBefore1 = '1';
//check catparts and catproducts ONLY
if (loc1 > 0)
{
int NumSymbols = loc1 - 2;
if (NumSymbols > 6)
NumSymbols = 6;
string tmpstr1 = Strings.Mid(name, loc1 - NumSymbols - 1, NumSymbols);
//analyse 4 chars max
for (i = 0; i <= loc1 - 2; i++)
{
Chr1 = name[loc1 - 2 - i];
//3-string array start from 0(position = count-1)
if ((Strings.Asc(ChrBefore1) >= 65 & Strings.Asc(ChrBefore1) <= 90))
{
if (Chr1 == ' ')
{
i = i + 2;
break; // TODO: might not be correct. Was : Exit For
}
else if (Chr1 == '-')
{
ChrBefore1 = Chr1;
//means can be two chars (ex. "AA") max
}
else if ((Strings.Asc(Chr1) >= 65 & Strings.Asc(Chr1) <= 90) & i < 2)
{
ChrBefore1 = Chr1;
}
else
{
break; // TODO: might not be correct. Was : Exit For
}
}
else if (ChrBefore1 == '-')
{
if (Chr1 == ' ')
{
i = i + 2;
break; // TODO: might not be correct. Was : Exit For
// And i < 3 Then 'means can be "---" - not more
}
else if (Chr1 == '-')
{
//ChrBefore1 = Chr1
}
else
{
i = i + 1;
break; // TODO: might not be correct. Was : Exit For
}
//ChrBefore1 = Chr1
// means start
}
else if (ChrBefore1 == '1')
{
if (Chr1 == '-' | (Strings.Asc(Chr1) >= 65 & Strings.Asc(Chr1) <= 90))
{
ChrBefore1 = Chr1;
}
else
{
i = i + 1;
break; // TODO: might not be correct. Was : Exit For
}
}
}
functionReturnValue = Strings.Left(name, loc1 - i) + Separ + Strings.Right(name, Strings.Len(name) - loc1 + 1);
}
return functionReturnValue;
}
Наличие комментария в 7ой строчке приводит в неописуемый восторг.
Без него понимать поведение функции пришлось бы с болью.
И да, в RegExp могут не только лишь все. Мало кто может.
+2
for(int c = 0; c < 2; ++c)
{
if(c)
{
// do something
}
else
{
// do something else
}
}
Одна из причин необходимости разворачивания циклов.