'use strict'; /// declare var dialog : any; declare var path : any; declare var fs : any; /** * Determine the greatest common denominator */ function gcd (a : number, b : number) : any { 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 : number, denominator : number) { // from: http://pages.pacificcoast.net/~cazelais/euclid.html let temp : any; let divisor : any; 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 : any) { return /^[0-9]+$/.test(value); } let filmout : FilmOut; class FilmOut { private id : string = 'filmout'; private videoExtensions : string[] = ['.mpg', '.mpeg', '.mov', '.mkv', '.avi', '.mp4', '.gif']; private stillExtensions : string[] = ['.tif', '.tiff', '.png', '.jpg', '.jpeg', '.bmp']; private sequenceExtensions : string[] = ['.png', '.jpg', '.jpeg']; private displays : any[] = []; private state : any = { frame : 0, display : null } constructor () { } 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)); ipcRenderer.on('pre_export', this.onPreExport.bind(this)); ipcRenderer.on('pre_export_progress', this.onPreExportProgress.bind(this)); } onSystem (evt : Event, args : any) { let option : any; for (let display of args.displays) { this.displays.push(display); option = $('