Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save amrishodiq/ca611bca044501268b2dfff77beca8b0 to your computer and use it in GitHub Desktop.
Save amrishodiq/ca611bca044501268b2dfff77beca8b0 to your computer and use it in GitHub Desktop.
JavaScript: LazyRepo PoC
<!DOCTYPE html>
<html>
<head>
<title>How To Use Lazy Repo</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="LazyRepo.js"></script>
</head>
<body>
<script type="text/javascript">
var databaseconfig = {
name: 'dummydatabase',
version: '1.0',
realName: 'Dummy Database',
size: 2 * 1024 * 1024
};
var datasourceTerminal = {
table: "terminal",
uri: "http://crop.jakarta.go.id/ajax/apps_command.php?Z2V0RGlzaHViVGVybWluYWx+MjAxNjA1MTBTbTRSVEMxdFk=",
fields: ["id", "terminal_name", "lat", "lng", "is_antar_kota", "alamat",
"kepala_terminal_dk", "kontak_dk", "kepala_terminal_ak", "kontak_ak",
"trayek_dk", "trayek_ak", "tahun", "luas_area", "foto"]
};
var datasourceHalte = {
table: "halte",
uri: "http://crop.jakarta.go.id/ajax/apps_command.php?Z2V0RGlzaHViSGFsdGV+MjAxNjA1MTBTbTRSVEMxdFk=",
fields: ["KOD1", "No", "LokasiHalte", "NamaHalte", "TipeHalte", "Atap", "lat", "lng"]
}
var datasourceHalteBusway = {
table: "haltebusway",
uri: "http://crop.jakarta.go.id/ajax/apps_command.php?Z2V0UnV0ZUJ1c3dheX4yMDE2MDUxMFNtNFJUQzF0WQ==",
fields: ["id", "nama_halte", "jurusan", "koridor", "geomtex"]
}
var datasourceDestinasiWisata = {
table: "destinasiwisata",
uri: "http://crop.jakarta.go.id/ajax/apps_command.php?Z2V0UGxhY2VtYXJrfjIwMTYwNTEwU200UlRDMXRZflRSLTI=",
fields: ["placemark_id", "category_id", "user_id", "package_id", "name", "address", "description",
"lat", "lng", "created", "icon", "icon_placemark", "contact", "email", "website", "banner",
"twitter_account", "counter", "counterx", "marketing_by", "is_parent", "child_of", "display"]
}
var datasourcePusatBelanja = {
table: "pusatbelanja",
uri: "http://crop.jakarta.go.id/ajax/apps_command.php?Z2V0UGxhY2VtYXJrfjIwMTYwNTEwU200UlRDMXRZfkxTLTI=",
fields: ["placemark_id", "category_id", "user_id", "package_id", "name", "address", "description",
"lat", "lng", "created", "icon", "icon_placemark", "contact", "email", "website", "banner",
"twitter_account", "counter", "counterx", "marketing_by", "is_parent", "child_of", "display"]
}
var jkt = new LazyRepo(databaseconfig);
// jkt.findLike(
// "terminal_name",
// "Ragunan",
// datasourceTerminal,
// function(results) {
// if (results == null) {
// console.log("Empty");
// return;
// }
// var len = results.rows.length;
// for (var i=0; i<len; i++) {
// console.log(results.rows.item(i));
// }
// },
// function(error) {
// console.log(error.message);
// });
// jkt.findLike(
// "LokasiHalte",
// "Bungur Raya",
// datasourceHalte,
// function(results) {
// if (results == null) {
// console.log("Empty");
// return;
// }
// var len = results.rows.length;
// for (var i=0; i<len; i++) {
// console.log(results.rows.item(i));
// }
// },
// function(error) {
// console.log(error.message);
// });
// jkt.findLike(
// "jurusan",
// "ragunan",
// datasourceHalteBusway,
// function(results) {
// if (results == null) {
// console.log("Empty");
// return;
// }
// var len = results.rows.length;
// for (var i=0; i<len; i++) {
// console.log(results.rows.item(i));
// }
// },
// function(error) {
// console.log(error.message);
// });
// jkt.findLike(
// "address",
// "ragunan",
// datasourceDestinasiWisata,
// function(results) {
// if (results == null) {
// console.log("Empty");
// return;
// }
// var len = results.rows.length;
// for (var i=0; i<len; i++) {
// console.log(results.rows.item(i));
// }
// },
// function(error) {
// console.log(error.message);
// });
jkt.findLike(
"address",
"cilandak",
datasourcePusatBelanja,
function(results) {
if (results == null) {
console.log("Empty");
return;
}
var len = results.rows.length;
for (var i=0; i<len; i++) {
console.log(results.rows.item(i));
}
},
function(error) {
console.log(error.message);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment