Skip to main content

Posts

Showing posts from 2013

JQuery progressbar example

<!DOCTYPEhtml> <html> <head>  <meta charset="utf-8">  <title>jQuery Progressbar</title>  <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">  <script src="../../jquery-1.9.1.js"></script>  <script src="../../ui/jquery.ui.core.js"></script>  <script src="../../ui/jquery.ui.widget.js"></script>  <script src="../../ui/jquery.ui.progressbar.js"></script>  <link rel="stylesheet" href="../demos.css">  <script>  $(function() {   $( "#progressbar" ).progressbar({    value: false   });   $( "button" ).on( "click", function( event ) {    var target = $( event.target ),     progressbar = $( "#progressbar" ),     progressbarValue = progressbar.find( ".ui-progressbar-value" );    if ( target.is( "#numButton" ) ) {  ...

JQuery image cycler example

<!DOCTYPE html> <html> <head>  <meta charset="utf-8">  <title>jQuery Image Cycler</title>  <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">  <script src="../../jquery-1.9.1.js"></script>  <script src="../../ui/jquery.ui.core.js"></script>  <script src="../../ui/jquery.ui.widget.js"></script>  <script src="../../ui/jquery.ui.position.js"></script>  <link rel="stylesheet" href="../demos.css">  <style>  body {   margin: 0;  }  #container {   overflow: hidden;   position: relative;   height: 400px;  }  img {   position: absolute;  }  </style>  <script>  $(function() {   $.fn.left = function( using ) {    return this.position({     my: "right middle",     at:...

JQuery tabs example

<!DOCTYPE html> <html lang="en"> <head>  <meta charset="utf-8">  <title>jQuery Tabs</title>  <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">  <script src="../../jquery-1.9.1.js"></script>  <script src="../../ui/jquery.ui.core.js"></script>  <script src="../../ui/jquery.ui.widget.js"></script>  <script src="../../ui/jquery.ui.tabs.js"></script>  <link rel="stylesheet" href="../demos.css">  <script>  $(function() {   $( "#tabs" ).tabs();  });  </script> </head> <body> <div id="tabs">  <ul>   <li><a href="#tabs-1">Nunc tincidunt</a></li>   <li><a href="#tabs-2">Proin dolor</a></li>   <li><a href="#tabs-3">Aenean lacinia</a>...

JQuery dialog example

<!DOCTYPEhtml> <html> <head>  <meta charset="utf-8">  <title>jQuery Dialog</title>  <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">  <script src="../../jquery-1.9.1.js"></script>  <script src="../../ui/jquery.ui.js"></script>  <link rel="stylesheet" href="../demos.css">  <script>  $(function() {   $( "#dialog" ).dialog();  });  </script> </head> <body> <div id="dialog" title="Basic dialog">  <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p> </div> <div class="demo-description"> <p>The basic dialog window is an overlay positioned within the viewport and is protected from page content (like select elements) shining through w...

JQuery date picker example

<!DOCTYPE html> <html> <head>  <meta charset="utf-8">  <title>jQuery Date Picker</title>  <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">  <script src="../../jquery-1.9.1.js"></script>  <script src="../../ui/jquery.ui.core.js"></script>  <script src="../../ui/jquery.ui.widget.js"></script>  <script src="../../ui/jquery.ui.datepicker.js"></script>  <link rel="stylesheet" href="../demos.css">  <script>  $(function() {   $( "#datepicker" ).datepicker();  });  </script> </head> <body> <p>Date: <input type="text" id="datepicker"></p> <div class="demo-description"> <p>The datepicker is tied to a standard form input field.  Focus on the input (click, or use the tab key) to open an interactive cal...

JQuery switch class example

<!DOCTYPE html> <html> <head>  <meta charset="utf-8">  <title>jQuery Switch Class Example</title>  <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">  <script src="../../jquery-1.9.1.js"></script>  <script src="../../ui/jquery.ui.effect.js"></script>  <link rel="stylesheet" href="../demos.css">  <style>  .toggler { width: 500px; height: 200px; position: relative; }  #button { padding: .5em 1em; text-decoration: none; }  #effect { position: relative; }  .newClass { width: 240px;  padding: 1em; letter-spacing: 0; font-size: 1.2em; margin: 0; }  .anotherNewClass { text-indent: 40px; letter-spacing: .4em; width: 410px; height: 100px; padding: 30px; margin: 10px; font-size: 1.6em; }  </style>  <script>  $(function() {   $( "#button" ).click(function(){    $( ".newClass" ).switchClass...

JQuery toggle class example

<!DOCTYPE html> <html> <head>  <meta charset="utf-8">  <title>ToggleClass Example</title>  <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">  <script src="../../jquery-1.9.1.js"></script>  <script src="../../ui/jquery.ui.effect.js"></script>  <link rel="stylesheet" href="../demos.css">  <style>  .toggler { width: 500px; height: 200px; position: relative; }  #button { padding: .5em 1em; text-decoration: none; }  #effect {position: relative;  width: 240px;  padding: 1em; letter-spacing: 0; font-size: 1.2em; border: 1px solid #000; background: #eee; color: #333; }  .newClass { text-indent: 40px; letter-spacing: .4em; width: 410px; height: 100px; padding: 30px; margin: 10px; font-size: 1.6em; }  </style>  <script>  $(function() {   $( "#button" ).click(function() {    $( "#effect" ...

Groovy example of storing values in different data variables

class Datatypes {     public void integer(){         def integer=10;         println integer;     }     public void decimal(){         def decimal=10.67f;         println decimal;     }     public void string(){         def string="0";         println string;     }     public void character(){         def character='a';         println character;     }     public static void main(args){         Datatypes dt=new Datatypes();         dt.integer();         dt.decimal();  ...

Groovy convert every alphabet of a string into its equivalent numeric form

import groovy.io.*; class AlphabetToDigit {     Scanner scan=new Scanner(System.in);     def txt;     def ch;     def str="";     def input(){         try{             printf "Enter A Word: ";             txt=scan.nextLine();             compute(txt);         } catch(e){             System.err.println "Error Occurred!\n$e"+e.getMessage();             System.exit(0);         }     }     def compute(txt){         for(def i in 0..txt.length()-1){      ...

Groovy calculator using menu driven criteria

class Calculator {     def choice;     def number1, number2;     Scanner scan=new Scanner(System.in);     def input(){         try{             printf "***MENU***\n1. Addition\n2. Subtraction\n3. Multiplication\n4. Division\n5. Modulus\nYour Choice: ";             choice=scan.nextInt();             printf "Enter First Number: ";             number1=scan.nextDouble();             printf "Enter Second Number: ";             number2=scan.nextDouble();         } catch(e){             ...

JavaScript md5 encoding

MD5 = function(data) {     // convert number to (unsigned) 32 bit hex, zero filled string     function to_zerofilled_hex(n) {             var t1 = (n >>> 0).toString(16)         return "00000000".substr(0, 8 - t1.length) + t1     }     // convert array of chars to array of bytes     function chars_to_bytes(ac) {         var retval = []         for (var i = 0; i < ac.length; i++) {             retval = retval.concat(str_to_bytes(ac[i]))         }         return retval     }     // convert a 64 bit unsigned number to array of bytes. Little endian     function int64_to_bytes(n...

PHP use of form and retrieve form data

<html> <body> <form action="welcome.php" method="post"> <label for="fname">Name: </label><input type="text" name="fname" id="fname"/> <label for="age">Age: </label><input type="text" name="age" id="age"/> <button type="submit">Continue</button> </form> </body> </html> welcome.php: <html> <body> Welcome <?php echo $_POST['fname']; ?>!<br/> You're <?php echo $_POST['age']; ?> years old!<br/> </body> </html>

PHP create directory

<?php if(isset($_GET["name"]) mkdir("php/".$_GET["name"]); ?> <html> <head> <title>Create Directory</title> </head> <body> <form action="?"> <input type="text" name="name" placeholder="Directory Name"/><br> <button type="submit">Create</button> </form> </body> </html>

PHP link image from a directory

The following code is to link images from your php directory. "photo.php" acts in two ways. The "src" attribute should be like "src=photo.php?view=1&default=0&id=1". When "view=0" is used it is to tell the script that the photo is to be used within a page. When "view=1" is used it is to tell the script that the page, "photo.php", is to be loaded and other options are shown to the user. Here, "id" specifies the image that is to be shown on the page. And "default=1" specifies that the image isn't user uploaded but images to be used in the sites. The use of above mentioned things can be seen in the same following code: <?php session_start(); $id = $_GET["id"]; $default = ""; if (isset($_GET["default"]))     $default = $_GET["default"]; $photo_path = "/php/account/"; $view = NULL; if (isset($_GET["view"]))     $view = $_GET[...

PHP captcha code generation, submission and verification

PHP Code Submission & Verification: The following code is for the submission and verification of the captcha code entered by user and redirect the user to an other page. <?php print '<html><head><link type="text/css" rel="stylesheet" href=" http://localhost/php/account/photo.css"/><title>Captcha</title></head><body>' ; $error = NULL; if (isset($_REQUEST['confirm_code'])) {     if (isset($_COOKIE['Captcha'])) {         list($Hash, $Time) = explode('.', $_COOKIE['Captcha']);         if (md5("OASDOIJQWOIJDASDOI" . strtoupper($_REQUEST['confirm_code'] . $_SERVER['REMOTE_ADDR'] . $Time)) != $Hash) {             $error = '<marquee behavior="slide" direction="up" width="100%" height="2.5%" style="text-align: center;" id="pop-up"><div width="100%" style="text-a...

PHP upload an image and set it as the profile photo of the user

I'm using WampServer for running PHP scripts offline. This code is to upload an image and set it as profile photo of the user. So, to store the data I've created a directory "account" & "account/users/" to store my php scripts and user's data and information.  PHP: <?php session_start(); if (isset($_POST["file"]) || isset($_GET["file"]) || isset($_GET[md5("upload")])) {     $allowedExts = array("gif", "jpg", "jpeg", "png");     $temp = explode(".", $_FILES['file']['name']);     $extension = end($temp);     $email = "";     if (isset($_SESSION["email"]))         $email = $_SESSION["email"];     $f = "/php/account/users/$email/profile/";     if ((($_FILES['file']['type'] == "image/gif") || ($_FILES['file']['type'] == "image/jpg") || ($_FILES['file'][...