// @require https://greasyfork.org/scripts/389117-apihelper/code/APIHelper.js?version=XXXSee last available version on the GreasyFork homepage
For initial helper use method APIHelper.bootstrap():
(function () {
'use strict';
APIHelper.bootstrap();
})();This library will run once for all scripts!
It works with WazeWrap too!
APIHelper.bootstrap()— initialization of the helper, for setup event triggersAPIHelper.addStyle(style)– append CSS style to the pageAPIHelper.addTranslation(uid, data)– add translation data to I18n objectAPIHelper.getVenues(except = [])– return Array of venues, except some categoriesAPIHelper.getSegments(except = [])– return Array of segments, except some road typesAPIHelper.getSelected()– return Array of the selected models, which you can editAPIHelper.getSelectedVenues()– return Array of the selected venues models, which you can editAPIHelper.getSelectedVenue()– return model of the selected venue, which you can editAPIHelper.getSelectedSegments()– return Array of the selected segments models, which you can editAPIHelper.getSelectedSegments()– return model of the selected segment, which you can editAPIHelper.getSelectedNodes()– return Array of the selected nodes models, which you can edit, or nullAPIHelper.getSelectedNode()– return model of the selected node, which you can edit, or null
init.apihelper– ondocument, when all ready for usagenode.apihelper– ondocument, when chosen some node for editsegment.apihelper– ondocument, when chosen some segment for editlandmark.apihelper– ondocument, when chosen some place for editlandmark-collection.apihelper– ondocument, when chosen more than one place
(function () {
'use strict';
// uniq script name
const NAME = 'Some Script';
// translation structure
const TRANSLATION = {
'en': {
title: 'Title example',
},
'uk': {
title: 'Приклад назви',
},
'ru': {
title: 'Пример названия',
}
};
APIHelper.bootstrap();
APIHelper.addTranslation(NAME, TRANSLATION);
APIHelper.addStyle(
'#uniq-id div { background-color: #123; }' +
''
);
$(document)
.on('init.apihelper', function () {
console.info('@ready');
})
.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)
});
})();Author homepage: http://anton.shevchuk.name/
Script homepage: https://github.com/AntonShevchuk/wme-api-helper
GreasyFork: https://greasyfork.org/uk/scripts/389117-apihelper
