|
1
|
|
|
<h3>Verseny <span> |
|
2
|
|
|
<?php |
|
3
|
|
|
$now = time(); |
|
4
|
|
|
$secToDiff = 0; |
|
5
|
|
|
|
|
6
|
|
|
if ($now < $challenge->startTime): |
|
7
|
|
|
$secToDiff = $challenge->startTime - $now; |
|
8
|
|
|
?> |
|
9
|
|
|
..még nem indult el. Az indulásig hátralévő idő <strong id="challStartTime"><?= Time::secondsToDifference($secToDiff); ?></strong>. |
|
10
|
|
View Code Duplication |
<?php elseif ($now >= $challenge->startTime && $now <= $challenge->endTime): |
|
|
|
|
|
|
11
|
|
|
$secToDiff = $challenge->endTime - $now; |
|
12
|
|
|
?> |
|
13
|
|
|
..folyamatban van. Hátralévő idő <strong id="challStartTime"><?= Time::secondsToDifference($secToDiff); ?></strong>. |
|
14
|
|
|
<?php else: ?> |
|
15
|
|
|
..lezárult. |
|
16
|
|
|
<?php endif; ?> |
|
17
|
|
|
<?php |
|
18
|
|
|
if ($secToDiff > 0) { |
|
19
|
|
|
Yii::app()->clientScript->registerScript('cntr', " |
|
20
|
|
|
$('#challStartTime').countdown({ |
|
21
|
|
|
until: {$secToDiff}, |
|
22
|
|
|
layout: '{mnn}{sep}{snn}', |
|
23
|
|
|
expiryText: '00:00', |
|
24
|
|
|
})"); |
|
25
|
|
|
} |
|
26
|
|
|
?> |
|
27
|
|
|
<?= CHtml::link('Részletek', ['challenge/details', 'id'=>$challenge->id]); ?> |
|
28
|
|
|
</span></h3> |
|
29
|
|
|
|
|
30
|
|
|
<!--p>[Az a klub győz, aki több <strong> pontot </strong> szerez a verseny alatt.<br> |
|
31
|
|
|
A győztes klub zsákmányát egyenlően szétosztjuk a tagjai közt a verseny lezárása után. |
|
32
|
|
|
A vesztes klub által zsákmányolt pénz a horgásszövetségé lesz.]</p--> |
|
33
|
|
|
<div class="duel-grid ui-grid-a"> |
|
34
|
|
|
<div class="ui-block-a"> |
|
35
|
|
|
<ul class="missions" data-role="listview" data-inset="true"> |
|
36
|
|
|
<li class="c" data-role="list-divider"><?= $challenge->caller==$club->id ? $challenge->name_caller : CHtml::link($challenge->name_caller, ['/club/details', 'id'=>$challenge->caller]); ?></li> |
|
37
|
|
|
<li id="details-caller" class="r"> |
|
38
|
|
|
<p><?= $challenge->point_caller ?> pont</p> |
|
39
|
|
|
<p><?= $challenge->cnt_won_caller ?>x győzött</p> |
|
40
|
|
|
<p><?= $challenge->loot_caller ?>$ zsákmány</p> |
|
41
|
|
|
</li> |
|
42
|
|
|
</ul> |
|
43
|
|
|
</div> |
|
44
|
|
|
|
|
45
|
|
|
<div class="ui-block-b"> |
|
46
|
|
|
<ul class="missions" data-role="listview" data-inset="true"> |
|
47
|
|
|
<li class="c" data-role="list-divider"><?= $challenge->opponent==$club->id ? $challenge->name_opponent : CHtml::link($challenge->name_opponent, ['/club/details', 'id'=>$challenge->opponent]); ?></li> |
|
48
|
|
|
<li id="details-opponent"> |
|
49
|
|
|
<p><?= $challenge->point_opponent ?> pont</p> |
|
50
|
|
|
<p><?= $challenge->cnt_won_opponent ?>x győzött</p> |
|
51
|
|
|
<p><?= $challenge->loot_opponent ?>$ zsákmány</p> |
|
52
|
|
|
</li> |
|
53
|
|
|
</ul> |
|
54
|
|
|
</div> |
|
55
|
|
|
<div class="spr vs"></div> |
|
56
|
|
|
</div> |
|
57
|
|
|
|
|
58
|
|
|
<?php |
|
59
|
|
View Code Duplication |
if ($now >= $challenge->startTime && $now <= $challenge->endTime) { |
|
|
|
|
|
|
60
|
|
|
$ajax = CHtml::ajax(array( |
|
61
|
|
|
'url' => Yii::app()->createUrl('ajax/test', ['id'=>$challenge->id]), |
|
62
|
|
|
'dataType' => 'html', |
|
63
|
|
|
'type' => 'get', |
|
64
|
|
|
'success' => 'function(result) { |
|
65
|
|
|
var details = result.split("|"); |
|
66
|
|
|
$("#details-caller").html(details[0]); |
|
67
|
|
|
$("#details-opponent").html(details[1]); |
|
68
|
|
|
}' |
|
69
|
|
|
) // ajax |
|
70
|
|
|
); // script |
|
71
|
|
|
|
|
72
|
|
|
Yii::app()->clientScript->registerScript('updateChallengeDetails', " |
|
73
|
|
|
timeout = 5 * 1000; |
|
74
|
|
|
function refresh() { |
|
75
|
|
|
$ajax |
|
76
|
|
|
} |
|
77
|
|
|
window.setInterval('refresh()', timeout);", CClientScript::POS_END); |
|
78
|
|
|
} |
|
79
|
|
|
?> |
|
80
|
|
|
|
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.