|
1
|
|
|
<?php |
|
2
|
|
|
$now = time(); |
|
3
|
|
|
if ($now < $challenge->startTime): |
|
4
|
|
|
?> |
|
5
|
|
|
<p>A verseny még nem indult el. Az indulásig hátralévő idő <strong><?= Time::secondsToDifference($challenge->startTime - $now); ?></strong>. |
|
6
|
|
View Code Duplication |
<?php elseif ($now >= $challenge->startTime && $now <= $challenge->endTime): ?> |
|
|
|
|
|
|
7
|
|
|
<p>A verseny folyamatban van. Hátralévő idő <strong><?= Time::secondsToDifference($challenge->endTime - $now); ?></strong>. |
|
8
|
|
|
<?php else: ?> |
|
9
|
|
|
<p>A verseny lezárult. |
|
10
|
|
|
|
|
11
|
|
|
<?php if ($challenge->winner): ?> |
|
12
|
|
|
<?php if ($challenge->winner < 3): ?> |
|
13
|
|
|
A győztes csapat: <strong><?= $challenge->winner==1 ? $challenge->name_caller : $challenge->name_opponent; ?></strong> |
|
14
|
|
|
<?php else: ?> |
|
15
|
|
|
Az eredmény: döntetlen. |
|
16
|
|
|
<?php endif;?> |
|
17
|
|
|
<?php else: ?> |
|
18
|
|
|
A kiértékelés pillanatokon belül megtörténik. |
|
19
|
|
|
<?php endif;?> |
|
20
|
|
|
<?php endif; ?> |
|
21
|
|
|
</p> |
|
22
|
|
|
|
|
23
|
|
|
<div class="duel-grid ui-grid-a"> |
|
24
|
|
|
<div class="ui-block-a"> |
|
25
|
|
|
<ul class="missions" data-role="listview" data-inset="true"> |
|
26
|
|
|
<li class="c" data-role="list-divider"><?= CHtml::link($challenge->name_caller, ['/club/details', 'id'=>$challenge->caller]); ?></li> |
|
27
|
|
|
<li id="details-caller" class="r"> |
|
28
|
|
|
<p><?= $challenge->point_caller ?> pont</p> |
|
29
|
|
|
<p><?= $challenge->cnt_won_caller ?>x győzött</p> |
|
30
|
|
|
<p><?= $challenge->loot_caller ?>$ zsákmány</p> |
|
31
|
|
|
</li> |
|
32
|
|
|
</ul> |
|
33
|
|
|
</div> |
|
34
|
|
|
|
|
35
|
|
|
<div class="ui-block-b"> |
|
36
|
|
|
<ul class="missions" data-role="listview" data-inset="true"> |
|
37
|
|
|
<li class="c" data-role="list-divider"><?= CHtml::link($challenge->name_opponent, ['/club/details', 'id'=>$challenge->opponent]); ?></li> |
|
38
|
|
|
<li id="details-opponent"> |
|
39
|
|
|
<p><?= $challenge->point_opponent ?> pont</p> |
|
40
|
|
|
<p><?= $challenge->cnt_won_opponent ?>x győzött</p> |
|
41
|
|
|
<p><?= $challenge->loot_opponent ?>$ zsákmány</p> |
|
42
|
|
|
</li> |
|
43
|
|
|
</ul> |
|
44
|
|
|
</div> |
|
45
|
|
|
<div class="spr vs"></div> |
|
46
|
|
|
</div> |
|
47
|
|
|
|
|
48
|
|
|
<?php |
|
49
|
|
View Code Duplication |
if ($now >= $challenge->startTime && $now <= $challenge->endTime) { |
|
|
|
|
|
|
50
|
|
|
$ajax = CHtml::ajax(array( |
|
51
|
|
|
'url' => Yii::app()->createUrl('ajax/test', ['id'=>$challenge->id]), |
|
52
|
|
|
'dataType' => 'html', |
|
53
|
|
|
'type' => 'get', |
|
54
|
|
|
'success' => 'function(result) { |
|
55
|
|
|
var details = result.split("|"); |
|
56
|
|
|
$("#details-caller").html(details[0]); |
|
57
|
|
|
$("#details-opponent").html(details[1]); |
|
58
|
|
|
}' |
|
59
|
|
|
) // ajax |
|
60
|
|
|
); // script |
|
61
|
|
|
|
|
62
|
|
|
Yii::app()->clientScript->registerScript('updateChallengeDetails', " |
|
63
|
|
|
timeout = 5 * 1000; |
|
64
|
|
|
function refresh() { |
|
65
|
|
|
$ajax |
|
66
|
|
|
} |
|
67
|
|
|
window.setInterval('refresh()', timeout);", |
|
68
|
|
|
CClientScript::POS_END |
|
69
|
|
|
); |
|
70
|
|
|
} |
|
71
|
|
|
?> |
|
72
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.