Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Saturday, February 20, 2021

8 JavaScript Libraries every developer should know.

 8 JavaScript Libraries every developer should know.

Small blue diamond
1. Lodash is a JavaScript library which provides utility functions for common programming tasks.  Lodash contains tools to simplify programming with strings, numbers, arrays, functions and objects. lodash.com

2. SWFObject
This simple yet powerful JS library is mainly used to embed flash SWF files in HTML documents. It supports only SWF files, and no other media types can be embedded using SWFObject. 

A highly reliable library that allows for event-based two-way communication between the server and the browser window. It has a node.js server and a browser client library.


4. Modernizr Modernizr provides feature detection i.e., it tells you the JS, HTML, and CSS features that your browser has. This helps in knowing and avoiding the unimplemented features. modernizr.com

5 Verge3D Adding the Verge3D toolkit, developers can create beautiful 3D visualizations on websites, for example, puzzles, UI and website layouts, animation, AR/VR, and much more, bringing out the artist in you.

6 Anime.js One of the best animation libraries that makes staggering follow-through animations so simple, Anime.js is light-weight and comes with a clean yet powerful API. With Anime, you can set various properties of CSS at different timings.


7 Parsley Parsley library makes form validation process simple. It detects changes to the form data and adjusts the validations dynamically, giving the result almost instantly. All you have to do is write the form validation requirements in your HTML.  parsleyjs.org

8. Three.js Three.js include many features like geometry, lights, materials, shaders, effects, scenes, data loaders, animation, and much more. The library is a single js file.

Thursday, October 8, 2015

Get selected value in dropdown list using JavaScript?

Get selected value in dropdown list using JavaScript?

<select id="ViewBy">
  <option value="1">Subjet1</option>
  <option value="2" selected="selected">Subject2</option>
  <option value="3">Subject3</option>
</select>



Running this code:

var e = document.getElementById("ViewBy");
var strUser = e.options[e.selectedIndex].value;

Would make strUser be 2.
If what you actually want is Subject2, then do this:

var e = document.getElementById("ViewBy");
var strUser = e.options[e.selectedIndex].text;

Which would make strUser be Subject2


--------------------------------------------------------------------------------------------

jQuery:

$("#elementId :selected").text() //the text content of the selected option
$("#elementId").val()            //the value of the selected option

------------------------------------------------------------------------------------------------
AngularJS

// html

<select ng-model="selectItem" ng-options="item as item.text for item in items">
</select>
<p>Text: {{selectItem.text}}</p>
<p>Value: {{selectItem.value}}</p>

// javascript
$scope.items = [{
  value: 'item_1_id',
  text: 'Item 1'
}, {
  value: 'item_2_id',
  text: 'Item 2'
}];

Thursday, April 23, 2015

Robomongo (v 0.8.4) connection to use localhost (127.0.0.1)

I set the Robomongo (v 0.8.4) connection to use localhost (127.0.0.1) and port 3001. Everything else is empty/default. I am using Ubuntu 14.4 LTS . 

My Robomongo settings:

Connection tab Authentication tab Advanced tab SSL tab SSH tab

Thursday, April 2, 2015

Disable click outside of bootstrap model area to close modal

Disable click outside of bootstrap model area to close modal

making a bootstrap project, with a couple of Bootstrap 'Modals'. someone  trying to customize some of the default features.

they want to disable click on outside of model area to close modal

$('#myModal').modal({
    backdrop: 'static',
    keyboard: false  // to prevent closing with Esc button (if you want this too)
})
 
happy Coding :)

Tuesday, January 20, 2015

Multiple versions of jQuery on the same page?

Multiple versions of jQuery on the same page?

Is it possible to handle conflicts between 2 versions of jQuery loaded in the same page? Assume that these lines of code:

----------------------------------------------------------------------------
<script type="text/javascript" src="jquery-1.1.3.js"></script>              
<script type="text/javascript" src="jquery-1.4.2.js"></script>              
                                                                            
--------------------------------------------------------------------------- 

solution 

use $.noConflict(true);

<!-- load jQuery 1.1.3 -->                                                       
<script type="text/javascript" src="http://example.com/jquery-1.1.3.js"></script>
<script type="text/javascript">                                                  
var jQuery_1_1_3 = $.noConflict(true);                                           
</script>                                                                        

<!-- load jQuery 1.3.2 -->                                                       
<script type="text/javascript" src="http://example.com/jquery-1.3.2.js"></script>
<script type="text/javascript">                                                  
var jQuery_1_3_2 = $.noConflict(true);                                           
</script>                                                                        

Then, instead of $('#selector').function();,                                     
 you'd do jQuery_1_3_2('#selector').function(); or jQuery_1_1_3('#selector').function();.


enjoy :)                                                                                

Thursday, December 11, 2014

Register Confirm Using Mail

create 4 page

1. login.php
2. register.php
3. verify.php
4. Confirm.php


Login.php                                                                                                          
                                                                                                                                

 <html>


</html> 



register.php                                                                                                          
                                                                                                                                  

<?php 
if(isset($_POST['submitform'])){

$name = trim(mysql_escape_string($_POST['name']));
$email = trim(mysql_escape_string($_POST['email']));
$passwords = trim(mysql_escape_string($_POST['pwd']));
$password = md5($passwords);

$query_verify_email = "SELECT * FROM register WHERE email ='$email' and isactive = 1";
$verified_email = mysqli_query($con,$query_verify_email);
if (!$verified_email) {
echo ' System Error';
}
if (mysqli_num_rows($verified_email) == 0) {
// Generate a unique code:
$hash = md5(uniqid(rand(), true));
$query_create_user = "INSERT INTO `register` ( `name`, `email`, `password`, `hash`) VALUES ( '$name', '$email', '$password', '$hash')";
$created_user = mysqli_query($con,$query_create_user);
if (!$created_user) {
echo 'Query Failed ';
}

if (mysqli_affected_rows($con) == 1) { //If the Insert Query was successfull.

$subject = 'Activate Your Email';

$headers = "From: admin@php999.com \r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$url= BASE_PATH . '/verify.php?email=' . urlencode($email) . "&key=$hash";

$message ='<p>To activate your account please click on Activate buttton</p>';
$message.='<table cellspacing="0" cellpadding="0"> <tr>';
$message .= '<td align="center" width="300" height="40" bgcolor="#000091" style="-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;

color: #ffffff; display: block;">';

$message .= '<a href="'.$url.'" style="color: #ffffff; font-size:16px; font-weight: bold; font-family: Helvetica, Arial, sans-serif; text-decoration: none;

line-height:40px; width:100%; display:inline-block">Click to Activate</a>';
$message .= '</td> </tr> </table>';

mail($email, $subject, $message, $headers);

echo '<div>A confirmation email
has been sent to <b>'. $email.' </b> Please click on the Activate Button to Activate your account </div>';
} else { // If it did not run OK.
echo '<div>You could not be registered due to a system
error. We apologize for any
inconvenience.</div>';
}
}
else{
echo '<div>Email already registered</div>';}
}

?>


verify.php                                                                                                          
                                                                                                                           


<?php
$email = trim(mysql_escape_string($_GET['email']));

$key = trim(mysql_escape_string($_GET['key']));

$query_verify_email = "SELECT * FROM register WHERE email ='$email' and isactive = 1";
$result_verify_email = mysqli_query($con,$query_verify_email);

if (mysqli_num_rows($result_verify_email) == 1)
{
echo '<div>Your Account already exists. Please <a href="login.html">Login Here</a></div>';

}
else
{

if (isset($email) && isset($key))

{

mysqli_query($con, "UPDATE register SET isactive=1 WHERE email ='".$email."' AND hash='".$key."' ") or die(mysql_error());

if (mysqli_affected_rows($con) == 1)
{
echo '<div>Your Account has been activated. Please <a href="login.html">Login Here</a></div>';

} else
{
echo '<div>Account couldnot be activated.</div>';

}
}
mysqli_close($con);

}?>


Thursday, April 24, 2014

Implementation of Captcha in Javascript

Implementation of Captcha in Javascript 

captcha helps us in understanding and logical implentation of captcha on entirely client side.

Generating Captcha using client side scripting is quite a simple but make sure that the javascript is enabled. Anyways lets move towards the code details.
the source code is quite simple and straight forward.

Source Code

<html>
<head>
<title>Captcha</title>
    
    <script type="text/javascript">

   //Created / Generates the captcha function    
    function DrawCaptcha()
    {
        var a = Math.ceil(Math.random() * 10)+ '';
        var b = Math.ceil(Math.random() * 10)+ '';       
        var c = Math.ceil(Math.random() * 10)+ '';  
        var d = Math.ceil(Math.random() * 10)+ '';  
        var e = Math.ceil(Math.random() * 10)+ '';  
        var f = Math.ceil(Math.random() * 10)+ '';  
        var g = Math.ceil(Math.random() * 10)+ '';  
        var code = a + ' ' + b + ' ' + ' ' + c + ' ' + d + ' ' + e + ' '+ f + ' ' + g;
        document.getElementById("txtCaptcha").value = code
    }

    // Validate the Entered input aganist the generated security code function   
    function ValidCaptcha(){
        var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
        var str2 = removeSpaces(document.getElementById('txtInput').value);
        if (str1 == str2) return true;        
        return false;
        
    }

    // Remove the spaces from the entered and generated code
    function removeSpaces(string)
    {
        return string.split(' ').join('');
    }
    
 
    </script>
    
    
    
</head>
<body onload="DrawCaptcha();">
<table>
<tr>
    <td>
        Welcome To Captcha<br />
    </td>
</tr>
<tr>
    <td>
        <input type="text" id="txtCaptcha" 
            style="background-image:url(1.jpg); text-align:center; border:none;
            font-weight:bold; font-family:Modern" />
        <input type="button" id="btnrefresh" value="Refresh" onclick="DrawCaptcha();" />
    </td>
</tr>
<tr>
    <td>
        <input type="text" id="txtInput"/>    
    </td>
</tr>
<tr>
    <td>
        <input id="Button1" type="button" value="Check" onclick="alert(ValidCaptcha());"/>
    </td>
</tr>
</table>
</body>
</html> 
 
 

How to Host a Laravel Project on Hostinger’s hPanel: A Step-by-Step Guide

How to Host a Laravel Project on Hostinger’s hPanel: A Step-by-Step Guide If you're looking to host a Laravel project on Hostinger’s hPa...