Selasa, 30 Januari 2018

TWAIN, Accessing Scanner via Web (Windows as client)

I need to develop a web app that should access client's scanner via web.
Since the scanner is installed in client's PC, that means we should use Javascript to do this. The next question is, can javascript access the scanner ??? Unfortunately, javascript can not do that. That means there should be a third party software that is able to provide the scanner as a service. 

There are many good software for that, but most of them are not free. After browsed a while, I finally found someone who developed this software and share it for free.


Yup, its Scan AppForWeb. I have not tried this in my web app actually, but I have tried to install it and it seems good.

So after I read the README, it uses web socket to access the scanner. The Scanner can be accessed via ws://localhost:8181.

To install the software, download Scan_App_SetUp.msi and setup.exe or just download the ScanApps.zip and extract the file. After it installed, open cmd and check netstat -an.

And here is the result:

look at the third last line, the state of port 8181 is LISTENING. It looks really good.

Next, I'll post whether the Web Scanner works or not....hope it works...

Selasa, 23 Januari 2018

codeIgniter, removing index.php in url

source : https://situsali.com/belajar-codeigniter-3-dasar-routing/

The default URL used by CI contains "index.php". This bothers some of us.
So here is how I remove the "index.php" inside the URL.


  • Make sure mod_rewrite module in Apache is already activated. This can be checked in httpd.conf. This file can be found in xampp/apache/conf/httpd.conf. Find a line with this LoadModule rewrite_module modules/mod_rewrite.so. If there is a hashtag at the beginning of the line, remove it. 
  • Restart Apache, if it is necessary 
  • Create a .htaccess file inside the CI folder, at the same level with application directory, system directory, user_guide directory and so on. 
  • Insert this code inside .htaccess: 
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

  • Finally, go to application/config/config.php. Set the value of $config['index_page'] to '' (blank) --> $config['index_page'] = '';

That's it

Sabtu, 20 Januari 2018

Check whether javascript function exists

if(typeof clearToday !== 'undefined'){
      clearToday();
}

above will check if function clearToday exists before the function executed.

Storing Javascript value into PHP

Short note!
I'm programming a web app for a health clinic and I just had a problem to give a notification sound for the doctor if new patient registered.

I use SSE to update the list of the queuing patients. The number of the queuing patients will be reduced if one patient is served and added if a new patient registered. The notification sound should be ringed once when a new patient registered.

The question is, where should I put the update function since I save the header, the side menu and the body (content) separately.

If I put the update function in the body, the problem is I have to put the update function in every page. Well it is actually not a problem, it is just funny to put the same function in every page.

So I decide to put the function in the header, since every page uses the same header. The problem is wherever I browse through the web app, the notification sound just may only be ringed once!!!! That means, I have to store the current number of the queuing patients as a session variable. That is the solution, but the problem is how I can do that since the Javascript updating the number..???!!!!

For the record, Javascript is client side and php is server side. So it is imposible to save Javascript value into PHP, if I do it via Javascript. That is the second clue. I have to pass the Javascript value to PHP somehow and let the PHP stores the value to a session variable.

So this is how I do that:

  1. Storing: Use AJAX to pass the Javascript value to PHP
  2. Storing: Since I am using MVC, I make a function in Controller just for storing the value to a session variable.
  3. Fetching: Make a Javascript function to fetch the value of the session variable and call it on loading windows. Storing PHP value into Javascript variable should not be a problem. 
  4. Fetching: Put the AJAX function inside SSE and call it if the number of queuing patient is added.

Senin, 08 Januari 2018

Show all HTML DOM childNodes

Everything is node in HTML DOM. To make sure that we get the right childNode, we can show all the childNodes. It really helps everyone who is new with this (me as well).

Best example is shown by W3SCHOOL. It is the link.

Hope it can help you.