WanaPlan

API Docs for: 2.7.0
Show:

SA_DatabaseManager

Module: Component
Parent Module: Wanaplan

Summary

An IndexedDB database manager. The constructor will try to normalize all prefixed objects.

Constructor

SA_DatabaseManager

Syntax

SA_DatabaseManager

()

Summary

Methods

clear

Syntax

clear

(
  • success
  • error
)

Summary

Clear all plans from the database.

Parameters:

  • success Function

    A function called when the process is done.

  • error Function

    A function called when an error occured.

initialize

Syntax

initialize

(
  • success
  • error
)

Summary

Initialize the manager. If the object store doesn't exists then it's created. The success callback is called when all operations are done.

Parameters:

  • success Function

    A function called when the manager is ready.

  • error Function

    A function called when an error occured.

isAvailable

Syntax

isAvailable

() Boolean

Summary

Indicates whether IndexedDB is available or not in the user's browser.

Returns:

Boolean:

Returns true if available otherwise it returns false.

loadItem

Syntax

loadItem

(
  • id
  • success
  • error
)

Summary

Load a structure of the specified plan.

Parameters:

  • id Number

    The plan's id

  • success Function

    A function called when the process is done.

  • error Function

    A function called when an error occured.

loadItems

Syntax

loadItems

(
  • success
  • error
)

Summary

Loads all plans from the database without their structures (id, name, screenshot). If you want to load structures too then you need to set the complete parameter to true. An array of plans objects is available in the first callback parameter.

Parameters:

  • success Function

    A function called when the process is done.

  • error Function

    A function called when an error occured.

removeItem

Syntax

removeItem

(
  • id
  • success
  • error
)

Summary

Remove a plan from the database.

Parameters:

  • id Number

    The plan's id to delete.

  • success Function

    A function called when the process is done.

  • error Function

    A function called when an error occured.

saveItem

Syntax

saveItem

(
  • plan
  • success
  • error
)

Summary

Save a plan into the database. The plan's id is updated. The structure of the object stored is:

  • id {Number} If it isn't set then a new record is created otherwise it's updated.
  • name {String} The plan's name.
  • structure {String} A serialized string of the structure.
  • screenshot {String} A base64 string.

Parameters:

  • plan Object

    The plan to save.

  • success Function

    A function called when the process is done.

  • error Function

    A function called when an error occured.