Changeset 884

Show
Ignore:
Timestamp:
02/25/08 07:15:43
Author:
goldoraf
Message:

More work on notifier demo app

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • apps/notifier/app/resources/users_resource.php

    r882 r884  
    1111            $this->responds_created($user); 
    1212        else 
    13             $this->responds_nothing(400); 
     13            $this->responds_error($user->errors, 400); 
    1414    } 
    1515} 
  • apps/notifier/app/views/test/index.php

    r882 r884  
    3939            <input type="submit" onclick="notifier.api.sendNote($('#note_text').val(), notifier.ui.prependNote);"  
    4040                                 value="Envoyer" /> 
    41             <a href="#" onclick="notifier.api.publicTimeline(notifier.ui.refreshFriendsTimeline);">Actualiser</a> 
     41            <a href="#" onclick="notifier.actions.refreshFriendsTimeline();">Actualiser</a> 
    4242            <div id="friends-timeline"></div> 
    4343        </div> 
  • apps/notifier/public/js/notifier.js

    r882 r884  
    88notifier.actions = {}; 
    99notifier.actions.login = function() { 
    10          
     10        $('#login').hide(); 
     11    $('#main').show(); 
    1112} 
    1213notifier.actions.register = function() { 
     
    2425        } 
    2526    }); 
     27} 
     28notifier.actions.refreshFriendsTimeline = function() { 
     29     
    2630} 
    2731 
     
    5862        params: {}, 
    5963        authenticate: false, 
    60         success: null 
     64        success: null, 
     65        error: null 
    6166    }; 
    6267    if (options == null) options = {}; 
     
    8792                var data = null; 
    8893            } 
    89             if (options.callback !== null) { 
    90                 options.callback(data, status); 
     94            if (options.success !== null) { 
     95                options.success(data, status); 
    9196            } 
    9297        }, 
    9398        error: function (xhr, status, error) { 
    94             alert("Erreur "+xhr.status+" !\n\n"+error); 
     99            try { 
     100                error = eval('(' + xhr.responseText + ')'); 
     101            } catch (e) { 
     102                error = error; 
     103            } 
     104            if (options.error !== null) { 
     105                options.error(data, status); 
     106            } else { 
     107                var str = "Erreur "+xhr.status+" !\n\n"; 
     108                for (var key in error) { 
     109                    str += key+': '+error[key]+"\n"; 
     110                } 
     111                alert(str); 
     112            } 
    95113        } 
    96114    }