Changeset 2113


Ignore:
Timestamp:
07/15/10 19:22:52 (19 months ago)
Author:
dart
Message:

Loreality:
o First JSON communication

Location:
trunk/loreality
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/loreality/loreality/controllers/messager.py

    r2112 r2113  
    7272 
    7373        messages = pilot.messages  
    74         buf = "" 
     74        res = { 'messages':[] } 
     75 
    7576 
    7677        for m in messages: 
    77             buf += "%(date)s#%(from_)s#%(subject)s|"%m.__dict__ 
    78         if buf: 
    79             buf = buf[:-1] 
    80         return buf 
     78            p = pilot_q.filter_by(id=m.from_).first() 
     79            res['messages'].append({ 'date': m.date.strftime("%c"), 'from':p.name, 'subject':m.subject }) 
     80        return res 
    8181    #-------------------------------------------------------------- 
    8282    def getmsg(self, id): 
  • trunk/loreality/loreality/templates/base/index.html

    r2112 r2113  
    1111<head> 
    1212${ h.stylesheet_link( '/style.css') } 
    13 ${ h.javascript_link( '/dojo/dojo/dojo.js', djConfig="parseOnLoad: true") } 
    14  <script type="text/javascript"> 
     13  <style type="text/css"> 
     14      @import "dojoroot/dijit/themes/tundra/tundra.css"; 
     15      @import "dojoroot/dojo/resources/dojo.css"; 
     16  </style> 
     17 
     18${ h.javascript_link( '/dojo/dojo/dojo.js',  djConfig="parseOnLoad: true") } 
     19<script type="text/javascript"> 
    1520     // Load Dojo's code relating to the Button widget 
    1621     dojo.require("dijit.form.Button"); 
     22     dojo.require("dijit.Editor"); 
    1723     dojo.require("dojo.fx"); 
    1824     dojo.require("dojo.html"); 
     25     dojo.require("dojox.json.ref"); 
    1926  </script> 
    2027 
     
    2229    ${self.head()} 
    2330</head> 
    24 <body> 
    25  
     31<body  class="tundra"> 
    2632    <div id="hd"> 
    2733        <div class="yui-gc"> 
  • trunk/loreality/loreality/templates/derived/page/messager.html

    r2112 r2113  
    3737        alert("Error"); 
    3838        }else{ 
     39        objects = dojox.json.ref.fromJson(data); 
     40        messages = objects['messages']; 
     41 
    3942        var buffer = ""; 
    40         messages = data.split("|"); 
    4143        for (i = 0; i < messages.length; i += 1) { 
    42             buffer += "<tr>"; 
    43             elements = messages[i].split("#"); 
    44             for (n = 0; n < elements.length; n += 1 ){ 
    45                 buffer += "<td>" + elements[n] + "</td>"  
    46             } 
    47             buffer += "</tr>"; 
     44            msg = messages[i]; 
     45            buffer += "<tr><td>" + msg['date'] + '</td><td>' + msg['from'] + '</td><td>' + msg['subject'] +"</td></tr>"  
    4846        } 
    4947        dojo.html.set("message_table", buffer); 
Note: See TracChangeset for help on using the changeset viewer.