-
Notifications
You must be signed in to change notification settings - Fork 0
/
render.js
159 lines (127 loc) · 3.17 KB
/
render.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
const fs = require("fs");
const parser = require("jsdoc3-parser");
let todos = [];
// const scriptPathConfig ="./data/scripts/"
const scriptPathConfig = "./data/sless/"
var Sqrl = require("squirrelly");
var editor;
let scope = {};
let jsparser = esprima.parse;
var typTemplate = `
/**
* {{description}}
* @typedef {{{if(options.fields.length === 0)}}native{{#else}}object{{/if}}} {{name}}
{{each(options.fields)}}
* @property {{{@this.typ}}{{if(@this.array)}}[]{{/if}}} {{@this.name}} {{@this.description}}
{{/each}}
**/
`
var funTemplate = `
/**
* {{description}}
{{each(options.params)}}
* @param {{{@this.typ}}{{if(@this.array)}}[]{{/if}}} {{@this.name}} {{@this.description}}
{{/each}}
{{if(options.returns != undefined)}}
* @returns {{{returns}}{{if(options.array)}}[]{{/if}}}
{{/if}}
*/
exports.fun = function {{name}}({{each(options.params)}}
{{@this.name}}
{{if(@index + 1 < options.params.length)}}, {{/if}}
{{/each}}
) {
}
`
const low = require('lowdb')
const FileSync = require('lowdb/adapters/FileSync')
let db = low(new FileSync('db.json'))
db.defaults({
typ: [],
synonym: [],
synonym_typ: [],
field: [],
fun: [],
count: 0
}).write();
var tables = {
typ: "typ",
synonym: "synonym",
synonym_typ: "synonym_typ",
field: "field",
fun: "fun"
}
let exports = {}
function hideAll() {
$("#main").hide();
$("#code_editor").hide();
$("#query_editor").hide();
$("#type_builder").hide();
$("#type_view").hide();
$("#object_builder").hide();
$("#fun_builder").hide();
$("#calculator").hide();
}
function loadDependency(name) {
return new Promise(function (resolve, reject) {
$.getScript(name, function (data, textStatus, jqxhr) {
if (exports.fun != undefined) {
global[exports.fun.name] = exports.fun;
}
resolve("load!");
});
});
}
$(document).ready(async function () {
fs.readdir(scriptPathConfig, function (err, files) {
var promises = [];
for (let i = 0; i < files.length; i++) {
let file = files[i];
let name = (scriptPathConfig || "") + file
promises.push(loadDependency(name));
}
Promise.all(promises).then(function () {
ready()
}, function (err) {
// error occurred
console.log(err)
});
});
})
function ready() {
myTimer()
hideAll()
addFunction("reloadf", "ORANGERED", "fa-sync");
addFunction("addf", "YELLOWGREEN", "fa-plus");
addFunction("editf", "DARKORCHID", "fa-edit");
addFunction("searchf", "orange", "fa-search");
addFunction("addTypef", "PLUM", "fa-dna");
addFunction("viewTypef", "PLUM", "fa-tasks");
$("#searchf").on("click", function () {
hideAll()
$("#main").show();
});
$("#viewTypef").on("click", function () {
hideAll()
initTypeView()
})
$("#addTypef").on("click", function () {
hideAll()
initTypeEditor()
})
$("#addf").on("click", function () {
hideAll()
initFunBuilder()
})
$("#reloadf").on("click", function () {
hideAll()
loadScripts()
})
// initScriptView();
// initEditor("main");
// initQueryBuilder();
// initObjectBuilder("number", {});
// initCalc(["a", "b", "c", "aLongerOne", "zehn"])
// initTypeEditor()
// initTypeView()
}