This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Check if there are files to process. | |
| */ | |
| var files = listFiles(get('global.in')) | |
| var config = readJSON(join(get('global.work'), 'config.json')) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * MetaData API | |
| * Copyright (C) 2016 romgrk <romgrk@Romgrk-ARCH> | |
| * | |
| * Distributed under terms of the MIT license. | |
| */ | |
| /** | |
| Usage: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * MaskedInput.js | |
| * Shamelessly copied from: https://github.com/insin/react-maskedinput (MIT License) | |
| * | |
| * Usage: | |
| * <MaskedInput mask='11/11/1111' onChange={value => console.log(value)} value={myValue} /> | |
| */ | |
| import React from 'react'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| window.onerror = function(error, filename, line, col) { | |
| 'use strict'; | |
| var infos = JSON.stringify([].slice.call(arguments)) | |
| var source = document.documentElement.innerHTML | |
| .split('\n') | |
| .slice(line - 5, line + 2) | |
| .join('\n'); | |
| alert(infos + '\n' + source) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Style guide | |
| // Wrong, a function that calls a function is pointless | |
| document.addEventListener('click', function() { | |
| doSomething() | |
| } | |
| // Right, pass the function itself as a callback | |
| document.addEventListener('click', doSomething) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const image = { | |
| name: 'image.jpg', | |
| src: 'blob:http://...' | |
| } | |
| getBase64FromUrl(image.src) | |
| .then(data => fetch(`${window.SERVER_URL}/image`, { // see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch | |
| method: 'POST', | |
| body: objectToFormData({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * multiply.js | |
| * Author: Romain Gregoire, 2017 | |
| */ | |
| var inputFile = Watch.getJobFileName() | |
| var outputFile = 'c:/users/gregoirr/tmp/output.pdf' | |
| var numberOfCopies = 3 // get('numberOfCopies') | |
| var numberOfPages = countPages(inputFile) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var path = get('global.workPath') | |
| var files = listFiles(path + '/') // Be sure the path ends with '/' | |
| log(files.length) | |
| /* | |
| * Helpers | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function svgToPNG(svg, cb) { | |
| var img = document.createElement('img') | |
| var canvas = document.createElement('canvas') | |
| img.onload = function() { | |
| canvas.width = img.width | |
| canvas.height = img.height | |
| canvas.getContext('2d').drawImage(img, 0, 0) | |
| cb(canvas.toDataURL('image/png', 1)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Usage: | |
| * | |
| * var objects = readExcel('c:/users/gregoirr/tmp/file.xlsx') | |
| * var json = JSON.stringify(objects) | |
| */ | |
| function readExcel(path, sheetNumber) { |