Wednesday, May 13, 2009

JQuery Mobile alert box open after completion of task

JQuery Mobile alert box open after completion of some task


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html class="ui-mobile">
<head>
<title>Products</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
<link type="text/css" href="http://dev.jtsage.com/cdn/simpledialog/latest/jquery.mobile.simpledialog.min.css" rel="stylesheet" />
<link type="text/css" href="http://dev.jtsage.com/jQM-DateBox/css/demos.css" rel="stylesheet" />
<script type="text/javascript" src="http://dev.jtsage.com/cdn/simpledialog/latest/jquery.mobile.simpledialog.min.js"></script>
<script type="text/javascript" src="http://dev.jtsage.com/gpretty/prettify.js"></script>
<link type="text/css" href="http://dev.jtsage.com/gpretty/prettify.css" rel="stylesheet" />
</head>
<body class="ui-mobile-viewport">
<div data-role="page" data-theme="b" data-content-theme="d">
  <div data-role="header" data-position="inline" data-theme="b">
    <h1>Products Listing </h1>
    <a href="#" id="addToCartButton" onclick="addToCart();" data-role="button" data-icon="myapp-shopping" data-theme="c">Add to Cart</a>
</div>
    <div data-role="content">
        Open jQuery Mobile alert box after completion of some task.
    </div>
</div>
<script>
function openDialog(msg) {
    $(document).delegate('#
addToCartButton', 'click', function() {
    $(this).simpledialog({
        'mode' : 'bool',
        'prompt' : msg+"<br/><br/><br/><br/>",
        'useModal': true,
        'buttons' : {  'OK': {  click: function () {   }  } }
                    })
            });
}
function addToCart() {
    // task goes here.....
    var msg="Product added in you cart";
    openDialog(msg);
}
/*$(document).delegate('#addToCartButton', 'click', function() {
    var msg=addToCart();
    $(this).simpledialog({
    'mode' : 'bool',
    'prompt' : msg,
    'useModal': true,
    'buttons' : {
      'OK': {
        click: function () {
           
          //$('#dialogoutput').text('OK');
        }
      }
    }
  })
});*/
</script>
</body>
</html>










Wednesday, May 6, 2009

Read yahoo groups rss by curl and SimpleXmlElement in PHP

..< ?php
// Read yahoo groups rss by curl and SimpleXmlElement
// by Amit gaur  $url = "http://rss.groups.yahoo.com/group/tm_informatikleri/rss"; $req = curl_init(); curl_setopt($req, CURLOPT_URL, $url);
curl_setopt($req, CURLOPT_RETURNTRANSFER, 1);
$xml = curl_exec($req);
curl_close($req);
$doc = new SimpleXmlElement($xml, LIBXML_NOCDATA);
if(isset($doc->channel))
{
showRSS($doc);
}
function showRSS($xml)
{
echo "".$xml->channel->title."
";
$cnt = count($xml->channel->item);
for($i=0; $i<$cnt; $i++)
{
$url = $xml->channel->item[$i]->link;
$title = $xml->channel->item[$i]->title;
$desc = $xml->channel->item[$i]->description;
$pubDate=$xml->channel->item[$i]->pubDate;
echo ''.$title.'
'.$pubDate.'
'.$desc. ' '. $guid. '

';
}
}
?>

How to send email from Gmail in Java.

import java.io.*;
import java.net.InetAddress;
import java.util.Properties;
import java.util.Date;
import javax.mail.*;
import javax.mail.internet.*;

// Created by Amit Gaur May-4-2009

// How to send email from Gmail in Java

public class GMail
{
public static void main(String ss[])
{
String host = "smtp.gmail.com";
String username = "a";// Put here only Gmail username not full email id
String password = "amitamit";// Put here Gmail password
int i;
i=1;
try
{
Properties props = new Properties();
props.put("mail.smtps.auth", "true");
//props.put("mail.from", "a@gmail.com");
props.put("mail.from",""); // put here from full gmail email id
Session session = Session.getInstance(props, null);
Transport t = session.getTransport("smtps");
t.connect(host, username, password);
MimeMessage msg = new MimeMessage(session);
msg.setFrom();
//msg.setRecipients(Message.RecipientType.TO, "a@gmail.com");
msg.setRecipients(Message.RecipientType.TO, ""); // put here receiver mail id

msg.setSubject("hello amit"+i);
msg.setSentDate(new Date());
msg.setText("Hello, Hi!"+i);
t.sendMessage(msg, msg.getAllRecipients());

}
catch(Exception ee)
{
System.out.println(ee.toString());
}
}
}