Greasy Fork is available in English.

APIHelper

API Helper

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @require https://greasyfork.org/scripts/389117-apihelper/code/APIHelper.js?version=736468

Tác giả
Anton Shevchuk
Đánh giá
0 0 0
Phiên bản
0.4.1
Đã tạo
Đã cập nhật
Giấy phép
MIT
Áp dụng cho

Mô tả của tác giả

WME API Helper

Require Script

// @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();
})();

This library will run once for all scripts!

Console output

It works with WazeWrap too!

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 – 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);
  APIHelper.addStyle(
    '#uniq-id div { background-color: #123; }' +
    ''
  );

  $(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