2015-08-12 14:39:02 -07:00
|
|
|
|
(function () {
|
|
|
|
|
|
|
|
|
|
function refreshSyncStatus(page) {
|
|
|
|
|
|
|
|
|
|
require(['localsync'], function () {
|
|
|
|
|
|
|
|
|
|
if (LocalSync.isSupported()) {
|
|
|
|
|
|
|
|
|
|
var status = LocalSync.getSyncStatus();
|
|
|
|
|
|
|
|
|
|
page.querySelector('.labelSyncStatus').innerHTML = Globalize.translate('LabelLocalSyncStatusValue', status);
|
|
|
|
|
page.querySelector('.syncSpinner').active = status == "Active";
|
|
|
|
|
|
2015-09-23 19:31:40 -07:00
|
|
|
|
if (status == "Active") {
|
|
|
|
|
page.querySelector('.btnSyncNow').classList.add('hide');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
page.querySelector('.btnSyncNow').classList.remove('hide');
|
|
|
|
|
}
|
2015-08-12 14:39:02 -07:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function syncNow(page) {
|
|
|
|
|
|
|
|
|
|
require(['localsync'], function () {
|
|
|
|
|
|
2015-09-21 18:05:33 -07:00
|
|
|
|
LocalSync.sync();
|
2015-08-12 14:39:02 -07:00
|
|
|
|
Dashboard.alert(Globalize.translate('MessageSyncStarted'));
|
|
|
|
|
refreshSyncStatus(page);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var interval;
|
|
|
|
|
|
2015-09-01 07:01:59 -07:00
|
|
|
|
$(document).on('pageinit', "#mySyncActivityPage", function () {
|
2015-08-12 14:39:02 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('.btnSyncNow', page).on('click', function () {
|
|
|
|
|
syncNow(page);
|
|
|
|
|
});
|
|
|
|
|
|
2015-10-01 23:14:04 -07:00
|
|
|
|
require(['localsync'], function () {
|
|
|
|
|
|
|
|
|
|
if (LocalSync.isSupported()) {
|
|
|
|
|
|
|
|
|
|
page.querySelector('.localSyncStatus').classList.remove('hide');
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
page.querySelector('.localSyncStatus').classList.add('hide');
|
|
|
|
|
page.querySelector('.syncSpinner').active = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}).on('pagebeforeshow', "#mySyncActivityPage", function () {
|
2015-08-12 14:39:02 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
refreshSyncStatus(page);
|
|
|
|
|
|
|
|
|
|
interval = setInterval(function () {
|
|
|
|
|
refreshSyncStatus(page);
|
|
|
|
|
}, 5000);
|
|
|
|
|
|
|
|
|
|
}).on('pagebeforehide', "#mySyncActivityPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
page.querySelector('.syncSpinner').active = false;
|
|
|
|
|
|
|
|
|
|
if (interval) {
|
|
|
|
|
clearInterval(interval);
|
|
|
|
|
interval = null;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})();
|