[Scripts] APIHelper
APIHelper - simple library for scripts developers.
When you need it most?
For replace code similar to follows:
With simple construction:
It works with WazeWrap too
If you use MutationObserver in your code – please, remove it ASAP!
Of cause, you can use native event selectionchanged to replace it, or my library:
This library will run once for all scripts!
Events:
When you need it most?
For replace code similar to follows:
Code: Select all
boostrap(tries = 1) {
// ...
setTimeout(() => bootstrap(++tries), 500)
// ...
}
Code: Select all
// Initialization
APIHelper.bootstrap();
// Event handler
$(document)
.on('ready.apihelper', function () {
console.info('@ready');
// Your code here
// ...
});
If you use MutationObserver in your code – please, remove it ASAP!
Of cause, you can use native event selectionchanged to replace it, or my library:
Code: Select all
$(document)
.on('node.apihelper', (e, el) => {
console.info('@node', el);
})
.on('segment.apihelper', (e, el) => {
console.info('@segment', el);
})
.on('landmark.apihelper', (e, el) => {
console.info('@landmark', el);
})
.on('landmark-collection.apihelper', (e, el) => {
console.info('@landmark-collection', el)
});
Events:
- ready.apihelper – on document, when all ready for usage
- node.apihelper – on document, when chosen some node for edit
- segment.apihelper – on document, when chosen some segment for edit
- landmark.apihelper – on document, when chosen some place for edit
- landmark-collection.apihelper – on document, when chosen more than one place
- APIHelper.bootstrap() — initialization of the helper, for setup event triggers
- APIHelper.addStyle(style) – append CSS style to the page
- APIHelper.addTranslation(uid, data) – add translation data to I18n object
- APIHelper.getVenues(except = []) – return Array of venues, except some categories
- APIHelper.getSegments(except = []) – return Array of segments, except some road types
- APIHelper.getSelectedVenues() – return Array of the selected venues, which you can edit
- APIHelper.getSelectedSegments() – return Array of the selected segments, which you can edit
- APIHelper.getSelectedNode() – return Model of the selected node, which you can edit, or null