-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
128 lines (101 loc) · 3.61 KB
/
Copy pathindex.html
File metadata and controls
128 lines (101 loc) · 3.61 KB
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
<html>
<body>
<table>
<tr><td>Text to Save:</td></tr>
<tr>
<td colspan="3">
<textarea id="inputTextToSave" cols="80" rows="25" value="Ingresar un texto aca. Luego probar de grabarlo a un archivo con el boton 'Save Text to File' y luego probar de leerlo nuevamente con el boton 'Load...'"></textarea>
</td>
</tr>
<tr>
<td>Filename to Save As:</td>
<td><input id="inputFileNameToSaveAs"></input></td>
<td><button onclick="saveTextAsFile()">Save Text to File</button></td>
</tr>
<tr>
<td>Select a File to Load:</td>
<td><input type="file" id="fileToLoad"></td>
<td><button onclick="loadFileAsText()">Load Selected File</button><td>
</tr>
<tr></tr>
<tr>
<td><button onclick="test_isgd()">Test shortURL + imagen</button></td>
</tr>
<tr>
<td><p id='shorty'></p></td>
</tr>
<tr>
<td><img id='qrcode'></img></td>
<!-
Const sRootURL As String = "https://chart.googleapis.com/chart?"
Const sSizeParameter As String = "chs="
Const sTypeChart As String = "cht=qr"
Const sDataParameter As String = "chl="
Const sECCParameter As String = "chld=" 'Q|0" 'q=25% ECC | 0=border in rows
Const sJoinCHR As String = "&"
->
</tr>
</table>
<script>
function saveTextAsFile()
{
var textToSave = document.getElementById("inputTextToSave").value;
var textToSaveAsBlob = new Blob([textToSave], {type:"text/plain"});
var textToSaveAsURL = window.URL.createObjectURL(textToSaveAsBlob);
var fileNameToSaveAs = document.getElementById("inputFileNameToSaveAs").value;
var downloadLink = document.createElement("a");
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = "Download File";
downloadLink.href = textToSaveAsURL;
downloadLink.onclick = destroyClickedElement;
downloadLink.style.display = "none";
document.body.appendChild(downloadLink);
downloadLink.click();
}
function destroyClickedElement(event)
{
document.body.removeChild(event.target);
}
function loadFileAsText()
{
var fileToLoad = document.getElementById("fileToLoad").files[0];
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent)
{
var textFromFileLoaded = fileLoadedEvent.target.result;
document.getElementById("inputTextToSave").value = textFromFileLoaded;
};
fileReader.readAsText(fileToLoad, "UTF-8");
}
function test_isgd(url){
if (url == undefined) {url = 'http://example.com';}
var data_file = "https://is.gd/create.php?format=json&opt=0&url="+ url;
var http_request = new XMLHttpRequest();
http_request.onreadystatechange = function(){
if (http_request.readyState == 4 ) {
var jsonObj = JSON.parse(http_request.responseText);
sethtml("shorty", jsonObj.shorturl); //jsonObj.errormessage);
// agregar la generacion de QRcode
document.getElementById('qrcode').src = 'https://chart.googleapis.com/chart?chs=400x400&cht=qr&chld=Q|0&chl=' + encodeURIComponent(jsonObj.shorturl);
}
}
http_request.open("GET", data_file, true);
http_request.send();
}
</script>
</body>
<!-
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
->
<script>
function sethtml(id,val){document.getElementById(id).innerHTML = val;}
</script>
</html>