-
Notifications
You must be signed in to change notification settings - Fork 2
/
blockly.js
59 lines (50 loc) · 1.78 KB
/
blockly.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use strict';
/*global goog:true */
/*global Blockly:true */
/*global main:true */
/*global document:true */
if (typeof goog !== 'undefined') {
goog.provide('Blockly.JavaScript.Sendto');
goog.require('Blockly.JavaScript');
}
Blockly.Words['google-spreadsheet_anyInstance'] = { en: 'all instances', de: 'allen Instanzen' };
/* eslint-disable @typescript-eslint/no-unused-vars */
function getInstances(withAny = true) {
var options = [];
if (withAny) {
options.push([Blockly.Translate('google-spreadsheet_anyInstance'), '']);
}
if (typeof main !== 'undefined' && main.instances) {
for (var i = 0; i < main.instances.length; i++) {
var m = main.instances[i].match(/^system.adapter.google-spreadsheet.(\d+)$/);
if (m) {
var n = parseInt(m[1], 10);
options.push([`google-spreadsheet.${n}`, `.${n}`]);
}
}
}
if (!options.length) {
for (var u = 0; u <= 4; u++) {
options.push([`google-spreadsheet.${u}`, `.${u}`]);
}
}
return options;
}
/* eslint-enable @typescript-eslint/no-unused-vars */
function loadJS(filename) {
console.log(`Loading ${filename}`);
const scriptTag = document.createElement('script');
try {
scriptTag.src = filename;
document.body.appendChild(scriptTag);
} catch (e) {
console.error(`Cannot load ${filename}: ${e}`);
}
}
loadJS('../google-spreadsheet/blocks/append.js');
loadJS('../google-spreadsheet/blocks/deleteRows.js');
loadJS('../google-spreadsheet/blocks/createSheet.js');
loadJS('../google-spreadsheet/blocks/deleteSheet.js');
loadJS('../google-spreadsheet/blocks/duplicateSheet.js');
loadJS('../google-spreadsheet/blocks/readCell.js');
loadJS('../google-spreadsheet/blocks/writeCell.js');