Thursday, July 6, 2017

Custom Google Map

function InitiallizeMap(){
 var myLatLng = new google.maps.LatLng(-33.903236,151.142783);
 var myOptions = {
  zoom: 16,
  center: myLatLng,
  mapTypeId: google.maps.MapTypeId.ROADMAP,
  mapTypeControl: false,
  zoomControl:false,
  streetViewControl:false,
 }
 var styles = [
  {
   "stylers": [
    { "invert_lightness": true },
    { "saturation": -47 },
    { "lightness": -9 }
   ]
  },{
   "featureType": "road",
   "stylers": [
    { "saturation": -91 },
    { "lightness": 25 },
    { "gamma": 0.92 }
   ]
  }
 ];

 
 var image = '/images/img_map-overlay-icon.png';
 var map = new google.maps.Map(document.getElementById("googleMap"),myOptions);
 var marker = new google.maps.Marker({
    position: new google.maps.LatLng(-33.903236,151.142783),
    map : map,
    icon: image
 });
 map.setOptions({styles: styles});
 google.maps.event.addListener(marker,'click', function() {
  window.open("https://maps.google.com/maps?q=The+Hub+House,+412+New+Canterbury+Road,+Dulwich+Hill,+NSW,+2203,+Australia&hl=en&ll=-33.903245,151.142778&spn=0.00976,0.021007&sll=-33.903485,151.143653&sspn=0.00244,0.005252&oq=hub410-412+New+canterbury+Road,Dulwich+hill.+NSW+2203&hq=The+Hub+House,&hnear=412+New+Canterbury+Rd,+Dulwich+Hill+New+South+Wales+2203,+Australia&t=m&z=16");   
 });  
}

Thursday, February 9, 2017

php search in a multi dimensional associative array

function in_array_r($needle, $haystack, $strict = false) {
foreach ($haystack as $key => $item) {
if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) {
return (object) $haystack[$key];
}
}
return false;
}

Input Amount jQuery Plugin

/*
Name:input_amount
Author:Reyneil Lato
Date:February 09, 2017
Time:04:47PM
Version:1.0
Description: amount formatter
*/

(function($){
$.fn.input_amount = function(options) {
// defaults
var defaults = {
decimal : 2
};  
var options = $.extend(defaults, options);
return this.each(function(){
jQuery(this).on("keypress keyup blur keydown",function(event) {
var t = jQuery(this).val();
// prevent letters and arrow
if((event.which >= 65 && event.keyCode <= 90) || (event.which >= 37 && event.which <= 40) || event.which == 32){
event.preventDefault();
}

// only 1 decimal point and 2 decimal places
if(t.indexOf(".") != -1){
var dec = t.toString().split(".");
if((event.which == 190 || event.which == 110) || (dec[1].length >= parseInt(options.decimal) && event.which != 8)){
event.preventDefault();
}
}

// format with commas every 3 digit
jQuery(this).val(function(index, value) {
var c = value.toString();

if(c.indexOf(".") != -1){
var x = c.split(".");
x[0] = x[0].toString().replace(/,/gi, "");
x[0] = x[0].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");

return x.join(".");
}
else{
var z = c.toString().replace(/,/gi, "");
z = z.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return z;
}
});
});
});
};
})(jQuery);

Wednesday, February 8, 2017

revert old firebug

browse
about:config

search
browser.tabs.remote.autostart,
browser.tabs.remote.autostart.1
browser.tabs.remote.autostart.2

and change all values to false

jQuery input amount format

jQuery(selector).on("keypress keyup blur keydown",function(event) {
var t = jQuery(this).val();
// prevent letters and arrow
if((event.which >= 65 && event.keyCode <= 90) || (event.which >= 37 && event.which <= 40) || event.which == 32){
event.preventDefault();
}

// only 1 decimal point and 2 decimal places
if(t.indexOf(".") != -1){
var dec = t.toString().split(".");
if((event.which == 190 || event.which == 110) || (dec[1].length >= 2 && event.which != 8)){
event.preventDefault();
}
}

// format with commas every 3 digit
jQuery(this).val(function(index, value) {
var c = value.toString();

if(c.indexOf(".") != -1){
var x = c.split(".");
x[0] = x[0].toString().replace(/,/gi, "");
x[0] = x[0].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");

return x.join(".");
}
else{
var z = c.toString().replace(/,/gi, "");
z = z.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return z;
}
});
});