Skip to content
Snippets Groups Projects

11- 13515040 - Patrick Nugroho Hadiwinoto

Open Martin Lutta requested to merge 1SleepNotFound/TugasBesar1_2017:master into master
Viewing commit 8a116dc5
Show latest version
4 files
+ 272
0
Preferences
Compare changes
Files
4
+ 123
0
function initialize() {
var id_active = getQueryVariable("id_active");
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myJSON = this.responseText;
var obj = JSON.parse(myJSON);
document.getElementById("hi-username").innerHTML = obj.username;
document.getElementById("username").innerHTML = "@" + obj.username;
}
}
xmlhttp.open("GET", "fetchUserData.php?id_active="+id_active,true);
xmlhttp.send();
document.getElementById("destination-phase").id="active-phase";
document.getElementById("driver-list").style.display="none";
document.getElementById("give-review").style.display="none";
}
function fetchDriverList() {
var htmlElement = [
'<div id="other-suggestions" class="other-suggestions">',
'<img id="userpp" src="../src/profile_sample_circle.PNG">',
'<div class="profile-data" style="width: 25em; height: 135px; float: right; border: 1px solid red;">',
'<p> PIKACHUUUU </p>',
'<button type="button" id="i-choose-you"> I CHOOSE YOU </button> </div> </div> <br>'
];
console.log(htmlElement);
var id_active = getQueryVariable("id_active");
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myJSON = this.responseText;
console.log(myJSON);
var obj = JSON.parse(myJSON);
var parent = document.getElementById("other-suggestions");
for (i = 0; i < obj.result.length; i++) {
htmlElement[2]="<p> " + obj.result[i].username + " </p>";
htmlElement[3]='<p> <span id="user-stars"> &#9734 ' +
obj.result[i].rating + '<span id="user-votes"> (' + obj.result[i].votes + ' votes) </span> </p>';
var elementInString = Array.prototype.join.call(htmlElement, "\n");
var child = document.createElement('div');
child.innerHTML = elementInString;
child = child.firstChild;
parent.appendChild(child);
console.log(elementInString);
}
}
}
xmlhttp.open("GET", "processOrder.php?id_active="+id_active,true);
xmlhttp.send();
}
function goTo(location) {
var currentActiveID = getQueryVariable("id_active");
if (location == 'profile') {
location = "profile.php?id_active=";
}
else if (location == 'history') {
location = "history.php?id_active=";
}
else {
console.log(location);
location= "order.php?id_active=";
}
location += currentActiveID;
console.log(location);
window.location.href = location;
}
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++)
{
var pair = vars[i].split("=");
if (pair[0] == variable)
{
return pair[1];
}
}
return -1; //not found
}
function showSelectDestination() {
document.getElementById("driver-list").style.display="none";
document.getElementById("give-review").style.display="none";
document.getElementById("destination-form").style.display="block";
document.getElementById("destination-phase").id ="active-phase";
document.getElementById("complete-order-phase").id ="complete-order-phase";
document.getElementById("select-driver-phase").id = "select-driver-phase";
}
function showSelectDriver() {
document.getElementById("give-review").style.display="none";
document.getElementById("destination-form").style.display="none";
document.getElementById("driver-list").style.display="block";
document.getElementById("active-phase").id ="destination-phase";
document.getElementById("complete-order-phase").id ="complete-order-phase";
document.getElementById("select-driver-phase").id = "active-phase";
}
function showCompleteYourOrder() {
document.getElementById("driver-list").style.display="none";
document.getElementById("give-review").style.display="block";
document.getElementById("destination-form").style.display="none";
document.getElementById("active-phase").id ="destination-phase";
document.getElementById("complete-order-phase").id ="complete-order-phase";
document.getElementById("select-driver-phase").id = "active-phase";
}