Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/history #441

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,52 @@ spf.cache.remove = function(key) {};
spf.cache.clear = function() {};


/**
* Namespace for history handling functions.
* @namespace
*/
spf.history = {};


/**
* Add a history entry.
*
* @param {?string=} opt_url The URL associated with this entry to display in
* the browser. This can be either a relative or an absolute URL, and if
* omitted, the current browser URL will be used.
* @param {Object=} opt_state The state object associated with this history
* entry. When the user returns to this entry, the "state" property of the
* event will contain a copy of this object.
* @param {boolean=} opt_doCallback Whether to do the history event callback.
* @throws {Error} If the state object is too large. For example, Firefox will
* pass the object to JSON.stringify and impose a 640k character limit.
* @throws {Error} If the URL is not in the same domain, a SECURITY_ERR
* (code == 18) is thrown.
* @throws {Error} If window.history.pushState is not a function.
*/
spf.history.add = function(opt_url, opt_state, opt_doCallback) {};


/**
* Replace the current history entry, merging any newly provided state values
* with existing ones.
*
* @param {?string=} opt_url The URL associated with this entry to display in
* the browser. This can be either a relative or an absolute URL, and if
* omitted, the current browser URL will be used.
* @param {Object=} opt_state The state object associated with this history
* entry. When the user returns to this entry, the "state" property of the
* event will contain a copy of this object.
* @param {boolean=} opt_doCallback Whether to do the history event callback.
* @throws {Error} If the state object is too large. For example, Firefox will
* pass the object to JSON.stringify and impose a 640k character limit.
* @throws {Error} If the URL is not in the same domain, a SECURITY_ERR
* (code == 18) is thrown.
* @throws {Error} If window.history.replaceState is not a function.
*/
spf.history.replace = function(opt_url, opt_state, opt_doCallback) {};


/**
* Namespace for script-loading functions.
* @namespace
Expand Down
7 changes: 7 additions & 0 deletions src/client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ spf.main.extra_ = {
// * Clear all entries.
'clear': spf.cache.clear
},
'history': {
// History API.
// * Add a history entry.
'add': spf.history.add,
// * Replace the current history entry
'replace': spf.history.replace
},
'script': {
// The bootloader API.
// * Load scripts.
Expand Down