Commit 3cadd2ef authored by Alice Bonafé's avatar Alice Bonafé
Browse files

Issue #62: atualizar balaios e mucuas quando altera a sessão de mocambola.

parent be364d6b
Showing with 16 additions and 0 deletions
+16 -0
......@@ -73,6 +73,9 @@ var $page = {
xhr.open(method, API_URL+endpoint);
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
if (this.session){
xhr.setRequestHeader("token", this.session.token);
}
xhr.send(data);
},
......
......@@ -2,6 +2,7 @@ $(function () {
$page.onChange('balaiosList', function (event) {
menu = $('#nav-balaios-menu');
menu.empty();
var checkActive = false;
for (var i=0; i<$page.balaiosList.length; i++) {
var menuItem = $('<a class="dropdown-item" href="#">');
menuItem.data('smid', $page.balaiosList[i].smid);
......@@ -16,6 +17,12 @@ $(function () {
}
});
menu.append(menuItem);
if ($page.balaio && !checkActive) {
checkActive = $page.balaio.smid == $page.balaiosList[i].smid;
}
}
if ($page.balaio && !checkActive) {
$page.balaio = $page.balaioDefault;
}
});
$page.onChange('mucuasList', function (event) {
......@@ -68,6 +75,12 @@ $(function () {
$page.onChange('context', function (event) {
console.log('new context: '+$page.context);
});
$page.onChange('session', function (event) {
$page.loadBalaiosList();
if ($page.balaio) {
$page.loadMucuasList();
}
});
$("#nav-galaxy").click(function (event) {
$page.context = 'galaxy';
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment