-
Notifications
You must be signed in to change notification settings - Fork 1
/
jsFactory.js
169 lines (134 loc) · 3.74 KB
/
jsFactory.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
158
159
160
161
162
163
164
165
166
167
168
169
var helpers = require('./libs/helpers');
var jsFactory = {};
jsFactory.createJS = function (name, configuration) {
return `/**
* @name ${name}
* @file Add a small description for this file.
* @author ${configuration.author} ${configuration.email}
* @version 1.0.0
*/`;
}
jsFactory.createClass = function (name, configuration) {
var className = helpers.capitalizeFirstLetter(name);
return `/**
* @name ${className}
* @extends
* @file ${name}.js
* @author ${configuration.author} ${configuration.email}
* @version 1.0.0
*/
class ${className} {
/**
* @param {data type} name - description.
*/
constructor() {
}
}`;
}
jsFactory.createJSForGame = function (configuration) {
return `/**
* @name main.js
* @file Add a small description for this file.
* @author ${configuration.author}, ${configuration.email}
* @version 1.0.0
*/
"use strict"
window.addEventListener('load', init, false);
function init() {
console.log('Game running!');
//Add Stats
var stats = new Stats();
stats.showPanel(0);
document.body.appendChild(stats.dom);
var requestId;
function update() {
stats.begin();
//Add here your game code that needs to be update every frame.
stats.end();
requestId = requestAnimationFrame(update);
}
update();
//Add here your game code that does not needs to be update every frame.
}`;
}
jsFactory.createJSForProject = function (configuration) {
return `/**
* @name main.js
* @file Add a small description for this file.
* @author ${configuration.author}, ${configuration.email}
* @version 1.0.0
*/
"use strict";
window.addEventListener('load', init, false);
function init() {
console.log('App running!');
//1. Declare variables
//2. Initialize variables
//3. Events
//4. Program Logic
}`;
}
jsFactory.createAppJSForWPProject = function (configuration) {
return `/**
* @name main.js
* @file Add a small description for this file.
* @author ${configuration.author}, ${configuration.email}
* @version 1.0.0
*/
"use strict";
import '../css/style.css';
import '../index.html'
window.addEventListener('load', init, false);
function init() {
console.log('App running!');
//1. Declare variables
//2. Initialize variables
//3. Events
//4. Program Logic
}`;
}
jsFactory.createHTMLHelper = function (configuration) {
return `/**
* @name html.js
* @file A small helper to create html elements.
* @author ${configuration.author}, ${configuration.email}
* @version 1.0.0
*/
export const div = (attributes, parent, children) => {
return tag('div', attributes, parent, children);
};
export const h1 = (attributes, parent, children) => {
return tag('h1', attributes, parent, children);
};
export const h2 = (attributes, parent, children) => {
return tag('h2', attributes, parent, children);
};
export const p = (attributes, parent, children) => {
return tag('p', attributes, parent, children);
};
export const button = (attributes, parent, children) => {
return tag('button', attributes, parent, children);
};
export const input = (attributes, parent, children) => {
return tag('input', attributes, parent, children);
};
export const select = (attributes, parent, children) => {
return tag('select', attributes, parent, children);
};
export const option = (attributes, parent, children) => {
return tag('option', attributes, parent, children);
};
export const tag = (type, attributes, parent, children) => {
let e = document.createElement(type);
if (parent) parent.appendChild(e);
if (children)
children.map((child) => {
e.appendChild(child);
});
for (const k in attributes) {
e[k] = attributes[k];
}
return e;
};`;
}
module.exports = jsFactory;