-
Notifications
You must be signed in to change notification settings - Fork 6
/
script.js
99 lines (89 loc) · 3.42 KB
/
script.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
/*jslint browser: true, plusplus: true, indent: 2 */
/*global majaX, unescape, escape */
var expmode = false, options = {};
function getOptions() {
"use strict";
options = {
'tags' : document.getElementById('tags').value,
'amazon' : document.getElementById('amazon').value,
'thomann' : document.getElementById('thomann').value,
'tradedoubler' : document.getElementById('tradedoubler').value,
'mainmode' : document.getElementById('mainmode').value,
'expmode' : expmode
};
return options;
}
window.onload = function () {
"use strict";
majaX({
'url': 'http://cdn.simon.waldherr.eu/projects/showpad-api/getList/',
'type': 'json'
}, function (json) {
var i, pads = '';
for (i = 0; i < json.length; i++) {
pads += '<span onclick="loadPad(\'' + json[i].docname + '\');" class="baf bluehover">' + json[i].docname + '</span>';
}
document.getElementById('padlist').innerHTML = pads;
});
};
function utf8_to_b64(str) {
"use strict";
return window.btoa(unescape(encodeURIComponent(str)));
}
function b64_to_utf8(str) {
"use strict";
return decodeURIComponent(escape(window.atob(str)));
}
function searchPadslist(e) {
"use strict";
var i, pads = document.getElementById('padlist').getElementsByTagName('span');
for (i = 0; i < pads.length; i++) {
if (pads[i].innerHTML.indexOf(e.value) !== -1) {
pads[i].style.display = 'block';
} else {
pads[i].style.display = 'none';
}
}
}
function loadPad(name) {
"use strict";
majaX({
'url': 'http://cdn.simon.waldherr.eu/projects/showpad-api/getPad/?id=' + name,
'type': 'txt'
}, function (txt) {
document.getElementById('defaulttextarea').innerHTML = txt;
});
}
function parsePad() {
"use strict";
var padContent = window.btoa(window.unescape(encodeURIComponent(document.getElementById('defaulttextarea').value)));
getOptions();
majaX({
'url': './api.php',
'method': 'POST',
'type': 'txt',
'data': {
'pad': padContent,
'tags': options.tags,
'amazon': options.amazon,
'thomann': options.thomann,
'tradedoubler': options.tradedoubler,
'mainmode': options.mainmode,
'expmode': options.expmode
}
}, function (txt) {
var style = '.osf_chaptertime, .osf_chapter {vertical-align: baseline;}';
document.getElementById('viewarea').srcdoc = '<html><head><title>' + options.mainmode + ' - Shownotes</title><link rel="stylesheet" href="http://shownotes.github.io/tinyOSF.js/shownotes.css" type="text/css" media="screen"><link rel="stylesheet" href="http://tools.shownot.es/parsersuite/preview.css" type="text/css" media="screen"><style>' + style + '</style></head><body><div class="content"><div class="box">' + txt + '</div></div><div class="footer"> <span>© 2013 <a href="/">shownot.es</a></span></div></body></html>';
document.getElementById('sourcearea').innerHTML = txt;
if (expmode === 'preview') {
document.getElementById('outputview').style.display = 'block';
document.getElementById('outputsource').style.display = 'none';
} else if (expmode === 'source') {
document.getElementById('outputview').style.display = 'none';
document.getElementById('outputsource').style.display = 'block';
} else if (expmode === 'download') {
document.getElementById('outputview').style.display = 'none';
document.getElementById('outputsource').style.display = 'none';
}
});
}