Selasa, Maret 29, 2011

JQuery : Tooltip and Image Preview

Case : You want to create cool tooltip or image preview from your thumbnail
Solution : JQuery
Script :

this.imagePreview = function(){
/* CONFIG */

xOffset = 10;
yOffset = 30;

// these 2 variable determine popup's distance from the cursor
// you might want to adjust to get the right result

/* END CONFIG */
$("a.preview").hover(function(e){
this.t = this.title;
this.title = "";
var c = (this.t != "") ? "
" + this.t : "";
$("body").append("

Image preview"+ c +"

");
$("#preview")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
.fadeIn("fast");
},
function(){
this.title = this.t;
$("#preview").remove();
});
$("a.preview").mousemove(function(e){
$("#preview")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px");
});
};

// starting the script on page load
$(document).ready(function(){
imagePreview();
});


Source : http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery

PHP : Auto Resize Image on Upload

Case : you want to resize image on upload
Solution : PHP imagecopyresampled
Script :

if ($_SESSION[username_administrasi] != "" && $_POST[submit] == "Simpan") {
$cek = cek("select * from ktp where no_ktp = '$no_ktp' and npwp = '$npwp' ");
if ($cek > 0) {
alert("Data sudah ada !");
loncat("../index.php");
} else {
$tmp_filename = $_FILES[file1][tmp_name];
$filename = $_FILES[file1][name];
$file = explode(".",$filename);
$nama_file = $file[0];
echo $nama_file;
list($old_width, $old_height, $type, $attr) = getimagesize($tmp_filename);
if ($type == 1 || $type == 2 || $type == 3) {
if (($_FILES["file1"]["size"]/1024) > 250) {
if ($type == 1) {
$new_image = imagecreatefromgif($tmp_filename);
} else if ($type == 2) {
$new_image = imagecreatefromjpeg($tmp_filename);
} else if ($type == 3) {
$new_image = imagecreatefrompng($tmp_filename);
}

echo "
width asli = ".$old_width;
echo "
height asli = ".$old_height;
$new_width = 800;

if ($old_width > $old_height) {
$percentage = ($new_width / $old_width);
} else {
$percentage = ($new_width / $old_height);
}

$new_width = round($old_width * $percentage);
$new_height = round($old_height * $percentage);

echo "
width resize = ".$new_width;
echo "
height resize = ".$new_height;

echo "
".$_FILES[file1][type];
echo "
".$_FILES[file1][size];


if (function_exists(imagecreatetruecolor)){
$resized_img = imagecreatetruecolor($new_width,$new_height);
}else{
die("Error: Please make sure you have GD library ver 2+");
}

imagecopyresampled($resized_img, $new_image, 0, 0, 0, 0, $new_width, $new_height, $old_width, $old_height);

if ($type == 1) {
imagegif($resized_img,"../images/uploaded/tumb_".$nama_file.".gif");
} else if ($type == 2) {
imagejpeg($resized_img,"../images/uploaded/tumb_".$nama_file.".jpg");
} else if ($type == 3) {
imagepng($resized_img,"../images/uploaded/tumb_".$new_image.".png");
}

$move = move_uploaded_file($_FILES['file1']['tmp_name'], '../images/uploaded/real_'.$filename);

ImageDestroy ($resized_img);
ImageDestroy ($new_image);

loncat("../index.php");
} else {

$move = move_uploaded_file($_FILES['file1']['tmp_name'], '../images/uploaded/real_'.$filename);

if ($move) {
alert("Upload sukses.");
} else {
alert("Upload gagal.");
}
loncat("../index.php");
}
} else {
alert(" Tipe file yang diijinkan : GIF, JPG, JPEG, PNG");
//loncat("../index.php");
}
}
}



Source : http://www.php.net/

Jumat, Maret 25, 2011

Blogger : Show hide Guestbook/Shoutbox/Shoutmix

Script CSS :

#gb{
position:fixed;
top:50px;
z-index:+1000;
}
* html #gb{position:relative;}
.gbtab{
height:200px;
width:30px;
float:left;
cursor:pointer;
background:url("http://purwomartono.googlepages.com/slider_shoutmix.gif") no-repeat;
}
.gbcontent{
float:left;
border:5px solid #000000;
background:#FFFFFF;
padding:5px;
}


Script Javascript :

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-4639370-4']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

window.google_analytics_uacct = "UA-4639370-4";

function showHideGB(){
var gb = document.getElementById("gb");
var w = gb.offsetWidth;
gb.opened ? moveGB(0, 30-w) : moveGB(20-w, 0);
gb.opened = !gb.opened;
}
function moveGB(x0, xf){
var gb = document.getElementById("gb");
var dx = Math.abs(x0-xf) > 10 ? 5 : 1;
var dir = xf>x0 ? 1 : -1;
var x = x0 + dx * dir;
gb.style.right = x.toString() + "px";
if(x0!=xf){setTimeout("moveGB("+x+", "+xf+")", 10);}
}

var gb = document.getElementById("gb");
gb.style.right = (30-gb.offsetWidth).toString() + "px";



Source html :







ShoutMix chat widget






Source : http://rtn-alwaysforyou.blogspot.com/2010/08/membuat-show-hide-guestbook.html? kiss

Senin, Maret 21, 2011

JQuery : Autocomplete extraParams

Case : You want to create an autocomplete that depends on another fields
Solution : Using JQuery Autocomplete with extraParams
Script :


$("#ProvinsiCalonSuami").autocomplete("actions/autocomplete.php?p=provinsi", {
max: 100,
width: 260,
selectFirst: true,
});

$("#KabupatenCalonSuami").autocomplete("actions/autocomplete.php?p=kabupaten", {
max: 100,
width: 260,
selectFirst: true,
extraParams: {
provinsi: function(){
return $('#ProvinsiCalonSuami').val();
}
}
});

$("#KecamatanCalonSuami").autocomplete("actions/autocomplete.php?p=kecamatan", {
max: 100,
width: 260,
selectFirst: true,
extraParams: {
kabupaten: function(){
return $('#KabupatenCalonSuami').val();
}
}
});

$("#KelurahanCalonSuami").autocomplete("actions/autocomplete.php?p=kelurahan", {
max: 100,
width: 260,
selectFirst: true,
extraParams: {
kecamatan: function(){
return $('#KecamatanCalonSuami').val();
}
}
});
Source : http://docs.jquery.com/Plugins/autocomplete

Sabtu, Maret 19, 2011

JQuery : Autocomplete not working more than 10 rows

Case : You are using JQuery autocomplete, but the data cannot display more than 10 rows
Solution : using option "Max"
Script :

$().ready(function() {
$("#targetDiv1").autocomplete("actions/autocomplete.php?p=provinsi", {
max: 100,
width: 260,
selectFirst: false,
});

$("#targetDiv2").autocomplete("actions/autocomplete.php?p=kabkota", {
max: 100,
width: 260,
selectFirst: false,
});

$("#targetDiv3").autocomplete("actions/autocomplete.php?p=kecamatan", {
max: 100,
width: 260,
selectFirst: false,
});
});

Selasa, Maret 15, 2011

Javascript : getElementById inside looping For

Mikir gini habis seharian


function formValidator(numrows,jumlah_soal) {
var id_soal = "";
if (numrows < jumlah_soal) {
var x = jumlah_soal;
} else {
var x = numrows;
}

for (var i=1;i<=x;i++) {
var id = document.getElementById("id_soal_"+i).value;
if (id_soal == "") {
var id_soal = id;
} else {
var id_soal = id_soal+', '+id;
}
}

$.post("actions/soal_simpan.php", { id: id_soal} );
window.location.href = "index.php?p=soal_create";
window.open("cetak/soal_simpan.php?id_soal="+id_soal,"print","width=800,height=400px,scrollbars=yes");
}

Install Office 2003 dan Office 2007

http://uksbsguy.com/blogs/doverton/archive/2007/07/21/how-to-get-rid-of-the-installer-configuration-dialog-when-running-office-2007-and-office-2003-on-the-same-system-for-vista-and-other-versions-of-windows.aspx


reg add HKCU\Software\Microsoft\Office\11.0\Word\Options /v NoReReg /t REG_DWORD /d 1
reg add HKCU\Software\Microsoft\Office\12.0\Word\Options /v NoReReg /t REG_DWORD /d 1

reg add HKCU\Software\Microsoft\Office\11.0\Excel\Options /v NoReReg /t REG_DWORD /d 1
reg add HKCU\Software\Microsoft\Office\12.0\Excel\Options /v NoReReg /t REG_DWORD /d 1

Rabu, Maret 09, 2011

JQuery : Reload whole page

Case : You want to reload whole page after add/edit/delete data
Solution : JQuery
Script :


function update(id,tanggal,keterangan,pengeluaran) {
//alert(id + ' ' + tanggal + ' ' + keterangan + ' ' + pengeluaran);
var keterangan = keterangan;
if (confirm('Yakin mau diedit ???')) {
$.post('actions/pengeluaran_edit.php', {id_pengeluaran: +id, tanggal: tanggal+'', keterangan: keterangan, pengeluaran: +pengeluaran, ajax: 'true' },
function(){
location.reload();
});
}
}


Source : http://www.jquery.com/

JQuery : Delete row without reload whole page

Case : You want to delete row of data without reload whole page
Solution : Use JQuery
Script :

function hapus(id){
if (confirm('Yakin mau dihapus ???')) {
$.post('actions/hapus_pengeluaran.php', {id: +id, ajax: 'true' },
function(){
$("#row_"+id).fadeOut("slow");
$('#total_pengeluaran').load('index.php?p=pengeluaran_list #total_pengeluaran');
$('#total_saldo').load('index.php?p=pengeluaran_list #total_saldo');
$('#total_pendapatan').load('index.php?p=pengeluaran_list #total_pendapatan');
});
}
}


Source : http://jquery.com/

Blogspot : Desain themes for adsense

Sample blogspot design themes for adsense :


http://hotbookmark.blogspot.com

























http://nyangkem.blogspot.com/

























http://devjobs-indonesia.blogspot.com/

http://formulaone-mania.blogspot.com/
http://motogpmaniax.blogspot.com/

Senin, Maret 07, 2011

Batch File : Repacking XAMPP

Case : You want to repack xampp to fit your web based application.
Solution : Combine with this, and you will have XAMPP custom installation

@ECHO OFF & SETLOCAL
PUSHD %~dp0

ECHO Mohon untuk sabar menunggu...
ECHO Install Apache masuk ke service Window dulu
xampp_cli.exe installservice apache

@ECHO:
@ECHO:

IF NOT ERRORLEVEL 1 (
ECHO Sekarang memulai Apache :)
xampp_cli.exe startservice apache
)

@ECHO:
@ECHO:

ECHO Mohon untuk sabar menunggu...
ECHO Install MySQL masuk ke service Window dulu
xampp_cli.exe installservice mysql

@ECHO:
@ECHO:

IF NOT ERRORLEVEL 1 (
ECHO Sekarang memulai MySQL :)
xampp_cli.exe startservice mysql
)

@ECHO:
@ECHO:

ECHO Mohon untuk sabar menunggu...
ECHO Install Shortcut ke desktop
copy [your_file_name] "%userprofile%\desktop"

@ECHO:
@ECHO:

ECHO Sabar... Install Firefox kalo belum ada, upgrade kalo sudah ada.
ECHO Tunggu sampai instalasi Firefox selesai, dan window ini akan menutup sendiri :)

@ECHO:
@ECHO:

ECHO Terima kasih

Firefox.exe

exit(1)



Source : http://www.google.com/

Jumat, Maret 04, 2011

Yulgang Online : BOT

Case : You want to play yulgang but too lazy to type on your keyboard, click your mouse, and stare at your monitor for a couple hours setan
Solution : use QuickMacro to bot


//Script mulai
VBS dim darah,mana,darahT,manaT
//pendefinisian variable
//gunakan quick macro pick tool untuk mendapatkan nilai (x1,x2,y,color)
UserVar darah=30 If HP<darah%, supply HP
UserVar mana=30 If MP<mana%, supply MP
UserVar darahT=256 Delay setelah mengisi darah(in milliseconds)
UserVar manaT=256 Delay setelah mengisi mana(in milliseconds)
Rem Begin
Delay 50
//Delay untuk meringankan kinerja CPU
Rem HP
//IfColor hong/100*(x2-x1)+x1 y color 2
IfColor darah/100*(45-30)+30 13 313429 2
//x2=Sisi kanan bar HP, x1=Sisi kiri bar HP
//y=Y axis dari center bar HP, color=warna ketika bar HP kosong
KeyPress 115,1
//Tombol Pot
Delay darahT
//Delay setelah mengisi HP
EndIf
Rem MP
IfColor mana/100*(45-30)+30 26 313429 2
//x2=Sisi kanan bar MP, x1=Sisi kiri bar MP
//y=Y axis dari center bar MP, color=warna ketika bar MP kosong
KeyPress 116,1
//Tombol Gingseng
Delay manaT
//Delay setelah mengisi MP
EndIf
Rem Target
MiddleClick 1
Delay 500
Rem Hit
KeyPress 113,1
//Tombol Skill F9
Delay 100
Rem Pick
KeyPress 120,1
Goto Begin
//script selesai

";})();ButtonMouseDown(this);'>

Source : http://sarifuddin-sarif.blogspot.com/2010/03/macro-bot-for-yulgang-online.html