Debug mobileweb in device

Posted: September 15, 2015 in HTML

1) Install nodeJs using msi installer: https://nodejs.org/en/
2) Go to command line and check if its installed or not using: npm -v
3) Install weinre using below command: npm install –g weinre
4) Run ipconfig command and note your IPv4 address.
5) Run the debugging server using your dev machine: weinre –boundHost 10.12.0.1
6) Once you run above command it will give you weinre URL like http://10.12.0.1:8080, run that url in browser
7) Under “Target Script” you will find <script>.., copy that line in your mobileweb code.
8) Under “Access Points”, click on “debug client user interface” i.e. http://10.12.0.1:8080/client/#anonymous
9) Now, once you run your mobileweb

Reference: http://people.apache.org/~pmuellr/weinre-docs/latest/Installing.html

Below is one simple function that saves my required json in localstorage using JavaScript array.


function saveMyJson(key,value)
{

// initialise array
var myObj = {};

// get existing json from local storage
if(localStorage.getItem('my_json') != null)
myObj = JSON.parse(localStorage.getItem('my_json'));

// add element in json by key-value pair
eval("myObj['" + key + "'] = \""+ value + "\"; ");

// set updated json in local storage
localStorage.setItem('my_json', JSON.stringify(myObj));

}

 

How to add line break in body for mailto

Posted: August 13, 2015 in HTML, PHP
Tags:

// PHP code

$email = 'myemail.domain.com';
$subject = addslashes("This is Subject: Let's check it...!!!");
$body = addslashes("This is message area. \r\n My Second line...Let's check it...!!!"); // body comes from text area so will have \r and \n
$body = str_replace(array("\r\n","\r","\n"),'%0D%0A',trim($body));

// HTML Code



<a onclick="mailto:<?=$email;?>?subject=<?=$subject;?>&body=<?=$body;?>" >Click here to email me</a>


Pass smarty variable to php code

Posted: July 22, 2014 in PHP
Tags:

If you want to do some complex php operation in smarty tempelate file then you can pass your smarty variable to {php} tags by following manner and then can add your login between {php} tags.


{assign var="currentName" value=`$one.name`}

{php}

echo $currentName = $this->get_template_vars('currentName');

{/php}

WAMP curl not working in local pc

Posted: July 16, 2014 in PHP
Tags: , ,

1) Enable curl extension in both php.ini ( file location shown below)

extension=php_curl.dll

D:\wamp\bin\php\php5.3.13\php.ini

D:\wamp\bin\apache\apache2.2.22\bin\php.ini

2) Download php_curl.dll from below link and replace it in D:\wamp\bin\php\php5.3.13\ext.

If your PHP version is 5.3.14 then download “php_curl-5.3.14-VC9-x64.zip” from http://www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/ under  ‘Fixed curl extensions‘ .

 

Wamp disable orange xdebug errors

Posted: June 30, 2014 in PHP
Tags:

Find following line in php.ini and comment that line and restart wamp.

;zend_extension = “d:/wamp/bin/php/php5.3.13/zend_ext/php_xdebug-2.2.0-5.3-vc9-x86_64.dll”


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example</title>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=KEY&sensor=true"
type="text/javascript"></script>
<script type="text/javascript">

function initialize()
{
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(23.005, 72.5959), 15);
map.setUIToDefault(); // will add top menu,left menu etc

var marker = new GMarker(new GLatLng(23.005, 72.5959));
map.addOverlay(marker);
}
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 700px; height: 500px"></div>
</body>
</html>