Learning Google gadgets (3)

Source: Internet
Author: User
Tags alphabetic character

The compilation of gadgets is actually very simple. You do not need to write your own gadgets if you understand HTML, JavaScript, and CSS. You can compile your own gadgets based on your needs and put them on your igoogle homepage or in some containers such as the Orkut website. The following is a sample tool provided by Google:

Code
<? XML version = "1.0" encoding = "UTF-8" ?>

module >
moduleprefs title =" Magic decoder " />
content type =" html " >
[CDATA [

// The Gadget version of rot13.
// Encodes/decodes text strings by replacing each letter with the letter
// 13 positions to the right in the alphabet.
Function decodemessage (form ){
VaR alpha = "abcdefghijklmnopqrstuvwxyz ";
VaR input = form. inputbox. value;
VaR Achar;
VaR message = "";
For (VAR I = 0; I < Input . Length; I ++)
{
Achar = Input. charat (I );
VaR Index = Alpha. indexof (Achar. tolowercase ());

// If a non-alphabetic character, just append to string
If (Index=-1)
{
Message += Achar;
}

// If you have to wrap around the end of the alphabet
Else if (Index > 12) {// compensate for 0-based index
Index = 25-index; // last item in array is at [25]
Index = 12-index; // Because array starts with 0
Achar = Alpha. charat (INDEX);
message + = Achar;
}

// If You Don't Have To wrap
Else {
Achar = Alpha. charat (index + 13 );
Message + = Achar;
}
}
Document. getelementbyid ('content _ Div '). innerhtml ="< B > Your message: </ B > "+ Message;
}
</ Script >

< Form Name = "Myform" Action = "" Method = "Get" > Message: < BR > < Input Type = "Text" Name = "Inputbox" Value = "" > < P > < Input Type = "Button" Name = "Button" Value = "Transform" Onclick = "Decodemessage (this. Form )" >
</ Form >
< Div ID = "Content_div" > </ Div >
]>
</ Content >
</ Module >

In this example, the tool application of rot13 is used. In rot13, each letter in the alphabet is replaced by a letter separated by 13 characters to encrypt the text. When you reuse rot13, it repeats each letter again to restore the original text.

Set this sectionCodeCopy to the GGE editor provided by Google, and put GGE on the homepage of my igoogle account for convenience.

Do not make any changes to the Code. Click the preview tab on GGE,

Enter "aabbcc ":

This is a simple tool.Source codeHosted on Google or any network server, you can add gadgets to Google,

Click "add"

 

Click "OK" to publish the tool to Google.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.