sygic-custom-url
Version:
437 lines (429 loc) • 14.4 kB
JavaScript
/**
* sygic-custom-url - sygic custom url
* @version v1.0.9
* @author frankkoenigstein
* @link https://github.com/frankkoenigstein/sygic-custom-url#readme
* @license Apache-2.0
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["ticktock"] = factory();
else
root["ticktock"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(__webpack_require__(1));
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ACTION_TYPE = {
DRIVE: "drive",
SHOW: "show",
WALK: "walk"
};
exports.ACTION = {
ACTIVATE: "activate",
ADDRESS: "address",
BACK_BUTTON: "back_button",
COORDINATE: "coordinate",
COORDINATEADDR: "coordinateaddr",
DEVICECODE: "deviceCode",
GPSLOG: "gpslog",
LOGIN: "login",
MYSYGIC: "mysygic",
MYSYGICBUY: "mysygicbuy",
MYSYGICPRODUCT: "mysygicproduct",
RESTORE: "restore",
ROUTE: "route",
SETTINGSOVERWRITE: "settingsOverwrite",
TRUCKSETTINGS: "truckSettings",
UPDATE: "update",
URL: "url"
};
exports.TRUCK_ROUTING_TYPE = {
CAMPER: "cmp",
CAR: "car",
TRUCK: "tru",
VAN: "van"
};
exports.SCHEME = "com.sygic.aura";
exports.ACTIONS_SEPARATOR = "&&&";
exports.OPTIONS_SEPARATOR = "|";
exports.TRUCK_SETTINGS_SEPARATOR = "&";
/**
* Service that creates sygic custom urls
*/
var CustomUrlService = /** @class */ (function () {
function CustomUrlService() {
}
/**
* Get url to show address on map
*
* @param {string} country Country or iso code.
* @param {string} city City.
* @param {string} postal Postal code.
* @param {string} street Street.
* @param {string} houseNumber House number.
*
* @returns {string} Url;
*/
CustomUrlService.prototype.showAddress = function (country, city, postal, street, houseNumber) {
return this.genCustomUrl(exports.ACTION.ADDRESS, country, city, postal, street, houseNumber, exports.ACTION_TYPE.SHOW);
};
/**
* Get url to drive to an address
*
* @param {string} country Country or iso code.
* @param {string} city City.
* @param {string} postal Postal code.
* @param {string} street Street.
* @param {string} houseNumber House number.
*
* @returns {string} Url;
*/
CustomUrlService.prototype.driveAddress = function (country, city, postal, street, houseNumber) {
return this.genCustomUrl(exports.ACTION.ADDRESS, country, city, postal, street, houseNumber, exports.ACTION_TYPE.DRIVE);
};
/**
* Get url to walk to an address
*
* @param {string} country Country or iso code.
* @param {string} city City.
* @param {string} postal Postal code.
* @param {string} street Street.
* @param {string} houseNumber House number.
*
* @returns {string} Url;
*/
CustomUrlService.prototype.walkAddress = function (country, city, postal, street, houseNumber) {
return this.genCustomUrl(exports.ACTION.ADDRESS, country, city, postal, street, houseNumber, exports.ACTION_TYPE.WALK);
};
/**
* Show coordinates on map
* @param {number} lon Longitude.
* @param {number} lat Latitude
*
* @returns {string} Url;
*/
CustomUrlService.prototype.showCoordinates = function (lon, lat) {
return this.genCustomUrl(exports.ACTION.COORDINATE, lon, lat, exports.ACTION_TYPE.SHOW);
};
/**
* Drive to coordinates
* @param {number} lon Longitude.
* @param {number} lat Latitude
*
* @returns {string} Url;
*/
CustomUrlService.prototype.driveCoordinates = function (lon, lat) {
return this.genCustomUrl(exports.ACTION.COORDINATE, lon, lat, exports.ACTION_TYPE.DRIVE);
};
/**
* Walk to coordinates
* @param {number} lon Longitude.
* @param {number} lat Latitude
*
* @returns {string} Url;
*/
CustomUrlService.prototype.walkCoordinates = function (lon, lat) {
return this.genCustomUrl(exports.ACTION.COORDINATE, lon, lat, exports.ACTION_TYPE.WALK);
};
/**
* Drive to coordinates with defining address description
* @param {number} lon Longitude.
* @param {number} lat Latitude
* @param {string} desc Description.
*
* @returns {string} Url;
*/
CustomUrlService.prototype.driveCoordinateaddr = function (lon, lat, desc) {
return this.genCustomUrl(exports.ACTION.COORDINATEADDR, lon, lat, desc, exports.ACTION_TYPE.DRIVE);
};
/**
* Loads json itinerary
* @param {string} route sif or json
*
* @returns {string} Url;
*/
CustomUrlService.prototype.route = function (route) {
return this.genCustomUrl(exports.ACTION.ROUTE, route);
};
/**
* opens web page directly in navigation
* @param {string} webpage Page to open.
*
* @returns {string} Url;
*/
CustomUrlService.prototype.url = function (webpage) {
return this.genCustomUrl(exports.ACTION.URL, webpage);
};
/**
* activate license with product code
* @param {string} productCode Product code
*
* @returns {string} Url;
*/
CustomUrlService.prototype.activate = function (productCode) {
return this.genCustomUrl(exports.ACTION.ACTIVATE, productCode);
};
/**
* Start navigation and login with username
*
* @param {string} user User name.
* @param {password} password Password.
*
* @returns {string} Url;
*/
CustomUrlService.prototype.login = function (user, password) {
return this.genCustomUrl(exports.ACTION.LOGIN, user, password);
};
/**
* Update specific map or all maps.
* Note: the call starts downloading maps immediately
* but removes old maps with the application restart.
* This means that at the certain moment both maps
* are present in your filesystem, so your memory limits
* can be hit.
* @param {string} map Map to update or all.
*
* @returns {string} Url;
*/
CustomUrlService.prototype.update = function (map) {
return this.genCustomUrl(exports.ACTION.UPDATE, map);
};
/**
* Show sygic products' shop.
*
* @returns {string} Url;
*/
CustomUrlService.prototype.mysygic = function () {
return this.genCustomUrl(exports.ACTION.MYSYGIC);
};
/**
* Show product detail from shop.
*
* @param productId Product id.
*
* @returns {string} Url;
*/
CustomUrlService.prototype.mysygicproduct = function (productId) {
return this.genCustomUrl(exports.ACTION.MYSYGICPRODUCT, productId);
};
/**
* Buy a license for a product
*
* @param {string} productId Product id.
*
* @returns {string} Url;
*/
CustomUrlService.prototype.mysygicbuy = function (productId) {
return this.genCustomUrl(exports.ACTION.MYSYGICBUY, productId);
};
/**
* Restore all purchases
*
*
* @returns {string} Url;
*/
CustomUrlService.prototype.restore = function () {
return this.genCustomUrl(exports.ACTION.RESTORE);
};
/**
* Play gps nmea log from Res/gpslog
*
* @param {string} nmeafile
* @returns {string} Url;
*/
CustomUrlService.prototype.gpslog = function (nmeafile) {
return this.genCustomUrl(exports.ACTION.GPSLOG, nmeafile);
};
/**
* Control truck settings
* @param {ITruckSettings} truckSettings Truck settings
* @returns {string} Url;
*/
CustomUrlService.prototype.truckSettings = function (truckSettings) {
var options = Object.keys(truckSettings)
.map(function (key) { return key + "=" + truckSettings[key]; })
.join(exports.TRUCK_SETTINGS_SEPARATOR);
return this.genCustomUrl(exports.ACTION.TRUCKSETTINGS, options);
};
/**
* Define back button behavior
* @param {string} applicationIdentifier
* @returns {string} Url;
*/
CustomUrlService.prototype.backButton = function (applicationIdentifier) {
return this.genCustomUrl(exports.ACTION.BACK_BUTTON, applicationIdentifier);
};
/**
* Overwrite app settings.
*
* @param {string} filePath File path of settings.
* @returns {string} Url;
*/
CustomUrlService.prototype.settingsOverwrite = function (filePath) {
return this.genCustomUrl(exports.ACTION.SETTINGSOVERWRITE, encodeURIComponent(filePath));
};
/**
* Get device code
*
* @returns {string} Url;
*/
CustomUrlService.prototype.deviceCode = function () {
return this.genCustomUrl(exports.ACTION.DEVICECODE);
};
CustomUrlService.prototype.multipleActions = function (actions) {
var path = this.prepareActions(actions);
return this.getCustomUrl(path);
};
/**
* Generates a sygic custom url for given action and options.
*
* @param {action} action Url action
* @param {any} args Options for action
*
* @returns {string} Url;
*/
CustomUrlService.prototype.genCustomUrl = function (action) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
var options = this.prepareAction.apply(this, [action].concat(args));
return this.getCustomUrl(options);
};
/**
* Get custom url for path.
* @param {string} path Path of URL.
* @returns {string} Url;
*/
CustomUrlService.prototype.getCustomUrl = function (path) {
return exports.SCHEME + "://" + path;
};
/**
* Prepare multiple actions
*
* @param {{ACTION, any[]}[]} actions Actions to prepare
* @returns {string} Actions prepared for custom url
*/
CustomUrlService.prototype.prepareActions = function (actions) {
var _this = this;
return actions
.map(function (_a) {
var action = _a.action, args = _a.args;
return _this.prepareAction.apply(_this, [action].concat(args));
})
.join(exports.ACTIONS_SEPARATOR);
};
/**
* Prepare action for url;
*
* @param {ACTION} action Url action.
* @param {any[]} args Args for custom url. including action.
* @returns {string} Args prepared for url.
*/
CustomUrlService.prototype.prepareAction = function (action) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
args.unshift(action);
return this.prepareOptions(args);
};
/**
* Prepare options for url;
*
* @param {any[]} args Args for custom url. including action.
* @returns {string} Args prepared for url.
*/
CustomUrlService.prototype.prepareOptions = function (args) {
return args
.filter(function (arg) { return arg !== null && arg !== undefined; })
.join(exports.OPTIONS_SEPARATOR);
};
return CustomUrlService;
}());
exports.CustomUrlService = CustomUrlService;
/***/ })
/******/ ]);
});
//# sourceMappingURL=sygic-custom-url.js.map