A Legend Back to Town (2013 - 2018)

It's been a while since my last post some years ago, but anyway... welcome home again. So, I'd like to talk about how curious I was on how PowerBI works that successfully lead me to develop a similar one (a super duper mini typically at least) for audit summary report purposed.

And now I'm proud to introducing this LiteBI® - a simple stand alone software to perform highlighted charts data from single drag and drop Excel file.


LiteBI® basically built from customized modules of SheetJs (https://github.com/sheetjs), LinqJS (https://lnkd.in/fHgrzHt) and Google Charts API (https://lnkd.in/fWjHwJF) based on ACFE (Association of Certified Fraud Examiners) report framework (http://www.acfe.com/).

And somehow - for the good news - it reveals the mistery of querying data under client side JavaScript. No more server side processing needed nor also the database! But of course for the bad news, there's 2 out of (at least) 30 charts and tabel must be done on this LiteBI® core 😨

Labels: , ,

  Post a Comment

nicEdit and Galleriffic: Great to Use!

Couple times ago, some readers of this blog gave me questions by email about is there any better client side text editor or the best slide show picture thumbnails available to put into their web based application? A lots! But just a few which absolutely flexible and more customizable. After researching in a weeks, finally I choose nicEdit for the best text editor and Galleriffic for the best slide show picture thumbnails. Both are jQuery based libraries and I succeeded using it in my latest online project on http://www.picanto-indonesia.com.

nicEdit
So what is so special about it? First, it has modern UI look of text editor similar to any word processor softwares with complete iconic built-in on top of it.


Secondly, this library is easy to use (even for beginner programmer I tough) since all I need is only to copy-paste the code with less modification to fit in the page (for example: the image upload function). The default image upload function in it's code is using imageshack.us server to store the files. Hence, for anyone who desire to move the image destination to their own server, there's available PHP plug-in file to use named as nicUpload.php. Just fill the target owned directory, included it in nicEdit.js and vice versa!


There's about no worry to inject the word we type in the edit box into the database, because we only take a single finalized variable to use. No more any securing function needed for this. And ... it's all free to use :)

Galleriffic
Hundreds of slide show plug-ins available on the net. It offering the same features; showing images with some effects. But a slide show without thumbnails and pagination means useless, after all, it's not a gallery. Based on it's name, Galleriffic offering a luxury features I described before. Although it's designed for flickr.com (CMIIW), it's modifiable to use to any web based software.


A small problem found when I need to fit the image in a specified size. Since flickr has 3 different file sizes (large, medium & small) after a picture uploaded, so I need to modifying and add a line in galleriffic.css file to make it fit in size from 1 image source.


So, problem is now solved. This gallery module look nice to see (even I need an additional blank space in bottom of it to handling a portrait type picture). That's it and ... thanks for reading. Have a good day :)

Labels: , ,

  Post a Comment

A Simple Way to Detecting Mobile Browser

Mobile browser is totally different from regular browser. There are several limitations why it so. For one reason, it has smaller screen to displaying the app and of course the mobile hardware it self. Such that, the interpreter in mobile browser are made in "mini-scale".

Tough, the mobile browser is designed to interpreting basic html only (not that complex as regular full web version) since it potentially affecting the performance of the mobile hardware or it may hung-up the device if they try to loading a large full web version.

The creator of custom site portal often create two kind of projects; full web version & mobile version. The mobile version is a limited version of regular one, which actually have some basic features in a basic display template.

There's an up-to-date documentation describing about mobile browser completely (including the engine inside) you can found in http://en.wikipedia.org/wiki/Mobile_browser.

Also, several ways you can get from Google to detecting wether the visitors come from regular browser or mobile device. You can use an .htaccess feature, custom PHP module, .NET mobile detector scripts, etc.

But here below a simple how-to detecting and forward the visitors which come from mobile device.

<title>Hello world</title>
Browser checking, please wait…
<hr>
<script type="text/javascript">
function isMobile() {
var index = navigator.appVersion.indexOf("Mobile");
return (index > -1);
}
</script>
<script>
if (isMobile()) document.location='http://m.yourdomain.com';
else document.location='http://www.yourdomain.com';
</script>


Yup, it only use a single line of Javascript syntax. So, if it's from mobile device then forward it to mobile version. But first, make sure that you should provide both different index file on both URLs. That's all!

Labels: , ,

  Post a Comment

Make DHTML more Dynamic with Java Applet

In a rarely cases, DHTML is not enough only with the use of Javascript. Some specific purpose in a web page just couldn't be supplied with it. Basically, Javascript has several limitations, especially in a page that need to retrieve information related to local machine resources.

Let say - for example - how to list printer names (on web based application) that installed locally in local machine? Without ActiveX object available in Windows & Internet Explorer browser, there is no option to gain with it. So, what's so special with "Dynamic" terms in DHTML if it stuck with specific OS's or browser? Please pay attention, Java Applet is the only key for the answer (multi-platform, multi-OS & multi-browser - theoretically :).

Well, I'm not a Java expert that order you to moved to become a Java programmer since my self is not included to the statement. Anyway - on this chance - I just tried to tells that "there's many ways to Rome", there's lots of things we can do to make our web page function properly accepted, but there's only a way to list printer name installed in local machine. Just spread up your creativity, make a R&D & your done! This article dedicated to peoples who follows Method 8 Framework & founder of jZebra (Hi, Tres. Looks like I need to modified the source :).

Before it started, imagine first: "I'm a new to Java programming, how can I make an applet?" and "Okay, I made it, so how can I embedded it to the page?" or "How can Java Applet communication with Javascript?"

As sequentially within the story, I'll share the answer. First of it, provide Netbeans & JDK installation file & configure it on your machine. Then, create an Applet project from Netbeans. On the example, I named both the project, class & java code with printName.

package printname;
import javax.print.PrintService;
import java.awt.print.PrinterJob;
import java.applet.Applet;
public class printName extends Applet {

public static void main(String[] args) {
String printerName;
printerName = menuList();
// just make a call to print out its value
System.out.println(printerName);
}

public static String menuList() {
// Lookup for the available print services.
PrintService[] printServices = PrinterJob.lookupPrintServices();

// Iterates the print services to a variable
String printerName = "";
for (PrintService printService : printServices) {
String name = printService.getName();
printerName = printerName + "#" + name;
}
return printerName;
}
}


Save & run above compiled code, you'll see that the applet will return a line of string of local printer name which separated with "#" character. Build & clean the code to make the JAR file.

Now, copy/upload the JAR file to the same folder where the HTML laid. Return to HTML editor & create a param tag to embed the JAR file. Also, create a dropdown select since we're gonna list that printer name from the applet to that object.

<html>
...
<script language="JavaScript">
function addOption(selectbox,text,value) {
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}

function removeAllOptions(selectbox) {
var i;
for(i=selectbox.options.length-1;i>=0;i--) {
selectbox.remove(i);
}
}

function fPrintName() {
var afPrintName = document.printName.menuList();
removeAllOptions(document.fInput.printerName);
addOption(document.fInput.printerName,'-- Pilih Printer --','');
if (afPrintName.length!=0) {
var namaPrinter = afPrintName.split('#');
n = namaPrinter.length;
for (var i=1; i<n; i++) {
addOption(document.fInput.printerName,namaPrinter[i],namaPrinter[i]);
}
}
}
</script>
<body onload="fPrintName();">
<applet name="printName" code="printname.printName.class" archive="printName.jar" width="1" height="1"></applet>
<form name="fInput">
<select name="printerName"></select>
</form></body>
...
</html>


Done, upload to the web server directory. Now, check your current printer from the control panel. There's 2 printers listed on my system.



Open your browser & locate to the html page. For the first usage, a standard permission window may appear since it need to confirm the security in the client side.




Finally, here come the result. The printer name now listed to the page.



CONCLUSION
The use of Java Applet on this case helping user to choose a selected printer name they want to print out with. It's useful to combine with jZebra since it only works with printer name that specified before. The Javascript core function located on fPrintName(). This function (first line -- document.printName.menuList()) purposed to communicate with the applet embedded in param tag, also to parse the string value returned from the applet. With 4kb of JAR executable size, this is so light-weight applet.

Labels: , , , ,

  Post a Comment

RAW Printing from Web Based Application

This is what I called a revolutionary for the web based application to handle RAW printing. Somehow, I found this Java applet named jZebra & it worked successfully as same as 16-bit console printing operation - the objective is prohibiting paper to rolled up one sheet full. Different with other extension “add-on” (eg: php_printer module on PHP) which is executed on server, jZebra operated on client side – since it Java based applet, you know it’ll depends on existing JRE package in each client. But - nevertheless - printing in a small paper (eg: receipt or bill) from web based application is not a problem anymore.

A couple years ago, I was thinking about to create a small win32 application purposed to take job RAW printing on LAN on here and there (with AssignPrn function available on Delphi), it’s done to print locally but unfortunately failed to handle network printing session – especially on non Windows machine (Linux ~ with CrossOver “limitation” capabilities). Anyway, you can read the online documentation of jZebra or try the sample directly provided over Google code page where it published for free.

On current article, I’d like to share about my experiment on exploring jZebra, including a short review and a bit modification of HTML page so that jZebra will have more flexible to use. Before continue reading this & decide to use it, I suggest you to read first of jZebra manual whether it suitable to your need or not.

At first, I try to create an HTML page, embed the applet – minor modification from the example - & store it on local Apache web server. The picture below explains what I’ve done above:



Image above shows jZebra initialization process. Once the applet executed, each & every browser will need a confirmation window to run Java applet. It signed by small loading logo rolling where the embed applet placed on a page.



When printer doesn’t exist, the applet will return fail code says that the printer is not yet ready. I switch back to Printer & Fax Control Panel & found that there’s no printer configured, while I still use FinePrint screen printing application as my default printer on my netbook.



Any printing process regarding to unsuccessful printer communication will raise failed information just like below picture.



For the experiment, I then rename the “FinePrint” printer name to “zebra



And … voila, the applet status says it ready.



Press print button & below picture display what’s happened on Windows printer status. You can see that the document name is “Java Printing”.



The printer on my experiment particularly used is LX-300 with USB plug cable. At the same time I press the Print button, the print will printing on paper directly & it stop to the end of string. It has exact behavior like DOS printing as I told before.



The above experiment I created from small modification of jZebra example. Note that information status as seen on above picture is based on AJAX, I decide to modified the source & use AJAX rather than manual common button (Detect Printer) for ease-of-use & compact source only. Below source define small part of index.html where I attach JavaScript main function:

...
<script type="text/javascript" src="js/jzebra.js"></script>
<body onLoad="detectPrinter()">

<table width="75%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr> <td colspan="2" bgcolor="#000000"><span id="printerStatusBar">Loading...</span></td></tr>
<tr> <td width="47%"><form name="form1" method="post" >
String untuk dicetak<br>
<textarea name="struk" cols="50" rows="7" id="struk"></textarea>
<br><input name="button" type=button onClick="printStruk(form1.struk.value)" value="Test Cetak">
<input name="button2" type=button onClick="print64()" value="Test Cetak (Base64)">
<input type="reset" name="Reset" value="Reset"></form></td>
<td width="53%">
<applet name="jZebra" code="jzebra.RawPrintApplet.class" archive="js/jzebra.jar" width="100" height="100">
<param name="printer" value="zebra">
<param name="sleep" value="200"></applet></td></tr></table>

While here below is the core of JavaScript function:

function detectPrinter()
{
var applet = document.jZebra;
if (applet != null)
{
applet.findPrinter("zebra");
while (!applet.isDoneFinding())
{
// Wait
}
var ps = applet.getPrintService();
if (ps == null) var info="Printer belum siap";
else var info="Printer \"" + ps.getName() + "\" siap";
}
else
var info="Java Runtime belum siap!";
document.getElementById("printerStatusBar").innerHTML=info;
window.setTimeout('detectPrinter()',5000);
}

function printStruk(str)
{
var applet = document.jZebra;
if (applet != null)
{
// Plain Text
str=returnEnter(str);
applet.append(str);
// Send to the printer
applet.print();
while (!applet.isDonePrinting())
{
// Wait
}
var e = applet.getException();
if (e == null) var info="Printed Successfully";
else var info="Error: " + e.getLocalizedMessage();
}
else
{
var info="Printer belum siap";
}
document.getElementById("printerStatusBar").innerHTML=info;
}

function returnEnter(dataStr)
{
return dataStr.replace(/(\r\n|\r|\n)/g, "\n");
}




From the above picture, the example page now contains a textarea input. This purposed for user to print what they enter on it. So that this prototype will more flexible to use, since each of HTML page only embedding the JavaScript core function when custom specified page need the RAW printing function. Have a good try & share your comment below.

Labels: , , , , ,

  Post a Comment

JavaScript: Return Multiple Values in Count Between Dates Function

JavaScript is one of parts that can’t be separated with web programming. Sometimes we usually depend on it, although we can solve the problem with another technique but the use of JavaScript is much helpful to support dynamic runtime application. For example manipulating or counting math is possibly without refreshing the page. Therefore, it is much simpler than AJAX. This article purposely dedicated to my self & any newbies which want to learn JavaScript methods.

Just like my own experience improving a page counting difference between two dates, here I found something new & I’d like to archived for me then share to you. The web page project it self are related to MySQL date field type & based on PHP programming. The subject was, how to calculate the year & month difference by both dates after the page loaded & once the date object is changed? As usual, I set the date interface with JavaScript so it would generate an interesting GUI just like common date object on Win32 programming.



Those dates GUI are compatible with date type format in MySQL (yyyy-mm-dd). When the date icon clicked, it will show small interactive calendar panel. The first date object I named with date_start, the second is date_end & sequentially, the difference year & month is n_year & n_month. The core date subtract function need 2 parameter dates & I created as well as it will return more than one value (year & month). On JavaScript, the treatment is put it on array mode. Pick out a small portion below:

function selisihTgl(dateEnd,dateStart)
{

return [yearAge, monthAge];
}


Displaying returned both value from function in array are simply called the array variable just like any others programming which is 0 based in bracket.

function fSelisih(sender)
{

obj.n_year.value=selisih[0]
obj.n_month.value=selisih[1]
}


That’s it, kinda simple isn’t it? By the way – unfortunately -, when dates changed, the date GUI object doesn’t have trigger event to call the function. So, I take <FORM> tag with onMouseMove event. Pretty dumb, but it works fine. Below is complete script from A to Z, check this out:

// portion of PHP code to retrieve both dates value from MySQL database
...
//
<HTML>
<HEAD>
<TITLE>Your Title Please</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
</HEAD>
<script language="JavaScript">
function selisihTgl(dateEnd,dateStart)
{
var baru = new Date(dateEnd.substring(0,4),
dateEnd.substring(5,7)-1,
dateEnd.substring(8,10));

var yearBaru = baru.getYear();
var monthBaru = baru.getMonth();
var dateBaru = baru.getDate();

var lama = new Date(dateStart.substring(0,4),
dateStart.substring(5,7)-1,
dateStart.substring(8,10));

var yearLama = lama.getYear();
var monthLama = lama.getMonth();
var dateLama = lama.getDate();

yearAge = yearBaru - yearLama;

if (monthBaru >= monthLama)
var monthAge = monthBaru - monthLama;
else
{
yearAge--;
var monthAge = 12 + monthBaru -monthLama;
}

if (dateBaru >= dateLama)
var dateAge = dateBaru - dateLama;
else
{
monthAge--;
var dateAge = 31 + dateBaru - dateLama;

if (monthAge < 0)
{
monthAge = 11;
yearAge--;
}
}

return [yearAge, monthAge];
}


function fSelisih(sender)
{
var obj=sender;
var selisih = selisihTgl(obj.date_end.value,obj.date_start.value);
obj.n_year.value=selisih[0]
obj.n_month.value=selisih[1]
}
</script>
<BODY onLoad="fSelisih(this)">
...
<form action="path/to/save/or/ignore/it" method="post" name="form1" onMouseMove="fSelisih(this)">
...
</form>
...
</BODY>
</HTML>


Don’t forget to insert the function within onLoad event on <BODY> tag to automatically count them expressly when the page are fully loaded.



Done! Enough for now lesson & I’ll be back with another unique tips & trick programming.

Labels: , , , , , , , ,

  Post a Comment