Used L.GeometryUtil from Leaflet Draw
This file contains 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 | |
//sendMail("[email protected]", "test", "test", "test", "<body>test</body>"); | |
//Or embed <img src=https://script.google.com/macros/s/macro_id_here/exec?id=someId style = "height: 1px; width: 1px; display: none !important;"> | |
//in email html body | |
var SCRIPT_LINK = "https://script.google.com/macros/s/macro_id_here/exec";//macro url | |
var SHEET_ID = "spreadsheet_id_here";//logger spreadsheet id | |
function sendMail(email, subject, plainText, id, html) { | |
var html = html + '<img src=' + SCRIPT_LINK + '?id=' + id + |
This file contains 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
//Keep in mind that Nova Poshta may change tracking API method to require phone number | |
/** | |
* Returns current status of cargo. | |
* | |
* @param {number} invoice Invoice number. | |
* @return {string} cargo status information. | |
* @customfunction | |
*/ | |
function getCargoStatus(invoice) { | |
This file contains 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 getCategory(itemUrl) { | |
var itemID = itemUrl.slice(itemUrl.lastIndexOf('/') + 1); | |
Logger.log(itemID); | |
var parameters = | |
"?callname=GetSingleItem" + | |
"&responseencoding=JSON" + | |
"&appid=" + "YourAppIDHere" + | |
"&siteid=0" + | |
"&version=963" + |
This file contains 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 Main() { | |
var template = DriveApp.getFileById('YOUR_SPREADSHEET_ID'); //template spreadsheet | |
var destination = DriveApp.getFolderById('COPY_DESTINATION_FOLDER_ID'); //the directory to copy the file into | |
var curDate = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "yyyy-MM-dd"); | |
var copyName = template.getName() + ' copy ' + curDate; //the filename that should be applied to the new copy (e.g. "My spreadsheet copy 2019-08-24") | |
copyTemplate(template, copyName, destination); | |
} | |
/** |
This file contains 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
//Script limit is 6 min = 360 sec and folder creation operation lasts for half of a second. | |
//So max folders created in one run is around 360sec * 2 = 720 | |
//To prevent time limit error was used workaround from https://ctrlq.org/code/20016-maximum-execution-time-limit | |
function onOpen(e) { | |
SpreadsheetApp.getUi() | |
.createMenu('Create folders') | |
.addItem('Create in current folder', 'createFolders') | |
.addItem('Create in current folder, starting from row', 'createAtRow') | |
.addItem('Create in root', 'createAtRoot') |
This file contains 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 onOpen() {//adds new menu item to active spreadsheet | |
var sheet = SpreadsheetApp.getActiveSpreadsheet(); | |
var entries = [ | |
{name : "Calculate distance", functionName : "findDistance"}, | |
{name : "Clear distance", functionName : "clearIDs"}]; | |
sheet.addMenu("Distance measure", entries); | |
} | |
function clearIDs() { | |
var sheet = SpreadsheetApp.getActiveSpreadsheet(); |
This file contains 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 extractData(data, startStr, endStr) { | |
// This function extracts text between two strings | |
// i.e. extractData("Good_news,_everyone!", "Good_", ",_Everyone!") will return "News" | |
var startIndex, endIndex, text = 'N/A'; | |
startIndex = data.indexOf(startStr); | |
if(startIndex != -1) { | |
startIndex += startStr.length; | |
text = data.substring(startIndex); |