1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-10-23 02:55:48 +00:00
TiddlyWiki5/core/modules/startup/syncer-browser.js
2014-05-05 14:41:46 +01:00

37 lines
859 B
JavaScript

/*\
title: $:/core/modules/startup/syncer-browser.js
type: application/javascript
module-type: startup
Startup handling
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
// Export name and synchronous status
exports.name = "syncer-browser";
exports.platforms = ["browser"];
exports.after = ["rootwidget"];
exports.synchronous = true;
exports.startup = function() {
// Set up the syncer object
$tw.syncer = new $tw.Syncer({wiki: $tw.wiki});
// Listen out for login/logout/refresh events in the browser
$tw.rootWidget.addEventListener("tw-login",function() {
$tw.syncer.handleLoginEvent();
});
$tw.rootWidget.addEventListener("tw-logout",function() {
$tw.syncer.handleLogoutEvent();
});
$tw.rootWidget.addEventListener("tw-server-refresh",function() {
$tw.syncer.handleRefreshEvent();
});
};
})();