2019 4G LTE 4G VoLTE 5G 7th Pay Commission Aadhaar Actor Wallpapers Actress Wallpaper Adriana Lima AdSense Ahoi Ashtami Airtel Airtel DTH Akshay Kumar Alcatel Alexa Rank Amazon Android Android Pie Android Q Anna university Antivirus Anushka Sharma apna csc online Apple Apps Army Army App Asthma Asus Atal Seva mirchpur Athletics Auto Auto Insurance Avengers Axis Bank Backlinks Badhajmi Bajaj Bang Bang Reloaded Bank Battery Bhai Dooj Katha Bhakti Bharti Bhumi Pednekar Big Bazaar Big TV Bing BlackBerry Blogger BlogSpot Bluetooth BoB Bollywood Boot Boxing Breathlessness Browser BSEH Bsnl Budget Budhvar Business buy Cable TV Camera Car Car Loan Card Less ATM Cash CBSE Celebrity CEO Chandra Grahan Channels Chest Pain Chhath chrome Clean WhatsApp Cache Common Service Centres (CSC) Mirchpur Hisar Haryana - Front of Jyoti Sen Sec School Mirchpur Comparisons Computer Coolpad Corona COVID 19 COVID 19 HARYANA Credit Cricket Crime CSC Cylinder Dama Dard Deepika Padukone Defence Detel Dhanteras Diamond Crypto DigiLocker App DigiPay App Digital India App Digital Indian Gov Dish TV Diwali DNS setting Domain Donate Doogee DTH DTH Activation DTH Installation DTH Plans in India Dusshera E-seva Kender mirchpur Earn Money Education Electronics Email Entertinment Ex-serviceman Extensions Facebook FASTag Fatigue Festivals FlicKr Flipkart Foldable Smartphone Food Foursquare Funny Gadgets Galaxy Galaxy S8 Game Ganesh ganesh chaturthi Gas Problems Gastric Problem Gharelu Gionee Gmail God Google Google + Google Assistant Google Drive Google Duo Google Pixel Google Tez Google Voice Google+ Govardhan Puja GroupMe GST GTA Guide GuruSatsang Guruvar Hamraaz hamraaz app hamraaz app download hamraaz army hamraaz army app hamraaz army app download Hamraaz Army App version 6 Apk Happy New Year Hariyali Teej Hartalika Teej Harvard University Haryana haryana csc online HDFC Bank Headphones Health Heart Attack Heart Fail Heart Problems Heart Stroke Heena Sidhu Hello App Help Hernia Hindi History Hockey Holi Holi Katha Hollywood Home Loan Honor HostGator Hosting Hrithik Roshan HTC Huawei humraaz app iBall IBM ICICI Bank Idea Ilaj India india vs china indian army app Indigestion Infinix InFocus Information Infosys Instagram Insurance Intel Internet Intex Mobile iPad iPhone iPhone 8 IPL IRCTC iVoomi Jan Dhan Account Janmashtami Japanese Encephalitis Javascript JBL Jio Jio GigaFiber Jio Meet JioPOS JioRail JioSaavn Jokes Kamjori Karbonn Kareena Kapoor Kartik Purnima Karva Chauth Karwa Chauth Kasam Tere Pyaar Ki Katrina Kaif Kendall Jenner Keywords Kimbho Kodak Kumkum Bhagya Kushth Rog Landline Laptop Lava Lenovo Leprosy LET Lethargy LG Library of Congress Lifestyle Linkedin Lisa Haydon Livejournal Liver Cancer Loans LPG Gas mAadhaar Macbook Maha Shivratri Makar Sankranti Map Market Mary Kom Massachusetts Institute of Technology Meizu Messages Mi Micromax Microsoft Mobile Modi Mokshada Ekadashi Money Motorcycles Motorola Movie Muscle Pain Music Myspace Narendra Modi Narsingh Jayanti Nature Naukri Navratri Nemonia Netflix Network News Nexus Nia Sharma Nokia Notifications Nuskhe OBC Ocean Office Offrs Ola Cab OMG OnePlus Online Opera Oppo Oreo Android Orkut OS OxygenOS Padmavati PagalWorld Pain Pain Sensation Pakistan PAN PAN Card Panasonic Passwords Patanjali Pay Payment Paypal Paytm PC PDF Peeda Pendrive Pension Personal Loan Pet Me Gas PF Phone Photo PHP Pila Bukhar Pinterest Pixel Plan PNB Bank Pneumonia PNR Poco Poster PPC Pradhan Mantri Kisan Samman Nidhi Pradhanmantri Kisan Samman Nidhi Yojna Pradosh Pragya Jaiswal Prepaid Princeton University Printer Priyanka Chopra promote my youtube channel promote video on youtube cost promote youtube channel promote youtube channel free promote youtube video free PUBG Qualcomm Quora Quotes Race 3 Railway Rambha Tritiya Vrat RBI Realme Recruitment Redmi Relationship Religious Restore Results Review Rule Sai Dharam Tej Saina Nehwal Salman Khan Samsung Sanusha Satsang Video Sawan Somvar Vrat SBI Bank Script Sell SEO Serial Server Shabd Shahid Kapoor Shanivar Sharad Poornima Sharp Shiv Shopping Shreyasi Singh Shruti Haasan Signal Sim Smart Android TV Smartphones SMS Snapchat Social Software Somvar Sonakshi Sinha Sonam Kapoor Soney Songs Sony Xperia Space Speakers Specifications Sports Sql Stanford University State Bank of India Stickers Stomach Upset Story Sun Direct Sunny Leone Surabhi Sushant Singh Rajput Swadeshi Swas Rog Tata Sky Tax Tech Technology Tecno Telegram Telugu Thakan Tiger Shroff Tiger Zinda Hai Tips Tiredness Tollywood Tool Top Trending People Trading Trai TRAI Rules for cable TV Trailer Treatment Trends True Things Truecaller Tubelight Tulsi Vivah Tumblr Tv Twitter Typing Uber Umang App University of Oxford UP Board Upay Upchar Update USA USB Vacancies Valentines Day Verizon Vertu Viber Video Videocon d2h Videos Vijayadashami Viral Bukhar Viral Fever Virat Kohli Virgin Visas Vivo VLE Vodafone Voter Card VPN Vrat Katha Vrat Vidhi Wallpaper War Wayback Machine Weakness WhatsApp WhatsApp Cleaner WhatsApp Status WhatsApp stickers Wi-Fi WiFi Windows Windows 10 Wipro Wireless WordPress workstation WWE Xiaomi Xiaomi Mi 6 Yeh Hai Mohabbatein Yellow Fever Yo Yo Honey Singh Yoga yojna YotaPhone YouTube youtube promotion youtube promotion free ZTE अपच अस्थमा आलस्य इलाज उपचार उपाय उमंग ऐप कहानियाँ कुष्ठरोग कोरोना वायरस गुरुसत्संग घरेलू जन धन योजना जापानी इन्सेफेलाइटिस डिजिटल इंडिया डिजिटल इंडिया अप्प्स डिजिपे ऐप डिजीलॉकर ऐप थकान दमा दर्द निमोनिया नुस्ख़े पीड़ा पीतज्वर पीला बुखार पेट में गैस पैन कार्ड प्रधानमंत्री किसान सम्मान निधि बदहज़मी भक्ति मांसपेशियों में दर्द लीवर कैंसर वायरल बुखार वोटर कार्ड शब्द सच्ची बातें सत्संग वीडियो सरसों सीने में दर्द स्कीम स्वास रोग हर्निया

New Twitter Design Expanding URLs with Jquery, Ajax and PHP

My last post explained about New Twitter design basic layout with CSS and Jquery. In this post I want to explain how to expand URLs like new Twitter user interface using jquery, ajax and PHP. It is very easy just implementing with oembed jquery media plugin.

Database
MySQL messages table contains two columns msg_id and message
CREATE TABLE messages
(
msg_id INT PRIMARY KEY AUTO_INCREMENT,
message VARCHAR(150)
);

Index.php
Contains simple HTML and PHP code. In left class contains messages table records.
<div id='container'>
// Right part
<div class='right'>
</div>

<div id="panel-frame">
<div class="panel">
<div class="head"> <a href="#" class="close">Close</a></div>
<div class="data">// Message id</div>
<div class="final">// Message </div>
<div class="expand_box">// Expanding URL area</div>
</div>
</div>

//Left Part
<div class="left">
// Message display here
<?php
include('db.php');
include('tolink.php');
$sql=mysql_query("select msg_id,message from messages order by msg_id desc");
while($row=mysql_fetch_array($sql))
{
$id=$row['msg_id'];
$message=$row['message'];
$message=tolink($message); // tutorial link click here
?>
<div class="block" id="<?php echo $id;?>">
<?php echo $message;?&gt;
</div>
<?php 
}
?>
</div>


Javascript
$(".block").click(function(){})block is the class name of DIV tag. Using $(this).attr('id')- calling DIV tag ID value and $(this).html() - calling DIV tag data. Here you have to include jquery.oembed.js plugin download link
<script type="text/javascript" src="http://ajax.googleapis.com/
ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery.oembed.js"></script>
<script type="text/javascript">
$(document).ready(function()
{

$('.block').click(function()
{
var id= $(this).attr('id'); // .block ID
var msg= $(this).html(); // .block DIV data
var data_id= $(".data").html(); // .data DIV value
var panel= $('.panel');
var panel_width=$('.panel').css('left'); // rolling panel width
//-Expanding URLs--------------------------------
$('.data').html(id);
$('.final').html(msg);

function expanding_url()
{
var dataString = 'id='+ id;
$.ajax({
type: "POST",
url: "newtwitterajax.php", // Expanding URL 
data: dataString,
cache: false,
success: function(data)
{
$('#expand_box').show();
$('#expand_box').html(data);
}
});
}

//---------------------------------

if(data_id==id)
{
// Rolling Animation
panel.animate({left: parseInt(panel.css('left'),0) == 0 ? +panel.outerWidth() : 0});
//--------------------------------
if(panel_width=='341px')
{
$('#expand_box').hide();
}
else
{
expanding_url();
}
//--------------------------------
}
else
{
expanding_url();
// panel width CSS width:340px + border:1px = 341px
if(panel_width=='341px')
{
// No rolling animation
}
else
{
// Rolling Animation
panel.animate({left: parseInt(panel.css('left'),0) == 0 ? +panel.outerWidth() : 0});
}
}
// passing id value to <div class='data'$gt; </div>
$('.data').html(id);
return false;
});

// panel close link
$('.close').click(function()
{
var panel= $('.panel');
panel.animate({left: parseInt(panel.css('left'),0) == 0 ? +panel.outerWidth() : 0});
$('#expand_box').hide();
return false;
});

});
</script>

newtwitterajax.php
Contains PHP and javascript code. Here calling message record from messages table where msg_id = .block id and calling oembed JavaScript function. If you want to display more details about message(Retweet information) write your code.
<?php
include('db.php');
if($_POST)
{
$id=$_POST['id'];
$sql=mysql_query("select message from messages where msg_id='$id'");
$row=mysql_fetch_array($sql);
$message=$row['message'];
?>
<script type="text/javascript">
$(document).ready(function()
{
$("#expand_url<?PHP echo $id; ?>").oembed("<?php echo $message; ?>", {maxWidth: 300, maxHeight: 200});
});
</script>
<div id='expand_url<?php echo $id; ?>></div>
<?php
}
?>

CSS
.data
{
font-size:16px;
display:none;
}
.final
{
overflow:hidden;
padding:20px;
font-size:24px;
}
#expand_box
{
position:relative;
position:absolute;
padding-left:30px;
}
#expand_box img { width:250px; }

db.php
PHP database configuration file
<?php
$mysql_hostname = "Host name";
$mysql_user = "UserName";
$mysql_password = "Password";
$mysql_database = "Database Name";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");
mysql_select_db($mysql_database, $bd) or die("Could not select database");
?>
Labels:

Post a Comment

[blogger][facebook]

Digitalindiagov.com

Satish Kumar

Contact Form

Name

Email *

Message *

Powered by Blogger.