-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpostit.js
executable file
·57 lines (45 loc) · 1.48 KB
/
postit.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
function postit(url, array) {
/* https://github.com/aleckyann/postit */
var inputs;
var formulario;
function prepareData(array){
var data = [];
array.forEach(function(input) {
data.push(input.split('='));
});
return data;
};
function createForm(url){
var formulario = document.createElement("form");
formulario.method = "post";
var atributo = document.createAttribute("action");
atributo.value = url;
document.body.appendChild(formulario);
formulario.setAttributeNode(atributo);
return formulario;
}
function createInputs(inputs, formulario){
var input;
inputs.push(['Postit', 'https://github.com/aleckyann/postit']);
inputs.forEach(function(item){
input = document.createElement("input");
input.type = "hidden";
input.name = item[0];
input.value = item[1];
formulario.appendChild(input);
});
return formulario;
}
inputs = prepareData(array);
formulario = createForm(url);
formulario = createInputs(inputs, formulario);
formulario.submit();
};
document.addEventListener("DOMContentLoaded", function(event) {
if(document.querySelectorAll('[onclick]')){
var elements = document.querySelectorAll("[onclick]");
for(var i = 0; i < elements.length; i++) {
elements[i].style.cursor = 'pointer';
}
};
});