This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Memanggil Function dan Perintah Javascript pada HTML | |
<a href="javascript:void(null)" onclick="nama_function()">Example</a> | |
<a href="javascript:void(null)" onclick="alert('Example')">Example</a> | |
//Mengambil URL yang sedang diakses | |
alert(document.location.href); | |
//Objek JSON | |
var JSONstring = | |
{ | |
"firstname": "Greg", | |
"email": "greg@fake_email.com", | |
"hobby": | |
[ | |
{ | |
"hobbyName": "sport", | |
"isHobby": true | |
}, | |
{ | |
"hobbyName": "reading", | |
"isHobby": false | |
}, | |
{ | |
"hobbyName": "music", | |
"isHobby": false | |
} | |
] | |
}; | |
alert(JSONstring.hobby[0].isHobby); //true | |
alert(JSONstring.hobby[1].hobbyName); //reading | |
//AJAX pada Javascript | |
$('#simpan_perangkat').click(function() { | |
var data = { | |
pengguna: $('#pengguna').val(), | |
katasandi: $('#katasandi').val() | |
}; | |
$.ajax({ | |
url: "http://192.168.1.130:8081/ekuade/masuk/masuk.php", | |
type: "POST", | |
data: data, | |
success: function(pesan) { | |
alert(pesan); | |
if(pesan === "Anda Sukses Masuk") { | |
document.location.href = "index2.html"; | |
} else { | |
document.location.href = "index.html"; | |
} | |
}, | |
error: function(pesan) { | |
alert('Kesalahan URL'); | |
} | |
}); | |
return false; | |
}); | |
var host = window.location.host; | |
var directory = window.location.pathname.split('/')[1]; | |
//var host = "192.168.200.101"; | |
//var directory = "pemesanan_makanan"; | |
var full_url = document.URL; | |
var url_array = full_url.split('='); | |
var id_pengguna = url_array[url_array.length-1]; | |
if(id_pengguna == "" || id_pengguna == "undefined" || isNaN(id_pengguna)) { | |
redirect('index'); | |
} | |
$(function() { | |
$('.show-page-loading-msg').click(); | |
$.ajax({ | |
url: "http://"+host+"/"+directory+"/actions/data_pesanan3.php", | |
dataType: "json", | |
success: function(data) { | |
$("#a_data_pesanan").html(""); | |
data_pesanan1 = '<br /><input type="button" onClick="redirect(\'data_pegawai\', id_pengguna)" data-role="button" data-inline="true" data-icon="refresh" data-mini="true" value="Muat Ulang" /><table data-role="table" id="tabel_data_pegawai" data-mode="columntoggle" class="ui-body-d ui-shadow table-stripe ui-responsive" data-column-btn-theme="b" data-column-btn-text="Tampil Kolom" data-column-popup-theme="d"><thead><tr class="ui-bar-d"><th data-priority="1">Meja</th><th data-priority="3">Atas Nama</th><th data-priority="4">Waktu Pesanan</th><th data-priority="5">Status</th><th data-priority="2">Aksi</th></thead><tbody>'; | |
data_pesanan2 = ''; | |
$.each(data, function(i,n) { | |
data_pesanan2 = data_pesanan2 + '<tr><th>' + n["id_meja"] + '</th><th><a href="#">' + n["atas_nama_pesanan"] + '</a></th><td>' + n["waktu_pesanan"] + '</td><td>' + statsAktif(n["status_pesanan"]) + '</td><td><a href="#" onclick="proses_data(\'' + n["waktu_pesanan"] + '\', ' + n["status_pesanan"] + ')">Proses</a></td></tr>'; | |
}); | |
data_pesanan3 = '</tbody></table>'; | |
$("#a_data_pesanan").append(data_pesanan1 + data_pesanan2 + data_pesanan3); | |
$("#a_data_pesanan").trigger("create"); | |
$('.hide-page-loading-msg').click(); | |
}, | |
error: function(pesan) { | |
alert('Kesalahan URL'); | |
} | |
}); | |
}); | |
function statsAktif(a) { | |
if(a=="0") { | |
return "Batal"; | |
} else if(a=="1") { | |
return "Antri"; | |
} else if(a=="2") { | |
return "Masak"; | |
} else if(a=="3") { | |
return "Antar"; | |
} else if(a=="4") { | |
return "Kasir"; | |
} else { | |
return "Selesai"; | |
} | |
} | |
function proses_data(a,b) { | |
var r=confirm("Apakah Anda yakin memproses data ini?"); | |
if (r==true) { | |
var data = { | |
id: a, | |
stat: b | |
}; | |
$.ajax({ | |
url: "http://"+host+"/"+directory+"/actions/proses_pesanan.php", | |
type: "POST", | |
data: data, | |
success: function(pesan) { | |
alert(pesan); | |
redirect('pengantar_makanan', id_pengguna); | |
}, | |
error: function(pesan) { | |
alert('Kesalahan URL'); | |
} | |
}); | |
} | |
} | |
function redirect(url, id) { | |
document.location.href = url + ".html?id=" + id; | |
} | |
function redirect_page(index) { | |
$.mobile.changePage("#" + index); | |
} | |
//Validasi Angka Inputan | |
$('#simpan_surat_perjanjian').click(function() { | |
var telepon = $('input#telepon_penyewa').val(); | |
if(isNaN(telepon)) { | |
alert('Form Telepon Bukan Angka!!'); | |
return false; | |
} else if(telepon === '') { | |
alert('Form Telepon Kosong!!'); | |
return false; | |
} else { | |
alert('Form Telepon Angka!!'); //Lakukan Sesuatu Jika Inputan Merupakan Angka | |
} | |
//return false; | |
}); | |
$('#kirim').click(function() { | |
if($('#nomor_penerima_sms').val()!="" && $('#nomor_penerima_sms').val()!=" " && $('#nomor_penerima_sms').val()!=null && !isNaN($('#nomor_penerima_sms').val()) && $('#nomor_penerima_sms').val().length>10 && $('#nomor_penerima_sms').val().length<13 && $('#nama_pengirim_sms').val()!="" && $('#nama_pengirim_sms').val()!=" " && $('#nama_pengirim_sms').val()!=null && $('#nama_pengirim_sms').val().length<=32 && $('#nama_penerima_sms').val()!="" && $('#nama_penerima_sms').val()!=" " && $('#nama_penerima_sms').val()!=null && $('#nama_penerima_sms').val().length<=32 && $('textarea#isi_pesan_sms').val()!="" && $('textarea#isi_pesan_sms').val()!=" " && $('textarea#isi_pesan_sms').val()!=null && $('textarea#isi_pesan_sms').val().length<=160 && $('textarea#isi_pesan_sms').val()!="{TULISKAN ISI PESANMU DISINI}") { | |
$.ajax({ | |
url: "http://agustianra.p.ht/smsgateway/simpan_sms.php?nama_pengirim_sms="+$('#nama_pengirim_sms').val()+"&nama_penerima_sms="+$('#nama_penerima_sms').val()+"&nomor_penerima_sms="+$('#nomor_penerima_sms').val()+"&isi_pesan_sms="+$('textarea#isi_pesan_sms').val(), | |
dataType : "jsonp", | |
async: false, | |
jsonpCallback: 'jsonCallback', | |
contentType: "application/json", | |
type: "GET", | |
success: function(pesan) { | |
alert("Status Kirim: " + pesan.sukses[0].pesanSukses + "\nReferensi ID: " + pesan.sukses[0].refID); | |
$('#nama_pengirim_sms').val("GUEST"); | |
$('#nama_penerima_sms').val("USER"); | |
$('#nomor_penerima_sms').val(0); | |
$('textarea#isi_pesan_sms').val("{TULISKAN ISI PESANMU DISINI}"); | |
}, | |
error: function(pesan) { | |
alert("Gagal"); | |
$('#nama_pengirim_sms').val("GUEST"); | |
$('#nama_penerima_sms').val("USER"); | |
$('#nomor_penerima_sms').val(0); | |
$('textarea#isi_pesan_sms').val("{TULISKAN ISI PESANMU DISINI}"); | |
} | |
}); | |
} else { | |
alert("Terdapat kesalahan pada inputan"); | |
} | |
return false; | |
}); | |
$('#reset').click(function() { | |
$('#nama_pengirim_sms').val("GUEST"); | |
$('#nama_penerima_sms').val("USER"); | |
$('#nomor_penerima_sms').val(0); | |
$('textarea#isi_pesan_sms').val("{TULISKAN ISI PESANMU DISINI}"); | |
return false; | |
}); | |
//Parsing JSON Pada HTML | |
function data_kontrak_paket_detail(id_paket) { | |
document.getElementById('id_data_kontrak_paket_json2').innerHTML = ""; | |
url2 = "http://192.168.1.130:8081/ekuade/surat_perjanjian/surat_perjanjian_paket_json2.php?id="; | |
$.ajax({ | |
url: url2 + id_paket, | |
dataType: "json", | |
success: function(data){ | |
data_kontrak3 = "<center><table border=\"1\" width=\"100%\">"; | |
$.each(data, function(i,n){ | |
data_kontrak3 = data_kontrak3 + "<tr><th>Nomor</th><td align=\"center\">" + n["id_spp"] + "</td></tr><tr><th>Nama</th><td align=\"center\">" + n["nama_spp"] + "</td></tr><tr><th>alamat</th><td align=\"center\">" + n["alamat_spp"] + "</td></tr><tr><th>telepon</th><td align=\"center\">" + n["telepon_spp"] + "</td></tr><tr><th>paket sewa</th><td align=\"center\">" + n["sewa_spp"] + "</td></tr><tr><th>contoh dekorasi</th><td align=\"center\">" + n["dekorasi_spp"] + "</td></tr><tr><th>tgl sewa</th><td align=\"center\">" + n["tanggal_spp"] + "</td></tr><tr><th>tanggal masuk</th><td align=\"center\">" + n["tanggal_masuk"] + "</td></tr><tr><th>penanggung jawab</th><td align=\"center\">" + n["penanggung_jawab"] + "</td></tr>"; | |
}); | |
data_kontrak3 = data_kontrak3 + "</table></center>"; | |
$.each(data, function(i,n){ | |
data_kontrak3 = data_kontrak3 + "<br /><center><a onclick=\"unduh_kontrak('"+ n["id_spp"] +"')\" href=\"javascript:void(null)\">" + n["id_spp"] + "</a></center>"; | |
}); | |
$(".result_data_kontrak_paket_json2").append(data_kontrak3); | |
} | |
}); | |
} | |
//Combo Box Bertingkat Dengan Menggunakan PHP & AJAX | |
function updateAngkaKredit(){ | |
jQuery.ajax({ | |
'url': 'index.php?butirid='+$('#Penelitian_butir_id').val(), | |
'cache': false, | |
'success': function(html){ | |
$('#Penelitian_angka_kredit').val(html); | |
} | |
}); | |
} | |
$(document).ready(function() { | |
$('#Penelitian_butir_id').change(function() { | |
updateAngkaKredit(); | |
}); | |
updateAngkaKredit(); | |
//$('#Pendidikan1_angka_kredit').attr('disabled', true); | |
//$('input').attr('readonly', true); | |
$('#Penelitian_subunsur_id').attr('readonly', true); | |
$('#Penelitian_angka_kredit').attr('readonly', true); | |
$('#Penelitian_dosen_id').attr('readonly', true); | |
//hide div | |
$('#divSubunsurid').hide(); | |
$('#divDosenid').hide(); | |
}); | |
//Perkalian Setiap Ada Perubahan Pada Nilai Inputan | |
function fungsi_perkalian() { //cara pakai onchange="fungsi_perkalian()" | |
a = document.getElementById("nilai_a").value; | |
document.getElementById("hasil_perkalian").innerHTML = a*275000; | |
} | |
//Javascript Checkbox Handler | |
$('#tombol_simpan').click(function() | |
{ | |
if($('#contoh_checkbox:checked').val() == 1) | |
{ | |
a = "Ter-centang"; //Lakukan Sesuatu Jika Ter-centang | |
} else { | |
a = "Tidak Ter-centang"; //Lakukan Sesuatu Jika TIDAK Ter-centang | |
} | |
} | |
//JSON Api handler | |
$(document).ready(function(){ | |
$.ajax({ | |
url: 'http://api.pemiluapi.org/calonpresiden/api/caleg?apiKey=' + api, | |
dataType: 'json', | |
success: function(data) { | |
alert(data.data.results.total); | |
$.each(data.data.results.caleg, function(i,n) { | |
alert(n["id"] + " " + i); | |
}); | |
}, | |
error: function(data) { | |
alert("Kesalahan URL"); | |
} | |
}); | |
}); | |
//Memunculkan pop-up | |
function popupstatic(url) | |
{ | |
var newwindow=window.open(url,'name','height=550,width=800,top=70,left=550,menubar=no,location=no,directories=no,resizable=no,scrollbars=yes,toolbar=no,status=no'); | |
if (window.focus) {newwindow.focus()} | |
} | |
//Mencetak halaman pop-up | |
window.print(); | |
setTimeout('window.close()', 1000); | |
//Ajax extract JSON API | |
var api = "bb9bded99adac7cf1049c5af7b7723be"; | |
$(document).ready(function(){ | |
$.ajax({ | |
url: 'http://api.pemiluapi.org/calonpresiden/api/caleg?apiKey=' + api, | |
dataType: 'json', | |
success: function(data) { | |
alert(data.data.results.total); | |
$.each(data.data.results.caleg, function(i,n) { | |
alert(n["id"] + " " + i); | |
}); | |
}, | |
error: function(data) { | |
alert("Kesalahan URL"); | |
} | |
}); | |
}); | |
//Memanggil Function secara dinasmis | |
pindah('apem'); | |
function pindah(a) { | |
window[a](); | |
} | |
function apem() { | |
alert('Sip'); | |
} |
Tidak ada komentar:
Posting Komentar