https://github.com/antonshevchuk/wme-bootstrap
Bootstrap library for custom WME scripts
https://github.com/antonshevchuk/wme-bootstrap
greasyfork waze wme-scripts
Last synced: 3 months ago
JSON representation
Bootstrap library for custom WME scripts
- Host: GitHub
- URL: https://github.com/antonshevchuk/wme-bootstrap
- Owner: AntonShevchuk
- License: other
- Created: 2022-08-25T07:51:19.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-12T08:12:56.000Z (almost 2 years ago)
- Last Synced: 2025-01-22T05:25:00.566Z (5 months ago)
- Topics: greasyfork, waze, wme-scripts
- Language: JavaScript
- Homepage:
- Size: 35.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WME Bootstrap
This is a small Boostrap library for checking WME loading and providing useful events, which you can use for your scripts.**For what?**
You can meet the realization of checking loading in the many scripts; it looks like this:
```javascript
// 👎
function init() {
/* checking */
setTimeout(init, 200)
}
```No need more this way; look at the following code:
```javascript
// 👍
$(document).on('bootstrap.wme', () => { /* your code here */ } )
```So I think it's clear.
**Need more?**
So, it is not all. This script trigger [more events](#events) for common events in the WME where you can manipulate the [arguments](#arguments).
## Require Script
```javascript
// @require https://greasyfork.org/scripts/450160-wme-bootstrap/code/WME-Bootstrap.js
```## Events
All following events are triggered on the `document`
* `bootstrap.wme` – when all WME-objects are ready for usage
* `none.wme` – when nothing chosen
* `node.wme` – when chosen node for edit
* `nodes.wme` – when chosen more than one node (I'm not sure how it is possible)
* `segment.wme` – when chosen segment for edit
* `segments.wme` – when chosen more than one segment
* `venue.wme` – when chosen place or point for edit
* `venues.wme` – when chosen more than one place or point
* `point.wme` – when chosen point place for edit
* `place.wme` – when chosen place for edit
* `residential.wme` – when chosen residential place for edit## Arguments
* `event` – [`jQuery.Event`](https://api.jquery.com/category/events/event-object/)
* `element` – [`HTMLElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) of the sidebar panel
* `model` – `W.model`
* `models` – array of `W.model`## Usage
```javascript
(function () {
'use strict'$(document)
.on('bootstrap.wme', function () {
console.info('ready')
})
.on('none.wme', (e) => {
console.info('none')
})
.on('node.wme', (event, element, model) => {
console.info('node', model)
console.info('sidebar', element)
})
.on('nodes.wme', (event, element, models) => {
console.info('nodes', models)
})
.on('segment.wme', (event, element, model) => {
console.info('segment', model)
console.info('sidebar', element)
})
.on('segments.wme', (event, element, models) => {
console.info('segments', models)
})
.on('venue.wme', (event, element, model) => {
console.info('venue', model)
})
.on('venues.wme', (event, element, model) => {
console.info('venues', models)
})
.on('point.wme', (event, element, model) => {
console.info('point', model)
})
.on('place.wme', (event, element, model) => {
console.info('place', model)
})
.on('residential.wme', (event, element, model) => {
console.info('residential', model)
})
})();
```## Links
Author homepage: http://anton.shevchuk.name/
Script homepage: https://github.com/AntonShevchuk/wme-bootstrap
GreasyFork: https://greasyfork.org/en/scripts/450160-wme-bootstrap