This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Kamis, 30 September 2010

JQuery : get HTML Content of object

JQuery : get HTML Content of object
We can get html content of Jquery object by using html(), this method will return child content of the object. So the workaround is wrap object into any element and get the element child :)


var html = $("<div>").append( $("#some_div").clone()).html();

Ok. That's obviously simple right ? Happy Coding!

Codeigniter : Melihat Query untuk debug

Sumber : http://codeigniter.com/forums/viewthread/96428/

Before the query runs:

Echo $this->db->_compile_select(); 

And after it has run:

Echo $this->db->last_query(); 

User specific Javascript timer

Long time ago i only know cron or task scheduler and javascript timer to do scheduled process. A few days ago i realize that i can do scheduled task using specific user, in this case i can use admin user
to do specific task that suppose to be runned only by admin. Well, i can use this for anything i guest including game engine.

Rabu, 29 September 2010

JasperReport Export ke Text

Sumber Tulisan : http://www.coderanch.com/t/62982/open-source/Jasper-Report-Text-Exporter

JRTextExporter uses a very smart algorithm to convert reports in graphics to reports in text. It first creates a virtual text grid based on your report's size and the character dimensiona given to the exporter. Then it places each individual item to the text grid based on the item's location in pixels. 

There are three very important parameters effecting how the exporter converts the output 

1- Width and Height of the reports in pixels 
2- Widths and Heights of the individual report elements (labels etc.) 
3- Character Width and Height parameters of the exporter 


To fit the report to the text grid, you need to make a simple calcuation: 

First find the maximum number of characters that can be fit to a row when you would print the report in text (Let's assume that it is 80 characters long and call this number MAX_CHAR_PER_ROW). 
Then find the maximum number of characters that can be fit to a column when you would print the report in text (Let's assume that it is 44 characters height and call this number MAX_CHAR_PER_COL). 


Then Divide your reports dimensions with these numbers to find the character height and width. LEt's assume the dimensions of the report are REPORT_WIDTH and REPORT_HEIGHT and the corresponding values are 524 and 524. Now the characters dimensions are calculated as: 


CHAR_WIDTH = REPORT_WIDTH / MAX_CHAR_PER_ROW 
CHAR_HEIGHT = REPORT_HEIGHT / MAX_CHAR_PER_COL 

CHAR_WIDTH = 524 / 80 = 6.55 
CHAR_HEIGHT = 524 / 44 = 11.9 


Of course, the resulting values will not be integers most of the time. Then if you want a perfect match, CHAR_WIDTH and CHAR_HEIGHT must be floating numbers. But the original exporter only accepts integers parameters. At this point, use my modified exporter here. I already converted these parameters to float. 

Here is how you may send character dimensions to the exporter. 


exporter.setParameter(JRTextExporterParameter.CHARACTER_WIDTH, new Float(6.55));//6.55 //6 
exporter.setParameter(JRTextExporterParameter.CHARACTER_HEIGHT, new Float(11.9)); //11//10 



Another notice! Make sure that CHAR_HEIGHT is not lower that the actual heights of the report items. Otherwise, the items will not added to the grid since the exporter truncates their heights to 0 because of the arithmetic operation inside the exporter. Another solution would be using rounding instead of truncation by modifying the exporter a little more. Anyway, I did not need that feature since the character height is ok for my case. 


/** 
* Transforms y coordinates from pixel space to character space. 
*/ 
protected int calculateYCoord(int y) 


int result = Math.round((float)pageHeight * y / jasperPrint.getPageHeight()); 

return result; 


/** 
* Transforms x coordinates from pixel space to character space. 
*/ 
protected int calculateXCoord(int x) 


int result = Math.round((float)pageWidth * x / jasperPrint.getPageWidth()); 

return result; 


Selasa, 28 September 2010

jQuery Dialog Example

$("#new_config").dialog

({ autoOpen: false,

     height:400,

     width:400,

     resizable:false,

     modal:true

});


 

<!--- Dialog Box start --->

<div
id="new_config"
title="Dialog Title"
style='width:400px;height:300px;display:none;'>

<div
style="padding:3px 0">

<strong
id="dialog_title"></strong>

<!-- content -->

<div
id="tabcontent_newconfig">

<!—your conten -->

</div>

<!-- content -->

</div>

</div>

<!--- Dialog Box end --->

Jquery $.post Example

function saveItem()

{


var mod_name = $("#module_name").val();

    var item_name = $("#item_name").val();

    var item_val = $("#item_value").val();

    var desc = $("#desc").val();

    var id = $("#id_item").val();


 

    json = "{\"module\":\"" + escape(mod_name) +


"\",\"name\":\"" + escape(item_name) +


"\",\"value\":\""+ escape(item_val) +


"\",\"desc\":\""+ escape(desc) +


"\",\"id\":\""+ id +


"\"}";


 

config_url = _base_url + "/index.php/admin/gconfig/save";

$.post(config_url,{data:json},function(result){


if(result)

{


//alert(result);

resetForm();


 


//reload only selected mod

url_reload = "url:"+ _base_url +"/index.php/admin/gconfig/index_json/"+ mod_name +"}";

    $("#table_flex0").flexReload();

}

});


 

$("#new_config").dialog('close');

    

}

Kamis, 23 September 2010

Library Codeigniter yang utama

Dari http://geshan.blogspot.com/2010/03/3-codeigniter-libraries-that-will-make.html

EzAuth : Authentikasi – mending pake lib orang deh daripada buat ulang :p
Ocular : Templating
DataMapper : ORM

Untuk project selanjutnya pake ini aja. ;)

Mixed Content untuk mengabaikan pesan “only secure content”

ie user mixed content nya enabled

Rabu, 22 September 2010

Memodifikasi Flexigrid QuickSearch button agar tidak muncul di bar bawah

  1. Tambahkan beberapa parameter baru di flexigrid options. Set nilai default agar compatible dengan behavior asli flexigrid


     

    showQuickSearch: true,

    quickSearchatTop: false,

    quickSearchatBottom: true,    


     

  2. Modifikasi kode yang memuat if(p.searchitems) menjadi


     

                //add search button

                if(p.showQuickSearch)

                {

                    if(p.quickSearchatBottom)

                    {

                        if (p.searchitems)

                        {

                            $('.pDiv2',g.pDiv).prepend("<div class='pGroup'> <div class='pSearch pButton'><span></span></div> </div> <div class='btnseparator'></div>");                        

                            $('.pSearch',g.pDiv).click(function(){$(g.sDiv).slideToggle('fast',function(){$('.sDiv:visible input:first',g.gDiv).trigger('focus');});});                

                            

                            //add search box

                            g.sDiv.className = 'sDiv';

                            

                            sitems = p.searchitems;

                            

                            var sopt = "";

                            for (var s = 0; s < sitems.length; s++)

                            {

                                if (p.qtype=='' && sitems[s].isdefault==true)

                                {

                                p.qtype = sitems[s].name;

                                sel = 'selected="selected"';

                                } else sel = '';

                                sopt += "<option value='" + sitems[s].name + "' " + sel + " >" + sitems[s].display + "&nbsp;&nbsp;</option>";                        

                            }

                            

                            if (p.qtype=='') p.qtype = sitems[0].name;

                            

                            $(g.sDiv).append("<div class='sDiv2'>Quick Search <input type='text' size='30' name='q' class='qsbox' /> <select name='qtype' id='qtype'>"+sopt+"</select> <input type='button' value='Clear' /></div>");


     

                            $('input[name=q],select[name=qtype]',g.sDiv).keydown(function(e){if(e.keyCode==13) g.doSearch()});

                            $('input[value=Clear]',g.sDiv).click(function(){$('input[name=q]',g.sDiv).val(''); p.query = ''; g.doSearch(); });

                            $(g.bDiv).after(g.sDiv);                

                            

                        }

                    }

                    

                    

                    if(p.quickSearchatTop)

                    {

                        if (p.searchitems)

                        {

                            g.sDiv.className = 'sDiv';                        

                            sitems = p.searchitems;

                            

                            var sopt = "";

                            for (var s = 0; s < sitems.length; s++)

                            {

                                if (p.qtype=='' && sitems[s].isdefault==true)

                                {

                                p.qtype = sitems[s].name;

                                sel = 'selected="selected"';

                                } else sel = '';

                                sopt += "<option value='" + sitems[s].name + "' " + sel + " >" + sitems[s].display + "&nbsp;&nbsp;</option>";                        

                            }


     

                            $('.tDiv2').append("<div class='btnseparator'></div><div class='fbutton_x'><span style='padding-left: 2px;padding-right:2px;'><label></label><input type='text' size='30' name='q' class='qsbox' style='color:#999999;' value='Quick Search'/> <select name='qtype' id='qtype'>"+sopt+"</select> <input type='button' value='Clear' /></span></div>");

                            if (p.qtype=='') p.qtype = sitems[0].name;                        

                            $('input[name=q],select[name=qtype]',g.tDiv).keydown(

                                function(e){

                                    if(e.keyCode==13)

                                    {

                                        //satiri @ 22-09-2010

                                        //add timeout to support update in .qsbox

                                        setTimeout(

                                            function(){g.doSearch();},

                                            200

                                        );

                                    }

                            });

                            

                            $(".qsbox").click(function(){

                                if($(this).val()=="Quick Search"){

                                    $(this).val("");

                                    $(this).css("color","#000000");

                                }

                            });

                            

                            $(".qsbox").mouseout(function(){

                                if($(this).val()==""){

                                    $(this).val("Quick Search");

                                    $(this).css("color","#999999");

                                }

                            });

                            

                            $('input[value=Clear]',g.tDiv).click(function(){

                                    $('input[name=q]',g.tDiv).val('');

                                    

                                    $(".qsbox").val("Quick Search");

                                    $(".qsbox").css("color","#999999");

                                    

                                    p.query = '';

                                    g.doSearch();

                            });                                        

                            

                        }

                    }

                    

                }

membuat flexigrid quicksearch menunggu


if(e.keyCode==13)
{
//satiri @ 22-09-2010
//add timeout to support update in .qsbox
setTimeout(
function(){g.doSearch();},
200
);
}

Contoh Jquery Autocomplete dengan parameter extra

ctype = $("#qtype").val();
$(".qsbox").autocomplete(_base_url + "/index.php/personnel/main/get_data/",
{
extraParams : {ctype : function(){
return $("#qtype").val();
}
},
dataType : "json",
maxItemsToShow : 10,
formatItem: false,
retrieveComplete : function(data){
if(data!="0"){
return data;
}
},
onItemSelect : function(li,row)
{
$(".qsbox").val(row);
}
});

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More