WebWidgets.io Admin Console Python Scripts Your First Widget JavaScript API Google Export

API Docs for JavaScript File WidgetMainApi.js

Go to file:

Auto-Extracted Documentation

The following information is automatically extracted from the JS code files. Methods and variables that begin with the double underscore ("__") are considered to be part of the private API of the library.

    • Map of of username::widgetname --> Unix checksum for the Widget DB
    • Sept 2022: removing old naive checksum technique
    • __databaseCheckSum : {},

  • MAX_GET_PARAM_VALUE : 2000,
    • https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
    • Could actually be much smaller than this

  • lookupItem : function(tabname, itemid)
    • Find the item with the given ID for the given table and return it.
    • Error if the item does not exist, if you are uncertain whether the ID exists or not,
    • call haveItem(tabname, itemid)

  • getItemList : function(tabname)
    • Get the full list of records associated with given table.
    • This is one of the most fundamental operations of the framework.
    • Error if the table name is not loaded on the current page.
    • If you are uncertain if the table will be present, use haveTable(...) to check

  • buildItem : function(tabname, record)
    • Create a new record for the given table.
    • The record argument is a hash with keys corresponding to the column names of the table.
    • It is optional to provide the "id" column, if you do not provide it, the framework
    • will allocate a new id and assign it to the record.
    • Other than the id column, all columns must be explicitly provided.
    • IMPORTANT: this method creates the record but does not sync it to the server.
    • To sync, call syncItem on the returned JS representation of the record.

  • haveItem : function(tabname, itemid)
    • Check if the given table has an item with the given ID.
    • This is logically equivalent to calling getItemList
    • and checking each record to see if it has the ID,
    • but is faster because it uses the index on the table.

  • haveTable : function(tabname)
    • Return true if the table is in the data for the page.

  • getTableOwner : function(tabname)
    • Return the owner of the given table

  • haveWriteAccess : function(tabname)
    • True if the current user has write access to the given table
    • Widgets that serve multiple users, some of whom have write access and some of whom do not,
    • should check this function before displaying UI options that will perform write actions.
    • The backend will disallow such writes anyway, but it will be a less pleasing user experience

  • getWidgetTableList : function()
    • Get all the tables that have been registered on this page.

  • newBasicId : function(tabname)
    • Creates a new ID for the given table name.
    • This method is no longer recommended, you should let the framework
    • assign a new ID and then call getId() on the resulting object.

  • serverSideNewDbId : function(tabname, callback)
    • Queries the server to obtain a new unused database ID for the given table
    • In other words, this is a server-side version of newBasicId(...)
    • It is generally better to use the client-side version. This method is intended to be used
    • in cases where you do not have all the records for the given table loaded in the client
    • For example, if you use the no_data=true option to load the table manager without loading any records

  • getBlobStoreUrl : function(username, widgetname, tablename, recordid)
    • Gets the Blob Store URL for the given item
    • NOTE: you should not use this function directly, instead call method with same name, but no arguments
    • that is attached to the Widget Blob item
    • Example : W.lookupItem("my_blob_table", itemid).getBlobStoreUrl()

  • checkTableName : function(tabname)
    • Checks that the given table name exists and is loaded.
    • Error if it is not.

  • __getListFuncMap : {},
    • Map of table name to get full item list

  • __buildItemFuncMap : {},
    • table name to builder function

  • __readOnlyAccess : [],
    • List of tables for which the current user has read access only

  • __tableNameIndex : new Map(),
    • Map of short table name to Widget Table objects

  • __augmentWithCheckSum : function(opurl)
    • Look up the widget owner and name from the url
    • Use that info to find the current checksum value
    • This needs to be looked up just-in-time, before the request is sent,
    • AFTER it is enqueued