APIHelper

API Helper

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://greasyfork.org/scripts/389117-apihelper/code/APIHelper.js?version=733775

Author
Anton Shevchuk
Ratings
0 0 0
Version
0.4.1
Created
Updated
License
MIT
Applies to

Author's Description

WME API Helper

Require Script

// @require https://greasyfork.org/scripts/24851-wazewrap/code/WazeWrap.js
// @require https://greasyfork.org/scripts/389117-apihelper/code/APIHelper.js?version=XXX

See last available version on the GreasyFork homepage

Initialisation of the API Helper

For initial helper use method APIHelper.bootstrap():

(function () {
  'use strict';
  APIHelper.bootstrap();
})();

Methods

  • 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

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.apihelper – on document, when chosen more than one place

Example

(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);

  $(document)
      .on('ready.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)
      });
})();

Links

Author homepage: http://anton.shevchuk.name/

Script homepage: https://github.com/AntonShevchuk/wme-api-helper

GreasyFork: https://greasyfork.org/uk/scripts/389117-apihelper