-
+158
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
$rand = rand(1,100);
if (($rand => 1) && ($rand <= 50)) {
include 'код баннера 1';
}
elseif (($rand => 51) && ($rand <= 80)) {
include 'код баннера 2';
}
else {
include 'код баннера 3';
}
50% - баннер 1, 30% - баннер 2, остальное (20%) - баннер 3.
Хотели сделать "ротацию с весом" для X баннеров :)
SVP,
18 Сентября 2014
-
+143
- 1
- 2
- 3
if (typeof window.$lab === 'undefined') {
document.write('<script type="text/javascript">var $lab = jQuery.noConflict(true);\x3C/script>');
}
потому что eval - зло
P.s. \x3C/script> - такая запись ибо впилено тегом скрипт в head
RedMonkey,
18 Сентября 2014
-
+158
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
if ($qproizv_r->s > 0 && $qpriem_n > 0) {
if ($qproizv_r->s >= $row->Kol) {
$Status = 6;
}
} else {
if ($qpriem_n > 0) {
$Status = 6;
}
}
Так и живем.
Khvorostin,
18 Сентября 2014
-
+82
- 1
Boolean hasRefId = !node.getAttributes().getNamedItem("refid").equals(null);
equals(null)
roman-kashitsyn,
18 Сентября 2014
-
+76
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
function returnUserId() {
if (document.getElementById('userstap') != null ) {
var obj = document.getElementById('userstap');
<% if ((sUserIdForPrint != null) && !sUserIdForPrint.equals("")) {%>
if (obj.options[obj.selectedIndex].value == 0) {
return "<%=sUserIdForPrint%>";
<% } %>
<% if (((sAccGrpUserIdForPrint != null) && !sAccGrpUserIdForPrint.equals("")) && ((sUserIdForPrint != null) && !sUserIdForPrint.equals(""))) {%>
} else if (obj.options[obj.selectedIndex].value == 1 ) {
return "<%=sAccGrpUserIdForPrint%>";
<% } else if ((sAccGrpUserIdForPrint != null) && !sAccGrpUserIdForPrint.equals("")){%>
if (obj.options[obj.selectedIndex].value == 1 ) {
return "<%=sAccGrpUserIdForPrint%>";
<% } %>
<% if (((sAccGrpUserIdForPrint != null) && !sAccGrpUserIdForPrint.equals("")) || ((sUserIdForPrint != null) && !sUserIdForPrint.equals(""))) {%>
} else if (obj.options[obj.selectedIndex].value == 2) {
return "<%=userId%>";
}
<% } else {%>
if (obj.options[obj.selectedIndex].value == 2) {
return "<%=userId%>";
}
<% } %>
} else {
return "<%=userId%>";
}
}
Любите ли вы JSP так, как люблю его я?
codingHorror,
18 Сентября 2014
-
+155
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
<?php
/**
* Get category tree.
*
* @param db $db
* @return array
*/
function getCategoryTree ($db) {
$query = $db->query('SELECT * FROM dle_category ORDER BY posi');
if ($query->num_rows <= 0) {
return FALSE;
}
$categories = $query->fetch_all(MYSQLI_ASSOC);
$tree = array();
foreach ($categories as $cat) {
if ($cat['parentid'] == '0') {
$tree[$cat['id']] = $cat;
}
else {
$tree[$cat['parentid']]['subcategories'][] = $cat;
}
}
return $tree;
}
/**
* Display categories.
* Sorry for my french 'echo'.
*
* @param array $category
*/
function displayCategory ($category) {
$html = '';
foreach ($category as $cat) {
$html .= '<li class="lonely "><a href="/">' . $cat['name'] . '</a>';
if ($cat['subcategories']) {
$html .= '<span class="accordion"></span><ul>';
$html .= displayCategory ($cat['subcategories']);
$html .= '</ul>';
}
$html .= '</li>';
}
return $html;
}
// Getting categories
$categories = getCategoryTree($db);
if ($categories) {
echo displayCategory ($categories);
}
else {
echo '<li>Нету категорий</li>';
}
Мой говно модуль для DLE для отображения дерева категорий в меню.
Почему DLE разработчики не могли это из коробки сделать? И почему там куча говнокода внутри? (на Англ. комментарии потому что привык)
volter9,
17 Сентября 2014
-
+140
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
@foreach (var groupTest in Model.Select(t => t.TestType).Distinct())
{
<div class="form-column form-column2">
<div class="static-height">
<p class="content-subblock-title left upper-text">
<label>
@if (@groupTest.GetEnumDescription().Length < 34)
{
<text> </text>
}
@groupTest.GetEnumDescription()
</label>
</p>
@foreach (var item in Model.Where(t => t.TestType == groupTest).OrderBy(t => t.Order))
{
<div class="donation-row">
<label>@item.TestName</label>
<span class="@item.TestClass blood-test-value-don">
@item.TestValue
</span>
</div>
}
</div>
</div>
}
Я пялюсь на этот кусок вот уже полчаса...
amatenkov,
17 Сентября 2014
-
+135
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
if ((Mathf.Abs(_mouseOverX) > 0.2f || Mathf.Abs(_mouseOverY) > 0.2f))
{
switch (selecetedItemIndex)
{
case -1 :
var a = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
a += angle / 2.0f;
if (a < 0) a = a + 360.0f;
index = (int)(a / angle);
break;
case 0:
var a0 = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
a0 += angle / 2.0f;
if (a0 < 0) a0 = a0 + 360.0f;
index = (int)(a0 / angle);
switch (index)
{
case 5 :
index = 7;
break;
case 6:
index = 7;
break;
case 4 :
index = -1;
break;
case 3:
index = 1;
break;
case 2:
index = 1;
break;
}
break;
case 1:
var a1 = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
a1 += angle / 2.0f;
if (a1 < 0) a1 = a1 + 360.0f;
index = (int)(a1 / angle);
switch (index)
{
case 0 :
index = 0;
break;
case 7:
index = 0;
break;
case 6 :
index = -1;
break;
case 5:
index = -1;
break;
case 4:
index = 3;
break;
case 3:
index = 3;
break;
case 2:
index = 2;
break;
}
break;
case 2:
var a2 = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
a2 += angle / 2.0f;
if (a2 < 0) a2 = a2 + 360.0f;
index = (int)(a2 / angle);
switch (index)
{
case 0: index = 1; break;
case 7: index = 1; break;
case 6: index = -1; break;
case 5: index = 3; break;
case 4: index = 3; break;
}
break;
case 3:
var a3 = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
a3 += angle / 2.0f;
if (a3 < 0) a3 = a3 + 360.0f;
index = (int)(a3 / angle);
switch (index)
Radial menu govnokod style
noshitleft,
17 Сентября 2014
-
+135
- 1
function e(id){ return document.getElementById(id); }
Бредогенерации тред.
3.14159265,
17 Сентября 2014
-
+53
- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 100
// quick render params menu actions
if(pe->buttons()&Qt::LeftButton || pe->buttons()&Qt::RightButton){
//
if(cRenderMenuOpended){//
if((p.x()+p.y())<18){// - -
cRenderMenuOpended=!cRenderMenuOpended;
repaint();
return;
}
else if(p.x()>5 && p.y()>5 && p.x()<145 && p.y()<cRenderMenuHeight){// actions rectangle
//
//sliceModifyMode=true; // show slice plane and can be modified
//useSlicePlane=true; // build geometry with slice plane
if(cViewType==0){// 2D
if(p.x()>10 && p.y()>22 && p.x()<140 && p.y()<38){
// reset zoom
if(c2DZoom1To1){
cPanFor2DX1to1=0;
cPanFor2D=0;
cPanFor2DX=0;
cZoomFor2D=1;
if(cViewType==0 && c2DZoom1To1 && renderLimits){
auto testSizeX=cVieportXSize;
auto testSizeY=cVieportYSize;
BoundaryConditionsOfComposite *cond=NULL;
cond=AbstractContainer::getInstance()->getBoundaryCondition(0);
if(cond->isHeatFlux_multiple()){
cPanFor2D+=15;
testSizeY-=20;
}
if(cond->isHeatFlux_multiple() || cond->isHeatFlux() || cond->isHeatPower() || cond->isConvection() || cond->isInsulated() || cond->isTemperature()){
cPanFor2D+=20;
testSizeY-=25;
}
cond=AbstractContainer::getInstance()->getBoundaryCondition(3);
if(cond->isHeatFlux() || cond->isHeatPower() || cond->isConvection() || cond->isInsulated() || cond->isTemperature()){
testSizeX-=35;
cPanFor2DX1to1+=30;
}
cond=AbstractContainer::getInstance()->getBoundaryCondition(1);
if(cond->isHeatFlux() || cond->isHeatPower() || cond->isConvection() || cond->isInsulated() || cond->isTemperature()){
testSizeX-=35;
}
if(cWidth>cThikness){
cZoomFor2D=(double(testSizeX)-50.0)/(zoomed2DX(width_sub_start)-zoomed2DX(width_sub_end));
}
else{
cZoomFor2D=(double(testSizeY)-50.0)/(zoomed2DY(thickness_sub_start)-zoomed2DY(thickness_sub_end));
}
}
}
else{
cZoomFor2D=1;
cPanFor2D=0;
cPanFor2DX=0;
}
repaint();
return;
}
else if(p.x()>10 && p.y()>42 && p.x()<140 && p.y()<58){
cForbidRenderResultsOverLayers=!cForbidRenderResultsOverLayers;
repaint();
return;
}
else if(p.x()>10 && p.y()>62 && p.x()<140 && p.y()<78){
renderLimits++;
if(renderLimits>1){
renderLimits=0;
}
repaint();
return;
}
else if(p.x()>10 && p.y()>82 && p.x()<140 && p.y()<98){
SLOT_swap2DMode11AndScaled();
return;
}
else if(p.x()>106 && p.y()>92 && p.x()<122 && p.y()<118){
cResTransparency-=0.1;
if(cResTransparency<0){cResTransparency=0;}
repaint();
return;
}
else if(p.x()>124 && p.y()>92 && p.x()<140 && p.y()<118){
cResTransparency+=0.1;
if(cResTransparency>1){cResTransparency=1;}
repaint();
return;
}
}
else{//3D
if(p.x()>10 && p.y()>22 && p.x()<140 && p.y()<38){
slot_swapCoordiantes();
return;
}
else if(p.x()>10 && p.y()>42 && p.x()<140 && p.y()<58){
Магия чисел в построении GUI
Abbath,
17 Сентября 2014