summaryrefslogtreecommitdiff
path: root/frontend/script.js
blob: 90dcb9a0ad41a34cf8f6732d82a2974225c270ab (plain)
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
const endpoint = "http://127.0.0.1:8080/endpoints"
let i = 0;


function set_embed_page(url) {
	document.getElementById("docset-page").src = url;
}

function populateSearchBar(docset_json) {
	//console.log(docset_json);
	++i;
	console.log(i);

	// Add to search bar
	document.getElementById("searchbar").getElementsByTagName("tbody")[0].innerHTML += "<tr>" +
		"<td scope=\"row\">" +
		"<button id=\"docset-" + docset_json["CFBundleIdentifier"] + "-parent\" class=\"docset-parent\" onclick=\"set_embed_page('" + docset_json["docset_root"] + "')\">" +
		docset_json["CFBundleName"] + 
		"</button>" +
		"</td>" + 
		"</tr>";
}


let xhttp = new XMLHttpRequest();
xhttp.open("GET", endpoint + "/get_plist.py");
xhttp.onload = function(){
	const json_response = JSON.parse(this.response);
	console.log(json_response);

	if(!json_response["success"]) {
		console.warn("Invalid json_response");
		return 1;
	}

	//populateSearchBar(json_response["docsets"][0]);
	json_response["docsets"].forEach(populateSearchBar);
	delete json_response
}
xhttp.send();