This documentation describes how Yote programs are written, and what idioms are used.
The following scripts should be included in any yote page. Yote relies on jquery and the javascript is not yet minified at the time of this writing.
<script src="/yote/js/jquery-latest.js"></script>
<script src="/yote/js/jquery.cookie.js"></script>
<script src="/yote/js/jquery.base64.min.js"></script>
<script src="/yote/js/json2.js"></script>
<script src="/yote/js/yote.js"></script>
Including these provides $.yote which contains the methods needed to interact with the server.
To get started using a yote app, simply invoke init, then get the
app singleton object. Each app has a singleton that provides methods for the app
and stores information specific to it. Putting all yote code inside the jquery $().ready
function is recommended.
$.yote.init(); //connects the front end objects to the backend
//returns the singleton app object.
var app = $.yote.fetch_app( 'MyApp' );
Some apps do not need to store information on a per user basis, but some do.
Yote provides methods to create and manage user accounts and logins. There are
four different login related methods attached to the $.yote.
Note: All the handlers below are optional.
var login = $.yote.login( 'handle', 'password', pass_handler, fail_handler );
var login = $.yote.create_login( 'handle', 'password', 'email', pass_handler, fail_handler );
$.yote.remove_login( 'handle', 'password', 'email', pass_handler, fail_handler );
$.yote.logout();
All methods on yote objects have the same method signature and take four optional arguments.
var return_value = yote_obj.some_method(
parameter, // this can be undefined, a scalar, a yote object, an array or an object ( hash )
passhandler, // this is a function that is invoked upon completion and given the return value as an argument
failhandler, // this is a function that is invoked upon error and is passed the error message as an argument
use_async // when true, this method is called asyncronously
);
Yote core javascript has four main tasks that will be covered in detail in this document. Much of the client side mirrors the server side, so both the server side documentation and the client side documentation will have necessary overlap.
Yote javascript objects are provided with methods that mirror server side methods. Each method attached to a javascript yote object has the same parameter list and all parameters are optional. The methods are called syncronously be default but any may be called asyncronously.
There are a few types of server side objects that always may exist for the system. These objects have special methods that return them. Think of these as the primary building blocks of a yote app.
A yote login is composed of credentials that uniquely identify a user. A yote login is global across all apps. Each app, however, has a different account for every login. The account is a bundle of data that is specific to an app and a user. This distinction is important.
Emails and handles are unique for logins. Login objects are like any other Yote object and any sort of data can be stored in them. There are a number of methods that are attached to the yote objects.
var login = $.yote.create_login( handle, password, email, passhandler, failhandler );
// handle, password and email are required
// passhandler and failhandler are optional functions that are run if
// the login creation succeeds or fails.
var login = $.yote.login( handle, password, email, passhandler, failhandler );
// handle, password and email are required
// passhandler and failhandler are optional functions that are run if
// the login creation succeeds or fails.
login.reset_password( { op => oldpassword, p => newpass, p2 => newpassverify } );