2

我正在研究 gmail 上下文小工具。为了创建我的第一个“Hello World”小工具,我从https://developers.google.com/google-apps/gmail/contextual_gadgets复制了代码 并做了完全相同的事情。下面是 manifest.xml 和 gadget.xml:

1.manifest 


    <?xml version="1.0" encoding="UTF-8" ?>
        <ApplicationManifest xmlns="http://schemas.google.com/ApplicationManifest/2009">

      <!-- Support info to show in the marketplace & control panel --> 
       <Support>    
      </Support>  <!-- Name and description pulled from message bundles -->  

       <Name>HelloWorld</Name>  
       <Description>A simple Hello World application for testing  Gmail contextual gadgets</Description>  
       <!-- Show this link in Google's universal navigation for all users -->  





       <!-- EXTRACTOR -->
       <Extension id="HelloWorldExtractor" type="contextExtractor">  
       <Name>Hello World</Name>  
       <Url>google.com:HelloWorld</Url>  
       <!-- Uncomment this Param to apply a filter to the extractor's  default output. The example regexp below makes the match case sensitive.  <Param name="hello" value="H[a-z]* W[a-z]*"/> -->  
       <Triggers ref="HelloWorldGadget"/>  
       <Scope ref="emailSubject"/>  
       <Scope ref="emailBody"/>  
       <Container name="mail"/></Extension>

       <!-- GADGET -->
       <Extension id="HelloWorldGadget" type="gadget">  
       <Name>Hello World Gmail contextual gadget</Name>  
       <Url>http://xxxx.com/gadget.xml</Url>  
       <Container name="mail"/>  
       <!-- Uncomment this to enable Caja. -->  
       <!-- <Param name="caja" value="enabled"/> -->
       </Extension>

       <!-- SCOPE -->
       <Scope id="emailSubject">  
       <Url>tag:google.com,2010:auth/contextual/extractor/SUBJECT</Url>  
       <Reason>This application searches the Subject: line of each email  for the text "Hello World."</Reason>
       </Scope><Scope id="emailBody">  
       <Url>tag:google.com,2010:auth/contextual/extractor/BODY</Url>  
       <Reason>This application searches the message body of each email  for the text "Hello World."</Reason>
       </Scope></ApplicationManifest>


2. gadget.xml:
<?xml version="1.0" encoding="UTF-8"?>

<Module>  
<ModulePrefs title="Hello World"    description="Matches and echoes 'Hello World' string in emails"    height="20"    author="Sarah M and Walter Q"    author_email="..."    author_location="Mountain View, CA">
    <!-- Declare feature dependencies. -->    
    <!-- This one is not specific to Gmail contextual gadgets. -->    
    <Require feature="dynamic-height"/>    
    <!-- The next feature, Caja, is optional, and is supported for     use only within test domains. Uncomment the tag only for     non-production gadgets. -->
    <!-- <Require feature="caja"/> -->    <!-- The next feature, google.contentmatch, is required for all     Gmail contextual gadgets.     
    <Param> - specify one or more comma-separated extractor IDs in     a param named "extractors". This line is overridden by the extractor ID     in the manifest, but is still expected to be present. -->    
    <Require feature="google.contentmatch">      
    <Param name="extractors">        google.com:HelloWorld      </Param>    
    </Require>  </ModulePrefs>  
    <!-- Define the content type and display location. The settings   "html" and "card" are required for all Gmail contextual gadgets. -->  
    <Content type="html" view="card">    
    <![CDATA[      
    <!-- Start with Single Sign-On -->      
    <script type="text/javascript"></script>      
    <script type="text/javascript">        
    <!-- Fetch the array of content matches. -->        

    matches = google.contentmatch.getContentMatches();        
    var matchList = document.createElement('UL');        
    var listItem;        
    var extractedText;        
    <!-- Iterate through the array and display output for each match. -->        
    for (var match in matches) {          
        for (var key in matches[match]) {            
            listItem = document.createElement('LI');            
            extractedText = document.createTextNode(key + ": " + matches[match][key]);            
            listItem.appendChild(extractedText);            
            matchList.appendChild(listItem);          
        }        
    }        
    document.body.appendChild(matchList);        
    gadgets.window.adjustHeight(100);      
    </script>    
  ]]>  </Content></Module>

但我得到了一些 javascript 错误:

  1. 'Date' 未定义 2.'unescape' 未定义
  2. 无法获取属性“setMessages_”的值:对象为空或未定义
  3. 无法获取属性“getContentMatches”的值:对象为空或未定义
4

0 回答 0