Skip to content

Commit

Permalink
Setup init was completely wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
manierim committed Jun 12, 2019
1 parent 035d088 commit c83205f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 29 deletions.
2 changes: 1 addition & 1 deletion crosslinks-enhancements.meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// @name Crosslinks Enhancements
// @description Adds options to limit cross links detection by drawn items color and to cross links inside a polygon
// @category Misc
// @version 1.0
// @version 1.1
// @author MarcioPG
// @website https://github.com/manierim/crosslinks-enhancements
// @updateURL https://github.com/manierim/crosslinks-enhancements/raw/master/crosslinks-enhancements.meta.js
Expand Down
36 changes: 8 additions & 28 deletions crosslinks-enhancements.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// @name Crosslinks Enhancements
// @description Adds options to limit cross links detection by drawn items color and to cross links inside a polygon
// @category Misc
// @version 1.0
// @version 1.1
// @author MarcioPG
// @website https://github.com/manierim/crosslinks-enhancements
// @updateURL https://github.com/manierim/crosslinks-enhancements/raw/master/crosslinks-enhancements.meta.js
Expand All @@ -17,8 +17,6 @@
// @require https://cdn.rawgit.com/hayeswise/Leaflet.PointInPolygon/v1.0.0/wise-leaflet-pip.js
// ==/UserScript==

// MarcioPG WRAPPER v1.0 START /////////////////////////////////////////////

function wrapper() {

// ensure plugin framework is there, even if iitc is not yet loaded
Expand All @@ -30,39 +28,22 @@ function wrapper() {
var $plugin = window.plugin.crossLinksEnhancements;

//-------------------------------------------------------------
// Init & Setup
// Setup
//-------------------------------------------------------------

$plugin.initDone = false;
$plugin.init = function () {

if ($plugin.initDone) {
return;
}
$plugin.initDone = true;
var setup = function () {

if (window.plugin.crossLinks === undefined) {
console.warn('crossLinks Enhancements: crossLinks plugin not found');
return;
}

$plugin.opts.init();
$plugin.crossLinks.init();
$plugin.ui.init();
$plugin.draw.init();

}

var setup = function () {

if (window.iitcLoaded) {
$plugin.init();
}
else {
window.addHook('iitcLoaded', $plugin.init);
}
window.plugin.crossLinksEnhancements.ui.init();
window.plugin.crossLinksEnhancements.opts.init();
window.plugin.crossLinksEnhancements.crossLinks.init();
window.plugin.crossLinksEnhancements.draw.init();

}
};

//-------------------------------------------------------------
// Storage
Expand Down Expand Up @@ -623,7 +604,6 @@ function wrapper() {

// PLUGIN END //////////////////////////////////////////////////////////


if (!window.bootPlugins) window.bootPlugins = [];
window.bootPlugins.push(setup);
// if IITC has already booted, immediately run the 'setup' function
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@ Point in Polygon function by [hayeswise/Leaflet.PointInPolygon](https://github.c

## Changelog

- 2019-06-13 (version 1.1)
+ Major bugfix in setup logic!
- 2019-06-11 (version 1.0)
+ Initial Release

0 comments on commit c83205f

Please sign in to comment.