'use strict'; /** * Determine the greatest common denominator */ function gcd(a, b) { if (b === 0) return a; return gcd(b, a % b); } /** * Reduce a numerator and denominator to it's smallest, integer ratio using Euclid's Algorithm */ function reduceRatio(numerator, denominator) { // from: http://pages.pacificcoast.net/~cazelais/euclid.html let temp; let divisor; if (!isInteger(numerator) || !isInteger(denominator)) return '? : ?'; if (numerator === denominator) return '1 : 1'; // make sure numerator is always the larger number if (+numerator < +denominator) { temp = numerator; numerator = denominator; denominator = temp; } divisor = gcd(+numerator, +denominator); return 'undefined' === typeof temp ? (numerator / divisor) + ' : ' + (denominator / divisor) : (denominator / divisor) + ' : ' + (numerator / divisor); } /** * Determine whether a value is an integer (ie. only numbers) */ function isInteger(value) { return /^[0-9]+$/.test(value); } let filmout; class FilmOut { constructor() { this.id = 'filmout'; this.extensions = ['.mpg', '.mpeg', '.mov', '.mkv', '.avi', '.mp4', '.gif', '.tif', '.tiff', '.png', '.jpg', '.jpeg', '.bmp']; this.displays = []; this.state = { frame: 0, display: null }; } init() { this.listen(); } listen() { ipcRenderer.on(this.id, this.onFilmout.bind(this)); ipcRenderer.on('system', this.onSystem.bind(this)); ipcRenderer.on('preview_frame', this.onFrame.bind(this)); } onSystem(evt, args) { let option; for (let display of args.displays) { this.displays.push(display); option = $('