Загрузка категорий на этапе формирования страницы, без AJAX
This commit is contained in:
parent
c1588c2c4f
commit
a3fc9c73e0
|
|
@ -68,6 +68,11 @@ class IndexController extends Controller
|
|||
self::addVar('pointLat', 0);
|
||||
self::addVar('pointLng', 0);
|
||||
|
||||
$categoryArray = array();
|
||||
foreach ($category as $cat) {
|
||||
$categoryArray[] = $cat->getValues();
|
||||
}
|
||||
|
||||
$og = array();
|
||||
if (isset($_GET['point']) && $_GET['point'] && is_numeric($_GET['point']))
|
||||
{
|
||||
|
|
@ -95,6 +100,7 @@ class IndexController extends Controller
|
|||
|
||||
self::render('indexTemplate.php', array(
|
||||
'categories' => $category,
|
||||
'categoryArray' => $categoryArray,
|
||||
'user' => App::$user,
|
||||
'routes' => $routes,
|
||||
'favorites' => $favorites,
|
||||
|
|
|
|||
|
|
@ -117,6 +117,11 @@
|
|||
<area onclick="hideBigLogo();" shape="rect" coords="0,0,40,40" style="cursor: pointer" title="Спрятать надолго"/>
|
||||
<area href="https://vk.com/wikipoints" shape="rect" coords="40,0,230,40" title="Посетить группу в VK - это интересно и полезно!" target="_blank"/>
|
||||
</map>
|
||||
<?php if (isset($categoryArray)): ?>
|
||||
<script type="text/javascript">
|
||||
var categoryArray = '<?= json_encode($categoryArray)?>';
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
if ($.cookie('doNotShowVKgroup')) {
|
||||
|
|
|
|||
|
|
@ -184,23 +184,17 @@ function showRandomPoint()
|
|||
*/
|
||||
function initCategories()
|
||||
{
|
||||
$.ajax({
|
||||
url: "/json/categories/",
|
||||
success: function (data) {
|
||||
for (var k in data) {
|
||||
categories[data[k]['id']] = L.icon({
|
||||
iconUrl: data[k]['icon'],
|
||||
iconSize: [32, 37],
|
||||
iconAnchor: [16, 37],
|
||||
popupAnchor: [0, 1]
|
||||
});
|
||||
}
|
||||
data = JSON.parse(categoryArray);
|
||||
for (var k in data) {
|
||||
categories[data[k]['id']] = L.icon({
|
||||
iconUrl: data[k]['icon'],
|
||||
iconSize: [32, 37],
|
||||
iconAnchor: [16, 37],
|
||||
popupAnchor: [0, 1]
|
||||
});
|
||||
}
|
||||
|
||||
initPoints();
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
return initPoints();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue