Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
119 lines (97 sloc) 4.57 KB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Gambas Farm</title>
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="farm.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
function DoSearch() {
var xhr = new XMLHttpRequest();
var url = "search.php?sort=date"
url += "&filter=" + document.getElementById("filter").value;
url += "&tags=" + document.getElementById("tags").value;
url += "&vendor=" + document.getElementById("vendor").value;
xhr.open('GET', url, true);
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//document.getElementById("code").innerHTML=this.responseText;
var lines = this.responseText.split("\n")
var results= lines[1].split("=")
var codes = results[1].split(",")
document.getElementById("total").innerHTML = codes.length.toString() + " Results"
var table = document.getElementById("view")
table.style.borderSpacing = "0px"
table.style.padding = "1px"
table.innerHTML = ""
var row = table.insertRow();
row.insertCell(0).innerHTML = "Code"
row.insertCell(1).innerHTML = "Icon"
row.insertCell(2).innerHTML = "Text"
row.insertCell(3).innerHTML = "Screen Shot"
for (var i = 0, len = codes.length; i < len; i++) {
var row = table.insertRow();
var codeCell = row.insertCell(0)
codeCell.style.verticalAlign= "top"
codeCell.innerHTML = codes[i]
var iconCell = row.insertCell(1)
iconCell.style.verticalAlign = "top"
iconCell.innerHTML = "<img src=\"http://gambasfarm.org/farm/get?icon&id=" + codes[i] +"\"/>"
var textCell = row.insertCell(2)
textCell.style.verticalAlign = "top"
row.insertCell(3).innerHTML = "<img src=\"http://gambasfarm.org/farm/get?screenshot&id=" + codes[i] +"\"/>"
//Get Text Information
xhrs = new XMLHttpRequest();
xhrs.open('GET', "get.php?id=" + codes[i], true);
xhrs.onreadystatechange = function() {
if (this[0].readyState == 4 && this[0].status == 200) {
var lines2 = this[0].responseText.split("\n")
for (var x = 0, len = lines2.length; x < len; x++) {
var values= lines2[x].split("=")
switch (values[0]) {
case "Name": case "Description": case "Owner": case "Version":
this[1].innerHTML += values[0] + ": " + values[1] + "</br></br>";
break;
case "FullDownloadCount":
this[1].innerHTML += "Downloads: " + values[1] + "</br></br>";
break;
}
}
}
}.bind([xhrs, textCell])
xhrs.send();
}
}
}.bind(xhr)
xhr.send();
}
</script>
</head>
<body>
<header>
<table>
<tr>
<td colspan=2><div id="title">Gambas Software Farm</div><br></td>
</tr>
<tr>
<td>Filter:</td>
<td><input type="text" id="filter" size="75"/></td>
</tr>
<tr>
<td>Tags:</td>
<td><input type="text" id="tags" size="75"/></td>
</tr>
<tr>
<td>Vendor:</td>
<td><input type="text" id="vendor" size="75"/></td>
</tr>
<tr>
<td colspan=2><br><button id="search" onclick="DoSearch()">Search</button>&nbsp;&nbsp;&nbsp;<span id="total"></span></td>
</tr>
</table>
</header>
<table id="view" border="1">
</table>
</body>
</html>