114 lines
3.6 KiB
JavaScript
114 lines
3.6 KiB
JavaScript
/*Alert*/
|
|
window.onload = function () {
|
|
var seconds = 5;
|
|
setTimeout(function () {
|
|
document.getElementById("alert").style.display = "none";
|
|
}, seconds * 1000);
|
|
};
|
|
|
|
|
|
$(document).ready(function(){
|
|
/*search form*/
|
|
$( "#search" ).blur(function() {
|
|
$('#suggestions').fadeOut();
|
|
});
|
|
$("#search").click(function(){
|
|
$('#suggestions').fadeIn();
|
|
});
|
|
|
|
/*friend status*/
|
|
if ($('#sfriend').html() != 'Add Friend'){
|
|
$("#sfriend").addClass( "disabled" );
|
|
}
|
|
|
|
});
|
|
|
|
/*search*/
|
|
function lookup(inputString) {
|
|
if(inputString.length == 0) {
|
|
$('#suggestions').fadeOut();
|
|
}else {
|
|
$.get("home.php?search="+inputString, function(data) {
|
|
$('#suggestions').fadeIn();
|
|
$('#suggestions').html(data);
|
|
});
|
|
}
|
|
}
|
|
|
|
function editprofil(){
|
|
var defau = $('#edited').html();
|
|
//elemen change
|
|
$('.middle, .right, .boxAvatar').foggy({
|
|
blurRadius: 3, // In pixels.
|
|
opacity: 0.8, // Falls back to a filter for IE.
|
|
cssFilterSupport: true // Use "-webkit-filter" where available.
|
|
});
|
|
var nama = $('#pnama').html();
|
|
var dob = $('#pdob').html();
|
|
var asal = $('#pasal').html();
|
|
var alamat = $('#palamat').html();
|
|
var fakultas = $('#pfakultas').html();
|
|
var jurusann = $('#pjurusan').html();
|
|
var year = $('#pangkatan').html();
|
|
$("#formedit").append('<div class="row" style="padding:10px;text-align:right;"><button class="btn btn-default btn-xs" type="button" id="canceledit">Cancel</button> <button class="btn btn-primary btn-xs" id="saveedit" type="submit">Save</button></div>' );
|
|
$('#pnama').html('<input type="text" name="name" maxlength="20" value="'+nama+'" required>');
|
|
$('#pdob').html('<input type="date" value="'+dob+'" name="dob" required>');
|
|
$('#pasal').html('<input type="text" value="'+asal+'" name="hometown" required>');
|
|
$('#palamat').html('<input type="text" value="'+alamat+'" name="address" required>');
|
|
$('#pangkatan').html('<input type="text" value="'+year+'" name="angkatan" required>');
|
|
$('#pfakultas').html('<select name="fakultas" id="fakultas" required><option value="'+fakultas+'" selected>'+fakultas+'</option></select>');
|
|
$('#pjurusan').html('<select name="jurusan" id="jurusan" required><option value="'+jurusann+'" selected>'+jurusann+'</option></select>');
|
|
$('#fakultas').append('<option value="Manajemen">Manajemen</option>');
|
|
$('#fakultas').append('<option value="Desain">Desain</option>');
|
|
$('#fakultas').append('<option value="Teknik">Teknik</option>');
|
|
|
|
//select box change
|
|
var teknik = ["Informatika","Telekomunikasi","Elektro","Industri"];
|
|
var manajemen = ["Bisnis","Informatika","Ekonomi","Akutansi"];
|
|
var desain = ["A","B","C","D"];
|
|
|
|
$('#fakultas').on('change', function() {
|
|
var fakultas = this.value;
|
|
$('#jurusan').empty().append('<option value="none">--Pilih Jurusan/Prodi--</option>');
|
|
var jurusan = [];
|
|
switch (fakultas) {
|
|
case 'Teknik' :
|
|
jurusan = teknik;
|
|
break;
|
|
case 'Manajemen' :
|
|
jurusan = manajemen;
|
|
break;
|
|
case 'Desain' :
|
|
jurusan = desain;
|
|
break;
|
|
}
|
|
$.each( jurusan, function( intValue, a ) {
|
|
$('#jurusan').append("<option value="+a+">"+a+"</option>");
|
|
});
|
|
});
|
|
|
|
//formaction
|
|
$('#canceledit').click(function() {
|
|
$('#edited').html(defau);
|
|
$('.middle, .right, .boxAvatar').foggy(false);
|
|
});
|
|
$('#formedit').submit(function(event) {
|
|
var formData = {
|
|
'name' : $('input[name=name]').val(),
|
|
'dob' : $('input[type=date]').val()
|
|
};
|
|
$.ajax({
|
|
type : 'POST',
|
|
url : 'profile.php?action=ajaxedit',
|
|
data : $(this).serialize(),
|
|
success : function(data) {
|
|
//alert(data);
|
|
if (data == 'sukses'){
|
|
alert('Update suskses');
|
|
location.reload();
|
|
}
|
|
}
|
|
});
|
|
event.preventDefault();
|
|
});
|
|
} |