Skip to content

romgrk/ol-resources

Repository files navigation

ol-resources

This repository is a compilation of scripts and resources for OL related stuff.

Workflow:

COTG:

  • cotg.polyfill.js allows you to test COTG's Photo, Signature and Annotations widgets directly form the browser. It also emulates savestate and restorestate using localStorage.
  • cotg.extension.js contains a number of useful functions documented below
  • cotg.onerror.js is a script to display javascript errors as alert in COTG
  • cotg.bundle.js contains all of the above in a single file. Drop it in your template and reap the benefits without more effort.

OL-template files:

The examples folder also contains a number of other resources.

rest.js

Usage:

var api = new RestAPI(
  'user',                 /* required */
  'password',             /* required */
  'http://localhost:9340' /* optionnal */
)

The API is synchronous in the workflow:

var version = api.files.serviceVersion()

And is Promised based in the browser:

api.files.serviceVersion()
  .then(function(version) { /* ... */ })

Advanced examples can be found here:

Live demo here

cotg.extension.js

The functions provided by this file are Promise based.

cotg.getSignature(width, height) triggers the signature widget and resolves to a SVG signature data. E.g.

cotg.getSignature(500, 200)
  .then(function(svg) {
    document.querySelector('img').src = 'data:image/xml+svg,' + svg })

cotg.getPicture(options) triggers the camera widget and resolves to an image URI. E.g.

cotg.getPicture({ width: 100, height: 100, quality: 50 })
  .then(function(uri) { document.querySelector('img').src = uri })

cotg.getDate(date) triggers the date widget and resolves to a date. E.g.

cotg.getDate({ width: 100, height: 100, quality: 50 })
  .then(function(date) { /* ... */ })

cotg.readFile(path) reads a file on the device and resolves to the file content.

cotg.writeFile(path, content) writes a file on the device and resolves when done.

jscript.js

About

Functions & examples for OL related stuff

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published