23 November, 2010

Easiest way to add nautilus scripts in Ubuntu

                  Here is a bit tutorial for adding nautilus scritps in ubuntu that will help you to increase the system accessibility. These scripts can be run by simply clicking the right mouse button and selecting any from the 'scripts' menu. The imporatnt advantage of the nautilus scripts is its easiness, for example we dont need a an image processing standalone application to rotate an image or convert it to another format or to mirror it... The only think that we need is to select the image and right clicking on it and choosing any of the scripts... its simple and can be accessed as shown in the figure...



Installing Nautilus scripts in Ubuntu 

Nautilus scripts are available for dowloading from G-script site. You can use the link here  to download it directly to your pc. Follow the steps below to to complete the installation.

  • Untar the downloaded file using the following command
 $ tar -xvzf  nautilus-scripts.tar.gz
  •  You can see the scripts arranged in a heirarchical manner inside the extracted folder. Copy the contents of the extracted nautilus-scripts folder  to the .gnome2/nautilus-scripts folder in your home directory. Since it a hidden folder you can't see it @ the first time. Click Ctrl + H key after enterin the home directory to see the hidden directory.
  • That's all for the installation... You can access the scripts by selecting a file > right clicking it > and choosing any of the scripts arranged in categories under the scripts menu.
Hope you enjoyed th tip...
Read rest of entry

22 November, 2010

Basic javascript programs


 1. A javascript to implement variable usage
<html>
<title>Variable Using Script</title>
<body>
<script>
      var greetings;
      greetings='Hi, How are you?';
      alert(greetings);
</script>
</body>
</html>

2. A javascript to implement the pop-up boxes 
<html>
<title>Script for prompt</title>
<script>
var username;
var greeting;
username = prompt("What is your name?");
username=username.toUpperCase();
greeting="Hi, "+username;
alert(greeting);
</script>
</body>
</html>
</script>
</html>

3.Implementing the eval() function in javascript

          In javascript every input is read as string. We need to convert it to numbers for processing if the input is a number 
<html>
<title>Sum of Two Numbers</title>
<script>
var num1,num2;
var sum;
var msg;
num1=prompt("Enter the first number: ");
num1=eval(num1);
num2=prompt("Enter the second number: ");
num2=eval(num2);
sum=num1+num2;
msg="Sum= "+sum;
alert(msg);
</script></html>

4.  Using switch case in javascript.
<html>
<title>Switch Case</title>
<body>
<script>
       var num,day;
       num=prompt("Enter an integer: ");
       switch(num%7)
       {
              case 1: day="Sunday";break;
              case 2: day="Monday";break;
              case 3: day="Tuesday";break;
              case 4: day="Wednessday";break;
              case 5: day="Thursday";break;
              case 6: day="Friday";break;
              case 0: day="Saturday";break;
              default: day="Invalid Day Number!!\n";
       }
       alert("Day: "+day);
</script>
</body>
</html>

5. Implementing for loop in javascript
<html>
<title>For Loop</title>
<body>
<script>
       var i;
       for(i=0;i<10;i++)
       {
              alert("This is the message no: "+i);
       }
</script>
</body>
</html>

6. Generating local information from the browser using javascript
<html>
<title>Information</title>
<body>
<script>
       document.bgColor="blue";
       alert("Background: "+document.bgColor);
       alert("Domain: "+document.domain);
       alert("URL: "+document.location);
       alert("Last Modified: "+document.lastModified);
       alert("Last Page: "+document.referrer);
       alert("Title: "+document.title);
</script>
</body>
</html>

7.Writing dynamic javascript contents on to html page to display in browser 
<html>
<title>Dynamic Write</title>
<body>
<script>
       var name;
       name=prompt("Enter your name: ");
</script>
        Hi how are you?
<script>
       document.write(name);
</script>
</body>
</html>

8. Implementing onclick events and functions within a form using javascript
<html>
<title>Script for Form Variable Changing</title>
<body>
<script>
       function changebuttonValue()
       {
               document.myForm.button.value="changed";
       }
       function changeText()
       {
               document.myForm.text1.value="Enter you name";
       }
</script>
<form name=myForm>
<input type=text name=text1 onMouseOver='changeText();'>
<br>
<input type=button name='button' value=Enter onClick='changebuttonValue();'>
</form>
</body>
</html>

9. opening a new browser window using javascript
<html>
<title>Open a New Window</title>
<body>
<input type=button value="Show New Window" onClick="newWindow();">
<input type=button value="Close Window" onClick="closeWindow();">
<script>
       var new1;
       function newWindow()
       {
              //document.write("Hi");
              new1=window.open("frame1.html","Name","height=450,width=450");
              new1.focus();
       }
       function closeWindow()
       {
              new1.close();
       }
</script>
</body>
</html><hr align="left" size="1" width="100%">


Read rest of entry

a Javascript a day | my javascript tutorial . . .


                 Here i share my basic experimentsi had done with javascript. Its not enough for making a geekness with that, but only for making the first lessons of javascript ...

What is javascript ?

JavaScript is a scripting language that will allow you to add real programming to your webpages. You can create small application type processes with JavaScript, like a calculator or a primitive game of some sort. Important uses of javascript are
  • Browser Detection
    • Detecting the browser used by a visitor at your page. Depending on the browser, another page specifically designed for that browser can then be loaded. 
  • Cookies
    • Storing information on the visitor's computer, then retrieving this information automatically next time the user visits your page. This technique is called "cookies".
  • Control Browsers
    • Opening pages in customized windows, where you specify if the browser's buttons, menu line, status line or whatever should be present.
  • Validate Forms
    • Validating inputs to fields before submitting a form. An example would be validating the entered email address to see if it has an @ in it, since if not, it's not a valid address. 
 
where is the playground ?

The browser will use the 
<script type="text/javascript"> and </script> to tell where javascript starts and ends respectively.

The <script> …… </script>  Tag can be included in

  • <head> section
  • <body> section
  •  Both <head> section and <body> section
  •  In an External file with .js extension    
    • Eg : <script type="text/javascript" src="xxx.js"></script> 
To declare a variable in JavaScript, use the var command.    Eg : var state, city, zip, country; 

Basics

  • Write directly into the document.
     >> document.write("Welcome to my world!!!");

  • Write using POPUP Boxes
     Alert Box
     >> alert("Welcome to my world!!!");

     Confirm Box

     >>if (confirm("Do you agree")) 

               {alert("You agree")}
           else{alert ("You do not agree")};

    Prompt Box
    >> username=prompt("Please enter your 

                    name","Enter your name here");  

Check out this link to make out the rest.
Read rest of entry
 

Terminal Diary | techblog Copyright © 2009 Gadget Blog is Designed by jintu jacob Powered by Blogger