function COUNTUNIQWORDS(cell) {
var result = []
var words = String(cell).split(" ");
var wordsCount = words.reduce(function (acc, w) {
if(acc[w]) {
acc[w] += 1
} else {
acc[w] = 1;
}
return acc;
}, {});
for (var w in wordsCount) result.push('Cлово "'+ w +'" встречается '+ wordsCount[w] + ' раз');
return result
}
let template = `
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
</head>
<body>
<h1>Результат: {{code}}</h1>
<div class="table-responsive">
<table class="table table-striped">
<thead class="thead-dark">
<tr>
{{#each names}}
<th scope="col">{{this}}</th>
{{/each}}
</tr>
</thead>
<tbody>
{{#each response}}
<tr>
<td>{{userId}}</td>
<td>{{id}}</td>
<td>{{title}}</td>
<td>{{body}}</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</body>
</html>`;
var data = pm.response.json();
var name = data.map(x=> Object.keys(x));
pm.visualizer.set(template,{
names: [...new Set(name)][0],
code: pm.response.code,
response: data
});
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Моя навигация')
.addItem('Ячейка A555', 'menuItem1')
.addSeparator()
.addSubMenu(ui.createMenu('Важно')
.addItem('Ячейка H555', 'menuItem2'))
.addToUi();
}
function menuItem1() {
SpreadsheetApp.getUi()
SpreadsheetApp.getActiveSheet().getRange('A555').activate();
}
function menuItem2() {
SpreadsheetApp.getUi()
SpreadsheetApp.getActiveSheet().getRange('h555').activate();
}
var list = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var counter = 6;
var logics = {
"F10": "=IFERROR(VLOOKUP(B10;'Эта неделя'!$B$3:$E$120;3;FALSE);0)",
"G10": "=IFERROR(VLOOKUP(B10;'Эта неделя'!$B$3:$E$120;4;FALSE);0)",
"H10": "=IF(C10>=10;F10-70;(F10+G10)-70)+J10",
"I10": "=H10+J10"
}
for (var key in logics) {
formulaPaste (list, counter, key, logics[key]);
counter++;
}
function formulaPaste (list, i, cell, formula){
list.getRange(cell).setFormula(formula);
var row = list.getLastRow();
var range = list.getRange(10, i, row-9);
list.getRange(cell).copyTo(range);
}
function MyDate(date){
this.date = new Date(date);
const options = {
year: 'numeric',
month: 'numeric',
day: '2-digit'
}
const locale = 'en'
const f = new Intl.DateTimeFormat(locale, options);
const [{ value: mo },,{ value: da },,{ value: ye }] = f.formatToParts(this.date);
this.formatData = () => console.log(`${ye},${mo},${da}`);
}
let d = new MyDate('Tue Apr 27 2021 00:33:00 GMT+0500 (Екатеринбург, стандартное время)');
d.formatData();