小工具的编写其实很简单,不需要什么很深的技术,懂html、javascript、css等就可以别写自己的小工具。可以根据自己的需要编写适用于自己的小工具然后把它方在自己的igoogle主页上或者orkut网站等一些容器内。下面这个小工具源码是google提供的小工具示例:


  <ModulePrefs title="Magic Decoder"/> 
  
<Content type="html">
  
<![CDATA[
     <script type="text/javascript"
>

       // 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>

这个例子是 ROT13 的小工具应用。ROT13 用字母表中每个字母相隔 13 个位置的字母进行替换来加密文本。当您重新运用 ROT13 时,它将再次循环每个字母以恢复原始文本。

把这段代码复制到google提供的编辑器GGE中,为了方便我把GGE放在了我在igoogle帐户的首页。

学习 Google Gadgets (三)

不要对代码做任何更改,直接点击GGE上面的Preview选项卡,

学习 Google Gadgets (三)

输入“aabbcc":

学习 Google Gadgets (三)

这就是一个简单的小工具,只需要把这个小工具的源代码托管在google或者是任何一台网络服务器上,然后就可以向google添加小工具了,

学习 Google Gadgets (三)

点击“添加”

 学习 Google Gadgets (三)

单击“确定”即可把此小工具发布到google。

相关文章:

  • 2022-12-23
  • 2022-02-15
  • 2021-08-19
  • 2021-08-20
  • 2021-07-30
  • 2022-12-23
  • 2021-12-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
  • 2021-07-26
  • 2022-01-13
相关资源
相似解决方案