April 16 2018

CSS and Jquery Android click Ripple effect look like

Tagged Under : , ,

css3
Below are showing example Android click Ripple effect with CSS3 and Jquery.
Below was 2 example:
Example 1
Example 2

April 16 2018

MySQL week() function not correct display

Tagged Under :

MySQL
I am try gather some statistics from a database and it need group by week numbers. and the results return unexpected.
SELECT create_date, WEEK(create_date) as week FROM `ttable` 
+---------------------+-------------+
| craete_date         | week        |
+---------------------+-------------+
| 2018-01-02 00:00:00 |           0 | 
| 2018-04-10 00:00:00 |          14 | 
| 2018-03-13 00:00:00 |          10 | 
| 2018-03-30 00:00:00 |          12 | 
+---------------------+-------------+
From the above you will found that the week number was wrong. and MySQL counts the first days of the year that do not belong week 1 as week 0.

This is because MySQL default week() function caused the issue. because in MySQL the first day of week is Sunday and it range was 0 to 53 weeks. And you need change the MySQL mode with the below table.

January 14 2018

IONIC 3 display config.xml version number on APP

Tagged Under :

ionic
To use config.xml version number on APP. you need install APP VERSION with npm.

To display the version number on APP.
this.platform.ready().then(() => {
	this.appVersion.getVersionNumber().then((value) => {
		var value = value.replace(/"/g, '');
		this.version = 'v'+value;
	})
});
and then put {{version}} where you want to display in html page.

and the output will be like this v1.0.1

January 14 2018

IONIC 3 dynamic loading control content or text

Tagged Under :

ionic
In IONIC 3 LoadingController you can set the content or text in starting. But if the loading is for getting information from many place and you want to display how many percent was completed or the process until which step.
this.loading = this.loadingCtrl.create({content: 'Please wait...'});

October 03 2017

Javascript display money format

Tagged Under :

javascript
Sometimes we need using javascript to display money format in our system but javascript don’t have this kind of function. So we need to write a function to convert number to money format.

October 02 2017

Javascript get compass direction with the two longitude and latitude

Tagged Under : ,

ionic
Just develop a project with IONIC and google map to tracking the transport routing. Because the google map wouldn’t rotate itself when the transport moving. It will confuse the user when they look at the map.

So I need to rotate the map to let navigation always facing to top. It will easy user to understand when they look at the map.

July 18 2017

Yii2 set wraptext on moonlandsoft phpexcel

On phpexcel you are allow to set “setWrapText(true)” property. but on Yii2 plugin moonlandsoft phpexcel it don’t have this property.

To set this property. you need to add extra code on the plugin.
Open Excel.php file. and then scroll to line 387 add the code below.
if (isset($column['wraptext']) &&  $column['wraptext'] == true) {
	$activeSheet->getStyle($col.$row)->getAlignment()->setWrapText(true);
}

March 26 2017

Jquery set focus on last character in input text box

Tagged Under :

javascript
Normally using Jquery or Javascript to set focus on input box it will point to beginning of the text box. But if you want it point to last character in input text box. you may need write a Jquery class to do.

Below is the Jquery function:
(function($){
    $.fn.focusTextToEnd = function(){
        this.focus();
        var $thisVal = this.val();
        this.val('').val($thisVal);
        return this;
    }
}(jQuery));

You may easy to use the function like below
$("#input").focusTextToEnd();

January 04 2017

Cron with wget always created an empty file on server

Tagged Under :

Linux
I am trying to write a cron task to call wget on a url. The cron runs fine, but every time it runs it will creates a cron.php.X file in my home directory. I’ve tried to turn off output using the –quiet option but it’s still outputting a new file with every running.

December 13 2016

Jquery validation validate money method function

Tagged Under :

javascript
Jquery validation itself didn’t give money validate method function. What we can to do is write a custom method to validate the money format with regular expression.

Below is the money validate method.
jQuery.validator.addMethod(
    "money",
    function(value, element) {
        var isValidMoney = /^\d{0,4}(\.\d{0,2})?$/.test(value);
        return this.optional(element) || isValidMoney;
    },
    "Insert "
);