Namespace registration helpers

This commit is contained in:
lilia 2014-11-13 15:38:09 -08:00
parent 28290477f4
commit 5a0e199fc5
3 changed files with 23 additions and 20 deletions

View file

@ -35,21 +35,24 @@
// Random shared utilities that are used only by chromium things
function registrationDone() {
localStorage.setItem("chromiumRegistrationDone", "");
chrome.runtime.sendMessage('registration_done');
window.location = '/index.html';
}
window.textsecure = window.textsecure || {};
window.textsecure.registration = {
done: function () {
localStorage.setItem("chromiumRegistrationDone", "");
chrome.runtime.sendMessage('registration_done');
window.location = '/index.html';
},
function isRegistrationDone() {
return localStorage.getItem("chromiumRegistrationDone") !== null;
}
isDone: function () {
return localStorage.getItem("chromiumRegistrationDone") !== null;
},
function addRegistrationListener(callback) {
chrome.runtime.onMessage.addListener(function(message) {
if (message === 'registration_done') {
callback();
}
});
}
addListener: function (callback) {
chrome.runtime.onMessage.addListener(function(message) {
if (message === 'registration_done') {
callback();
}
});
}
};
}());