Created
August 31, 2020 18:56
-
-
Save sillvva/9627e4db049b6968cc68d73d5d4ff0d2 to your computer and use it in GitHub Desktop.
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
name: AL_Logsheet | |
description: '' | |
host: EXCEL | |
api_set: {} | |
script: | |
content: >- | |
/** @CustomFunction */ | |
function AddingMagicItems(PreviousItems: string, NewItems: string): string { | |
try { | |
if (NewItems.trim().length == 0) return PreviousItems; | |
var merged = PreviousItems+","+NewItems; | |
var mergedSplit = merged.split(","); | |
return mergedSplit.map(function(el) { return el.trim(); }).filter(function(el) { return el.length > 0; }).join(","); | |
} | |
catch(err) { | |
console.log(err); | |
return ""; | |
} | |
} | |
/** @CustomFunction */ | |
function TradingMagicItems(PreviousItems: string, OldItem: string, NewItem: | |
string): string { | |
try { | |
if (OldItem.trim().length == 0 && NewItem.trim().length == 0) return PreviousItems; | |
var merged = PreviousItems; | |
var mergedSplit = merged.split(",") | |
.map(function (el) { return el.trim(); }); | |
mergedSplit.splice(mergedSplit.indexOf(OldItem.trim()), 1); | |
mergedSplit.push(NewItem.trim()); | |
return mergedSplit | |
.filter(function (el) { return el.length > 0; }) | |
.join(","); | |
} | |
catch (err) { | |
console.log(err); | |
return ""; | |
} | |
} | |
/** @CustomFunction */ | |
function ConsolidateMagicItems(Items: string): string { | |
try { | |
var splitValue = Items.split(","); | |
splitValue = splitValue.map(function (v) { return v.trim(); }); | |
var i = 0; | |
while (i < splitValue.length) { | |
var val = splitValue[i]; | |
var cnt = splitValue.filter(function (v) { return v === val; }).length; | |
if (cnt > 1) { | |
splitValue[i] = cnt + "x " + val; | |
splitValue = splitValue.filter(function (v) { return v !== val; }); | |
} | |
i++; | |
} | |
return splitValue.join(" | "); | |
} | |
catch (err) { | |
return Items; | |
} | |
} | |
language: typescript | |
libraries: | | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
@types/office-js | |
[email protected]/dist/css/fabric.min.css | |
[email protected]/dist/css/fabric.components.min.css | |
[email protected]/client/core.min.js | |
@types/core-js | |
[email protected] | |
@types/[email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment