Skip to content

Commit

Permalink
Updated code documentation #12
Browse files Browse the repository at this point in the history
  • Loading branch information
andersevenrud committed Jan 17, 2015
1 parent a71c86b commit 91a4568
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/javascript/helpers/default-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
* You need to implement this in your application.
* For an example see the 'Textpad' application
*
* TODO Rename to onCheckChanged()
*
* @return boolean If the document has changed
*
* @method DefaultApplicationWindow::checkChanged()
Expand Down Expand Up @@ -315,6 +317,8 @@
/**
* When requesting check for if file has changed
*
* TODO: Rename to _onCheckChanged()
*
* @param Function callback Callback function => fn(discard)
*
* @return void
Expand Down
69 changes: 69 additions & 0 deletions src/javascript/helpers/google-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@

var SingletonInstance = null;

/**
* The GoogleAPI wrapper class
*
* This is a private class and can only be aquired through
* OSjs.Helpers.GoogleAPI.createInsatance()
*
* Generally you want to create an instance of this helper
* and when successfully created use `window.gapi`.
*
* @link https://developers.google.com/api-client-library/javascript/start/start-js
* @link https://developers.google.com/api-client-library/javascript/
* @link https://console.developers.google.com/project
*
* @see OSjs.Helpers.GoogleAPI.createInsatance()
* @api OSjs.Helpers.GoogleAPI.GoogleAPI
*
* @private
* @class
*/
function GoogleAPI(clientId) {
this.clientId = clientId;
this.accessToken = null;
Expand All @@ -56,9 +75,15 @@
];
}

/**
* Destroy the class
*/
GoogleAPI.prototype.destroy = function() {
};

/**
* Initializes (preloads) the API
*/
GoogleAPI.prototype.init = function(callback) {
callback = callback || function() {};
var self = this;
Expand All @@ -74,6 +99,9 @@
}
};

/**
* Loads the API
*/
GoogleAPI.prototype.load = function(load, scope, callback) {
load = (['auth:client']).concat(load);

Expand Down Expand Up @@ -105,6 +133,15 @@
});
};

/**
* Sign out of GoogleAPI
*
* @param Function cb Callback => fn(error, result)
*
* @return void
*
* @method GoogleAPI::signOut()
*/
GoogleAPI.prototype.signOut = function(cb) {
cb = cb || function() {};

Expand Down Expand Up @@ -132,6 +169,15 @@
cb(false, true);
};

/**
* Revoke Google permissions for this app
*
* @param Function cb Callback => fn(error, result)
*
* @return void
*
* @method GoogleAPI::revoke()
*/
GoogleAPI.prototype.revoke = function(callback) {
console.info('GoogleAPI::revoke()');

Expand All @@ -152,6 +198,9 @@
});
};

/**
* Authenticates the user
*/
GoogleAPI.prototype.authenticate = function(scope, callback) {
console.info('GoogleAPI::authenticate()');

Expand Down Expand Up @@ -238,10 +287,30 @@

OSjs.Helpers.GoogleAPI = OSjs.Helpers.GoogleAPI || {};

/**
* Gets the currently running instance
*
* @api OSjs.Helpers.GoogleAPI.getInstance()
*
* @return GoogleAPI Can also be null
*/
OSjs.Helpers.GoogleAPI.getInstance = function() {
return SingletonInstance;
};

/**
* Create an instance of GoogleAPI
*
* @param Object args Arguments
* @param Function callback Callback function => fn(error, instance)
*
* @option args Array load What functions to load
* @option args Array scope What scope to load
*
* @api OSjs.Helpers.GoogleAPI.createInstance()
*
* @return void
*/
OSjs.Helpers.GoogleAPI.createInstance = function(args, callback) {
var load = args.load || [];
var scope = args.scope || [];
Expand Down
84 changes: 76 additions & 8 deletions src/javascript/helpers/windows-live-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@
* @licence Simplified BSD License
*/

// http://msdn.microsoft.com/en-us/library/hh826547.aspx
// http://msdn.microsoft.com/en-us/library/hh826538.aspx
// http://msdn.microsoft.com/en-us/library/hh550837.aspx
// http://msdn.microsoft.com/en-us/library/dn631844.aspx
//
// http://msdn.microsoft.com/en-us/library/dn631839.aspx
// http://msdn.microsoft.com/en-us/library/hh243643.aspx

(function(Utils, API) {
'use strict';

Expand All @@ -52,6 +44,30 @@

var SingletonInstance = null;


/**
* The WindowsLiveAPI wrapper class
*
* This is a private class and can only be aquired through
* OSjs.Helpers.WindowsLiveAPI.createInsatance()
*
* Generally you want to create an instance of this helper
* and when successfully created use `window.WL`.
*
* @see OSjs.Helpers.WindowsLiveAPI.createInsatance()
* @api OSjs.Helpers.WindowsLiveAPI.WindowsLiveAPI
*
* @link http://msdn.microsoft.com/en-us/library/hh826547.aspx
* @link http://msdn.microsoft.com/en-us/library/hh826538.aspx
* @link http://msdn.microsoft.com/en-us/library/hh550837.aspx
* @link http://msdn.microsoft.com/en-us/library/dn631844.aspx
* @link http://msdn.microsoft.com/en-us/library/dn631839.aspx
* @link http://msdn.microsoft.com/en-us/library/hh243643.aspx
* @link https://account.live.com/developers/applications/index
*
* @private
* @class
*/
function WindowsLiveAPI(clientId) {
this.hasSession = false;
this.clientId = clientId;
Expand All @@ -65,9 +81,15 @@
}];
}

/**
* Destroy the class
*/
WindowsLiveAPI.prototype.destroy = function() {
};

/**
* Initializes (preloads) the API
*/
WindowsLiveAPI.prototype.init = function(callback) {
callback = callback || function() {};
var self = this;
Expand All @@ -83,6 +105,9 @@
}
};

/**
* Loads the API
*/
WindowsLiveAPI.prototype.load = function(scope, callback) {
console.debug('WindowsLiveAPI::load()', scope);

Expand Down Expand Up @@ -170,6 +195,15 @@
}
};

/**
* Sign out of WindowsLiveAPI
*
* @param Function cb Callback => fn(error, result)
*
* @return void
*
* @method WindowsLiveAPI::logout()
*/
WindowsLiveAPI.prototype.logout = function(callback) {
callback = callback || function() {};

Expand All @@ -193,6 +227,9 @@
}
};

/**
* Authenticates the user
*/
WindowsLiveAPI.prototype.login = function(scope, callback) {
var self = this;
if ( this.hasSession ) {
Expand All @@ -214,6 +251,9 @@
});
};

/**
* If the API session was changed
*/
WindowsLiveAPI.prototype.onSessionChange = function() {
console.warn('WindowsLiveAPI::onSessionChange()', arguments);
var session = WL.getSession();
Expand All @@ -224,6 +264,9 @@
}
};

/**
* When user logged in
*/
WindowsLiveAPI.prototype.onLogin = function() {
console.warn('WindowsLiveAPI::onLogin()', arguments);
this.hasSession = true;
Expand All @@ -240,12 +283,18 @@
}
};

/**
* When user logs out
*/
WindowsLiveAPI.prototype.onLogout = function() {
console.warn('WindowsLiveAPI::onLogout()', arguments);
this.hasSession = false;
this._removeRing();
};

/**
* When API sends a log message
*/
WindowsLiveAPI.prototype.onLog = function() {
console.debug('WindowsLiveAPI::onLog()', arguments);
};
Expand All @@ -256,10 +305,29 @@

OSjs.Helpers.WindowsLiveAPI = OSjs.Helpers.WindowsLiveAPI || {};

/**
* Gets the currently running instance
*
* @api OSjs.Helpers.WindowsLiveAPI.getInstance()
*
* @return WindowsLiveAPI Can also be null
*/
OSjs.Helpers.WindowsLiveAPI.getInstance = function() {
return SingletonInstance;
};

/**
* Create an instance of WindowsLiveAPI
*
* @param Object args Arguments
* @param Function callback Callback function => fn(error, instance)
*
* @option args Array scope What scope to load
*
* @api OSjs.Helpers.WindowsLiveAPI.createInstance()
*
* @return void
*/
OSjs.Helpers.WindowsLiveAPI.createInstance = function(args, callback) {
args = args || {};

Expand Down

0 comments on commit 91a4568

Please sign in to comment.