app/script.js
/* Adds a new note and stores it on the server. */
Adds a new note and stores it on the server.
Adds a new note and stores it on the server .
function addnote() {
    $('#message').hide();
    var text = $('#newtext').val();
    if(!text)  return;
    nive.DataStorage({name:'notes'}).newItem({key:'note', value:text})
        .done(function (data, message, xhr) {
            number_stored = data.result;
            $('#newtext').val('');
            $('#message span').html('Note stored!');
            $('#message').show('fast');
            loadnotes(1);
        })
        .fail(function (jqXHR, message, error) {
            if(jqXHR.status=='403') {
                $('#message span').html('Please sign in!');
                $('#message').show('fast');
            } else {
                $('#message span').html('Sorry! ' + error + '. ' + jqXHR.responseJSON.error);
                $('#message').show('fast');
            }
        });
}
function addnote ( ) { $ ( '#message' ) . hide ( ) ; var text = $ ( '#newtext' ) . val ( ) ; if ( ! text ) return ; nive . DataStorage ( { name : 'notes' } ) . newItem ( { key : 'note' , value : text } ) . done ( function ( data , message , xhr ) { number_stored = data . result ; $ ( '#newtext' ) . val ( '' ) ; $ ( '#message span' ) . html ( 'Note stored!' ) ; $ ( '#message' ) . show ( 'fast' ) ; loadnotes ( 1 ) ; } ) . fail ( function ( jqXHR , message , error ) { if ( jqXHR . status == '403' ) { $ ( '#message span' ) . html ( 'Please sign in!' ) ; $ ( '#message' ) . show ( 'fast' ) ; } else { $ ( '#message span' ) . html ( 'Sorry! ' + error + '. ' + jqXHR . responseJSON . error ) ; $ ( '#message' ) . show ( 'fast' ) ; } } ) ; }
Adds a new note and stores it on the server.
Adds a new note and stores it on the server .
// stores a new note based on the entries in the first note block. // success: text has been stored // error: something went wrong