Skip to content

Commit 31d7078

Browse files
Refeito todo o sistema
1 parent fa56db5 commit 31d7078

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+8748
-242
lines changed
File renamed without changes.

ClientModuleJS-master/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ClientModuleJS
2+
Sistema de modulos semelhante ao do Node JS que é executado em Javascript Client Side
3+
4+
---------------------------
5+
6+
##### Pequeno sistema de carregamento de modulos em Javascript Client Side
7+
8+
---------------------------
9+
- **Mas vai ficar fazendo Requisições toda hora?**
10+
- **R:** Não. O sistema tem cache, caso esteja em modo de desenvolvimento há uma verificação de codigo novo via requisição.
11+
---------------------------
12+
- **Como Usar?**
13+
- **R:** No Arquivo **index.html** tem um belo Exemplo de como usar.
14+
---------------------------

ClientModuleJS-master/index.html

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Testes</title>
6+
</head>
7+
<body>
8+
<h1>Testes</h1>
9+
<script type="text/javascript" src="scripts/ClientModuleJS.min.js"></script>
10+
<script type="text/javascript">
11+
12+
let Require = new Modules({
13+
"path": "scripts/modules/",
14+
"debug": false,
15+
"developer": false
16+
});
17+
18+
var Serial = Require("serial"),
19+
User = Require("user"),
20+
Gen = Require("genUser");
21+
22+
var usuario = new User.CreateUser("Paulo Romao");
23+
var gerado = Serial.Generate(10000);
24+
25+
document.write(Gen.GenUser("Paulao", gerado));
26+
document.write("<br/>"+usuario.getNome()+"<br/>"+usuario.getId());
27+
28+
</script>
29+
</body>
30+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
"use strict";
2+
3+
class Modules {
4+
5+
constructor(config) {
6+
this.Path = config.path || "scripts/modules/";
7+
this.Debugged = config.debug || false;
8+
this.Developer = config.developer || false;
9+
return this.Require.bind(this);
10+
}
11+
12+
Development(file){
13+
var Cache = this.Cache();
14+
this.getCode(file, function() {
15+
var res = this.responseText;
16+
var buffer = Cache.getCache(file);
17+
console.log("➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖");
18+
console.log("☑️ 👨🏻‍💻 DEBUG MODO DESENVOLVEDOR 👨🏻‍💻 ☑️");
19+
if(res != buffer){
20+
console.log("👉🏽 Cache Modificado! do modulo : "+file+" ✔️\n O modulo sera recarregado ✔️");
21+
Cache.setCache(file, res);
22+
}else{
23+
console.log("👉🏽 Não mudou nada no cache do modulo : "+file+" 🔴");
24+
}
25+
console.log("➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖");
26+
});
27+
}
28+
29+
getCode(dir, call) {
30+
var req = new XMLHttpRequest();
31+
req.onload = call;
32+
req.open("GET", dir, true);
33+
req.send();
34+
}
35+
36+
static ClearCache(reload) {
37+
if (sessionStorage.getItem("modulesLoaded") != null) {
38+
var Cached = JSON.parse(sessionStorage.getItem("modulesLoaded"));
39+
Cached.map((moduleName, moduleIndex) => {
40+
sessionStorage.removeItem(moduleName);
41+
});
42+
sessionStorage.removeItem("modulesLoaded");
43+
if ((reload || false)) {
44+
location.reload();
45+
}
46+
}
47+
}
48+
49+
Cache(n) {
50+
51+
return {
52+
exists(name) {
53+
if (sessionStorage.getItem(name) == null) {
54+
return false;
55+
} else {
56+
return true;
57+
}
58+
},
59+
setCache(n, c) {
60+
function PushModule(name) {
61+
var CacheModules = JSON.parse(sessionStorage.getItem("modulesLoaded"));
62+
if (CacheModules.indexOf(name) == -1) {
63+
CacheModules.push(name);
64+
sessionStorage.setItem("modulesLoaded", JSON.stringify(CacheModules));
65+
}
66+
}
67+
if (!this.exists("modulesLoaded")) {
68+
sessionStorage.setItem("modulesLoaded", JSON.stringify(new Array()));
69+
}
70+
PushModule(n);
71+
sessionStorage.setItem(n, c);
72+
},
73+
getCache(n) {
74+
return sessionStorage.getItem(n);
75+
}
76+
}
77+
78+
}
79+
80+
Patterns(code, debug, filename) {
81+
var m = new Function("", `
82+
const debug = ${debug};
83+
const exports = {};
84+
const module = {exports: {}};
85+
${code}
86+
if(Object.values(exports).length > 0){
87+
if(debug){ console.log("Modulo Importado via : exports"); }
88+
return exports;
89+
} else if(Object.values(module.exports).length > 0){
90+
if(debug){ console.log("Modulo Importado via : module.exports"); }
91+
return module.exports;
92+
} else{
93+
throw 'Indefinido "exports" ou "module.exports" No Arquivo : ${location.href+filename}';
94+
return exports;
95+
}
96+
`);
97+
return m;
98+
}
99+
100+
Require(filename) {
101+
const Path = this.Path;
102+
let file = Path + filename + ".js";
103+
var Cache = this.Cache();
104+
if (!Cache.exists(file)) {
105+
this.getCode(file, function() {
106+
var res = this.responseText;
107+
Cache.setCache(file, res);
108+
});
109+
}
110+
if (Cache.exists(file)) {
111+
if(this.Developer){ this.Development(file); }
112+
var p = this.Patterns(Cache.getCache(file), this.Debugged, file);
113+
return p();
114+
} else {
115+
var BotVerifyCache = setInterval(function() {
116+
if (Cache.exists(file)) {
117+
clearInterval(BotVerifyCache);
118+
location.reload();
119+
}
120+
}, 1);
121+
}
122+
}
123+
124+
}

ClientModuleJS-master/scripts/ClientModuleJS.min.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports.GenUser = function(nome, key){
2+
console.log({nome: nome,id: key});
3+
return "Nome : "+nome+", ID: "+key;
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pasta padrao para carregamento dos modulos
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function Generate(max){
2+
return Math.floor(Math.random() * max);
3+
}
4+
5+
function Log(text){
6+
console.log(text);
7+
}
8+
9+
module.exports = {
10+
Generate: Generate,
11+
Log: Log
12+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class User{
2+
3+
constructor(name){
4+
this.nome = name;
5+
console.log("Novo usuario : "+ name);
6+
}
7+
8+
getNome(){
9+
return this.nome;
10+
}
11+
12+
getId(){
13+
return Math.floor(Math.random() * 10000);
14+
}
15+
16+
}
17+
18+
exports.CreateUser = User;

artyom.js-master/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.vscode

artyom.js-master/.npmignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
development
2+
node_modules
3+
public
4+
.gitignore

artyom.js-master/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Carlos Delgado
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)