Thursday, 14 March 2013

Phonegap photoswipe with download option script



(function(window, PhotoSwipe){

document.addEventListener('DOMContentLoaded', function(){

var
options = {

getImageCaption: function(el){

var captionText, captionEl, captionTextSRC;

// Get the caption from the alt tag
if (el.nodeName === "IMG"){
captionText = el.getAttribute('alt');
captionTextSRC = el.getAttribute("src");
}
var i, j, childEl;
for (i=0, j=el.childNodes.length; i childEl = el.childNodes[i];
if (el.childNodes[i].nodeName === 'IMG'){
captionText = childEl.getAttribute('alt');
captionTextSRC = childEl.getAttribute("src");
}
}




// Return a DOM element with custom styling
captionEl = document.createElement('div');
captionEl.style.cssText = 'background: red; font-weight: bold; padding: 5px;';
captionEl.appendChild(document.createTextNode("Download"));
//console.log('JJJJJJJJJJJJ'+ captionTextSRC);
//captionEl.onclick = testing;
//var fileTransfer = new FileTransfer();
captionEl.onclick = (function() {
//navigator.notification.alert("Loasdasdsaddsdsdsdgin Successfull");
var fileTransfer = new FileTransfer();
fileTransfer.download(
    captionTextSRC,
    "file://sdcard/"+captionText,
    function(entry) {
       navigator.notification.alert("download complete: " + entry.fullPath);
    },
    function(error) {
       navigator.notification.alert("download error source " + error.source);
        navigator.notification.alert("download error target " + error.target);
        navigator.notification.alert("upload error code" + error.code);
    });

});


//captionEl.appendChild(document.createTextNode(captionText));
return captionEl;

// Alternatively you can just pass back a string. However, any HTML
// markup will be escaped

}

},
instance = PhotoSwipe.attach( window.document.querySelectorAll('#Gallery a'), options );

}, false);


}(window, window.Code.PhotoSwipe));


function testing()
{
navigator.notification.alert("Login Successfull");
}

Wednesday, 13 March 2013

SVN: Authorisation Failed

Use the below command: rm ~/.gnome2/keyrings/login.keyring

Monday, 2 July 2012

How to get the Spanish Character from URL in php?

How to get the Spanish Character from URL in php?

Use utf8_decode("string");

Tuesday, 15 November 2011

set_time_limit in php, set_time_limit in php5, why set_time_limit?

WHY set_time_limit ?
It is used to run the scripts in the file for a particular amount of time. If we just put set_time_limit(1) then the setting will allow the file to run the script for 1 second and if the time exceeds then it will throw the fatal error

Set_time_limit(0) – No time limit will be set, but I didt checked my MAX_EXECUTION_TIME, if there is still problem in the set_time_limit please check with the MAX_EXECUTION_TIME in the php.ini settings.

Let us check some examples
set_time_limit(0);
function ran()
{
$i=100000;
for ($j=0;$j<$i;$j++)
{
echo $j;
}
}
$gg=ran();
?>
>>>>> WONT THROW ANY ERROR


set_time_limit(1);
function ran()
{
$i=100000;
for ($j=0;$j<$i;$j++)
{
echo $j;
}
}
$gg=ran();
?>

>>>>>> HERE WE SET THIS TO 1 SECOND BUT THE SCRIPT NEEDS TO RUN A LOOP FOR 100000 SO IT WILL THROW THE ERROR LIKE BELOW
Fatal error: Maximum execution time of 1 second exceeded in ------------------------------------------------------------------------

Saturday, 29 October 2011

Stored procedure in MYSQL PHP / MYSQLi

Before proceeding with stored procedure, just confirm whether your server is having all the enough latest versions, please check with MYSQL for the same

While trying i found MYSQLi works well when compared to MYSQL.

Tuesday, 29 March 2011

Know the status of your email in php

This is my requesting php file

This is my response php file


Thursday, 17 March 2011

CRON Path and settings in server


@minute - * * * * *


And paths that you need to try

/web/cgi-bin/php5 "$HOME/html/public_html/my.php"

php /home/*******/public_html/my.php

/home/*******/public_html

/web/cgi-bin/php5 -q /home/*******/public_html/my.php

/web/cgi-bin/php5 -q /home/*******/public_html/my.php

/web/cgi-bin/php5 $HOME/html/home/*******/public_html/html/my.php

/web/cgi-bin/php5 “$HOME/*******/public_html/my.php?

------------------------------------------------------------------------------
/usr/bin/php /home/*******/public_html/my.php
-----------------------------------------------------------------------------