使用導引
, 介接
, 文件狀態:維護中
Chih-Yang Huang, 黃志揚
2020
DocuWidgets are consisted of several DocuSky widgets in the form of JavaScript packages. It is convenient for developers to access data from DocuSky server. If you want to learn more about theory and concept, please read this paper.
We provide some Web APIs for web tool developers to upload and retrieve data from DocuSky server. The developers could utilize those APIs to control session status of users, database lists, database queries, and to upload as well as to download data. Additionally, we wrap the APIs as DocuSky widgets. Thus, the developers could use those widgets as an interface to access and control data in a more convenient manner, which means developers do not need to cope with the format of Web APIs, and they can get data as objects directly. For these APIs to operate correctly, it is required jQuery library loaded for DocuSky widgets to process layout settings, so remember to include it before using DocuWidgets.
Currently, we provide three DocuSky widgets for developers to use.
General users can process their data in the format of DocuXml, JSON, CSV, TXT, etc., and among which, DocuXML is the most important format for DocuSky server for its fruitful information. DocuXML consists of the corpora, documents as well as our enriched metadata. To handle DocuXML's rich information, we designed two widgets for it. One is docusky.ui.manageDbListSimpleUI.js, and the other is docusky.ui.getDbCorpusDocumentsSimpleUI.js. For other data formats such as JSON, CSV, and TXT, they are accessible through docusky.ui.manageDataFileListSimpleUI.js.
This widget provides the function of uploading DocuXML to a database and database renaming/deletion.
In addition, account information and friendship management are in the widget.
The main idea of this widget is to get corpus/documents, post-classification, and tag-analysis from DocuSky.
Users need to specify some parameter before their queries, so we provide some clever functions where developers can choose their scenario. Additionally, we also offer the function of updating document in it.
Except DocuXML, all other formats of files are handled, including the upload/retrieval/renaming/deletion features, through this widget. Other DocuTools such as DocuGIS and GeoPort also utilize this widget to handle tasks like storing GIS positions, lexicon and some information for files other than the DocuXML format.
Before writing any code to integrate DocuSky via DocuWidgets, please follow the following steps on your page:
Include jQuery between <head></head>
in HTML
If you want to use docusky.ui.manageDbListSimpleUI.js, include
after jQuery library.
If you want to use docusky.ui.getDbCorpusDocumentsSimpleUI.js, include
after jQuery library.
If you want to use docusky.ui.manageDataFileListSimpleUI.js, include
after jQuery library.
You could activate the widgets' UI by the following example.
If you want to get all documents in a database, please refer to this section.
If you want to know the specifications of a document in docuskyGetDbCorpusDocumentsSimpleUI.docList
, please refer to this documentation.
To get user information, user friendship, or to upload DocuXML to a database as well as rename/delete the database, you need to use this widget.
docuskyManageDbListSimpleUI.loginSuccFunc
If the user didn't login, the widget will force the user to login. After logging in, it will execute docuskyManageDbListSimpleUI.loginSuccFunc
. For example, it could be as following:
docuskyManageDbListSimpleUI.loginFailFunc
If the user didn't login, the widget will force the user to login. If log in fails, docuskyManageDbListSimpleUI.loginFailFunc
will be executed. For example, it could be used as following:
docuskyManageDbListSimpleUI.Error
This is a global property for the developers to set a callback function when functions in this widget occurrs an error. If you invoke a function without setting a fail(error)
callback function in the argument, docuskyManageDbListSimpleUI.Error
will be invoked. docuskyManageDbListSimpleUI.Error
will receive Connection Error
or Server Error
when an error occurred. For example, it could be used as following:
docuskyManageDbListSimpleUI.uploadProgressFunc
This is a global property for the developers to set a callback function for uploading DocuXML. If docuskyManageDbListSimpleUI.uploadMultipart
is invoked for uploading DocuXML successfully, docuskyManageDbListSimpleUI.uploadProgressFunc
will receive the progress percentage of uploading. For example, it could be used as following:
docuskyManageDbListSimpleUI.maxResponseTimeout
This is the value of maxResponseTimeout
for uploading DocuXML via docuskyManageDbListSimpleUI.uploadMultipart
.
The default value is 300000
(5 minutes).
For example, it could be used as following:
docuskyManageDbListSimpleUI.maxRetryCount
If the developers don't set any fail callback function while invoking the functions in this widget, it will retry the invoked function automatically. The number of times of retrial is defined in docuskyManageDbListSimpleUI.maxRetryCount
, and the default value is 10
. For example, it could be used as following:
docuskyManageDbListSimpleUI.login(username, password, succFunc, failFunc)
For user login.
username
Type: String
The username is usually an Email.
password
Type: String
succFunc
Type: Function
The callback function to execute when login is successful.
failFunc
Type: Function
The callback function to execute when login is failed.
docuskyManageDbListSimpleUI.hideWidget(is_hidden)
Hide this widget display on the web. The widget is displayed on the web as default.
is_hidden
Type: Boolean
Whether or not the widget is hidden.
docuskyManageDbListSimpleUI.hideLoadingIcon(is_hidden)
Hide loading icon display on the web. The loading icon is displayed on the web as default.
is_hidden
Type: Boolean
Whether or not the widget is hidden.
docuskyManageDbListSimpleUI.includeFriendDb(is_inclusive)
Show friend's corpus. The default value is false
.
is_inclusive
Type: Boolean
Whether or not the information of friendship is displayed.
docuskyManageDbListSimpleUI.enableWidgetEvent(evtKey, callback)
Set some event callback functions on the widget UI.
evtKey
Type: String
Current events are "dbClick"
, "corpusAttCntClick"
, "corpusClick"
, "attCntClick"
.
callback
Type: Function
A function to execute when the event(evtKey)
is triggered.
docuskyManageDbListSimpleUI.disableWidgetEvent(evtKey)
Disable some event callback functions on the widget UI.
Type: String
Current events are "dbClick"
, "corpusAttCntClick"
, "corpusClick"
, "attCntClick"
.
docuskyManageDbListSimpleUI.setLoadingIcon(url)
Set a loading icon by URL.
url
Type: String
The URL of your icon.
docuskyManageDbListSimpleUI.deleteDb(DbTitle, succFunc, failFunc)
Delete user database by the title of database.
DbTitle
Type: String
succFunc
Type: Function
The callback function to execute when deleting database is successful.
failFunc
Type: Function
The callback function to execute when deleting database is failed.
docuskyManageDbListSimpleUI.renameDbTitle(oldDbTitle, newDbTitle, succFunc, failFunc)
Rename user database by the title of database.
oldDbTitle
Type: String
newDbTitle
Type: String
succFunc
Type: Function
The callback function to execute when renaming database is successful.
failFunc
Type: Function
The callback function to execute when renaming database is failed.
docuskyManageDbListSimpleUI.getUserProfile(evt, succFunc, failFunc)
Get user profile. The data will be sent to succFunc
.
evt
Type: Event
docuskyManageDbListSimpleUI.getUserProfile
will be triggered by an event. If there is no event, it could be null
.
succFunc
Type: Function
The callback function to execute when getting user profile is successful. The data will be passed to succFunc
.
failFunc
Type: Function
The callback function to execute when getting user profile is failed.
docuskyManageDbListSimpleUI.manageDbList(evt, succFunc, failFunc)
Open the widget UI and get the list of databases. The list of databases will be in docuskyManageDbListSimpleUI.dbList
.
evt
Type: Event
docuskyManageDbListSimpleUI.manageDbList
will be triggered by an event. If there is no event, it could be null
.
succFunc
Type: Function
The callback function to execute after putting the list of databases into docuskyManageDbListSimpleUI.dbList
.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyManageDbListSimpleUI.getUserFriendship(param, succFunc, failFunc)
Get the list of friends of the present user. The data will be passed to succFunc
.
param
Type: Object
It is usually {}
.
succFunc
Type: Function
The callback function to execute when getting user friendship is successful. The data will be passed to succFunc
.
failFunc
Type: Function
The callback function to execute when getting user friendship is failed.
docuskyManageDbListSimpleUI.getUserFriendAccessibleDb(param, succFunc, failFunc)
Get the database tuple list that the present user's friends can access. The tuple format is (friend_username, database_title)
. The data will be passed to succFunc
.
param
Type: Object
It is usually {}
.
succFunc
Type: Function
The callback function to execute when it is successful. The data will be passed to succFunc
.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyManageDbListSimpleUI.replaceUserFriendship(param, succFunc, failFunc)
Add the other users as friends.
param
Type: Object
Set the property of param as below.
It will add friend1
, friend2
and friend3
as friends.
succFunc
Type: Function
The callback function to execute when it is successful. The result of this function will be passed to succFunc
.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyManageDbListSimpleUI.replaceUserFriendAccessibleDb(param, succFunc, failFunc)
Assign a database for a friend to access.
param
Type: Object
Set the property of param as below.
It will allow friendUsername
to access userDbName
.
succFunc
Type: Function
The callback function to execute when it is successful. The result will be passed to succFunc
.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyManageDbListSimpleUI.deleteUserFriendship(param, succFunc, failFunc)
Delete friendship between the current user and the assigned user.
param
Type: Object
Set the property of param as below.
It will delete friendship from friend1
, friend2
and friend3
.
succFunc
Type: Function
The callback function to execute when it is successful. The outcome will be passed to succFunc
.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyManageDbListSimpleUI.deleteUserFriendAccessibleDb(param, succFunc, failFunc)
Remove the access of the database from the assigned user .
param
Type: Object
Set the property of param
as below.
It will remove the access of userDbName
from friendUsername
.
succFunc
Type: Function
The callback function to execute when it is successful. The outcome will be passed to succFunc
.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyManageDbListSimpleUI.uploadMultipart(data, succFunc, failFunc, option)
Upload DocuXML.
data
Type: Object
succFunc
Type: Function
The callback function to execute when it is successful.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyManageDbListSimpleUI.utility.setStyle(param)
Set the style of the widget UI.
param
Type: Object
Set the property of param as below.
To get database, corpus, metadata and to modify corpus, you need to use this widget.
docuskyGetDbCorpusDocumentsSimpleUI.loginInvokeFun
If the user didn't login, the widget will ask the user to login. After logging in, it will execute docuskyGetDbCorpusDocumentsSimpleUI.loginInvokeFun
. For example, it could be used as following:
docuskyGetDbCorpusDocumentsSimpleUI.Error
This is a global property for the developers to set a callback function when functions in this widget occurred an error. If you invoke a function without setting a fail(error)
callback function in the argument, docuskyGetDbCorpusDocumentsSimpleUI.Error
will be invoked. docuskyGetDbCorpusDocumentsSimpleUI.Error
will receive Connection Error
or Server Error
when an error occurred. For example, it could be used as following:
docuskyGetDbCorpusDocumentsSimpleUI.maxResponseTimeout
This is the value of maxResponseTimeout
for getting corpora/documents.
The default value is 300000
(5 minutes).
For example, it could be used as following:
docuskyGetDbCorpusDocumentsSimpleUI.maxRetryCount
If the developers don't set any fail callback function while invoking the functions in this widget, it will retry the invoked function automatically. The number of times of retrial is defined as docuskyGetDbCorpusDocumentsSimpleUI.maxRetryCount
, and the default value is 10
. For example, it could be used as following:
docuskyGetDbCorpusDocumentsSimpleUI.setLoadingIcon(url)
Set a loading icon by URL.
url
Type: String
The URL of your icon.
docuskyGetDbCorpusDocumentsSimpleUI.hideLoadingIcon(is_hidden)
Hide loading icon display on the web. The loading icon is displayed on the web as default.
is_hidden
Type: Boolean
Whether or not the icon is hidden.
docuskyGetDbCorpusDocumentsSimpleUI.includeFriendDb(is_inclusive)
Show friend's corpus. The default value is false
.
is_inclusive
Type: Boolean
Whether or not the information of friendship is displayed.
docuskyGetDbCorpusDocumentsSimpleUI.docList
The result of documents after calling getDbCorpusDocumentsGivenPageAndSize
, getDbCorpusDocuments
and getQueryResultDocuments
.
docuskyGetDbCorpusDocumentsSimpleUI.docList
It is presented in this documentation.
docuskyGetDbCorpusDocumentsSimpleUI.getDbCorpusDocuments(target, db, corpus, evt, succFunc, failFunc)
Get documents in the corpus with assigned arguments. The result will be stored in docuskyGetDbCorpusDocumentsSimpleUI.docList.
target
Type: String
Change the database privacy setting to be public or private (personal). If a database is public, target
would be set as "OPEN"
. If the database is private (personal), the target would be set as "USER"
.
db
Type: String
The title of the target database.
corpus
Type: String
The title of the target corpus in the selected database.
Use "[ALL]"
if there are multiple corpora in this database and you want to select all of them.
evt
Type: Event
docuskyGetDbCorpusDocumentsSimpleUI.getDbCorpusDocuments
will be triggered by an event. If there is no event, it could be null
.
succFunc
Type: Function
The callback function to execute when it is successful.
failFunc
Type: Function
The callback function to execute when it is failed.
Note:
After calling this function, it will return the first 200 documents indocuskyGetDbCorpusDocumentsSimpleUI.docList
. If you want to get all documents in the corpus/database, you need to use a loop to get them. You may usedocuSkyGetDocsObj.totalFound
could find the number of all documents after invokinggetDbCorpusDocuments
.
docuskyGetDbCorpusDocumentsSimpleUI.getDbCorpusDocumentsGivenPageAndSize(target, db, corpus, page, pageSize, evt, succFunc, message, failFunc)
Get documents in the corpus with assigned arguments. The result will be stored in docuskyGetDbCorpusDocumentsSimpleUI.docList
.
target
Type: String
Change the database privacy setting to be public or private (personal). If a database is public, target
would be set as "OPEN"
. If the database is private (personal), the target would be set as "USER"
.
db
Type: String
The title of the target database.
corpus
Type: String
The title of the target corpus in the selected database.
Use "[ALL]"
if there are multiple corpora in this database and you want to select all of them.
page
Type: String
The documents are paginated when fetched as lists. It is used to get the specific page in a query. If the number of all documents in a corpus is 400, page: "2"
means it will return documents from 201 to 400.
pageSize
Type: String
Define the number of documents in a page. The default value is 200.
evt
Type: Event
docuskyGetDbCorpusDocumentsSimpleUI.getDbCorpusDocuments
will be triggered by an event. If there is no event, it could be null
.
succFunc
Type: Function
The callback function to execute when it is successful.
message
Type: String
The string that will display on the loading icon when this function is triggered.
failFunc
Type: Function
The callback function to execute when it is failed.
Note:
After calling this function, it will returnpageSize
documents in the specificpage
and put them indocuskyGetDbCorpusDocumentsSimpleUI.docList
. You may find the number of all documents found indocuSkyGetDocsObj.totalFound
after invokinggetDbCorpusDocumentsGivenPageAndSize
.
docuskyGetDbCorpusDocumentsSimpleUI.getQueryResultDocuments(param, evt, succFunc, failFunc)
Get documents in corpus with detailed arguments. The result will be stored in docuskyGetDbCorpusDocumentsSimpleUI.docList
.
param
Type: Object
Set the property of param as below.
target, db, corpus are the required properties in param.
Type: String
Change the database privacy setting to be public or private (personal). If a database is public, target
would be set as "OPEN"
. If the database is private (personal), the target would be set as "USER"
.
Type: String
The title of the target database.
Type: String
The title of the target corpus in the selected database.
Use "[ALL]"
if there are multiple corpora in this database and you want to select all of them.
Type: String
If the user wants to access a friend's database, it is required to set the friend's username.
Type: String
It provides full-text search and advanced search.
Examples:
Type: String
The documents are paginated when fetched as lists. It is used to get the specific page in query. If the number of all documents in a corpus is 400, page: "2"
means it will return documents from 201 to 400.
Type: String
Define the number of documents in a page. The default value is 200.
Type: String
The string that will display on the loading icon when this function is triggered.
Type: Boolean
Set true
if you want to get metadata only.
On the contrary, it would be false. The default value is false.
Type: String
Set channelKey if you want to get the data into a specific channel. It is used for multiple fetching. If channelKey is assigned, the result isn't in docuskyGetDbCorpusDocumentsSimpleUI.docList.
The documents will be stored in docuskyGetDbCorpusDocumentsSimpleUI.channelBuffer[channelKey].
evt
Type: Event
docuskyGetDbCorpusDocumentsSimpleUI.getQueryResultDocuments
will be triggered by an event. If there is no event, it could be null
.
succFunc
Type: Function
The callback function to execute when it is successful.
failFunc
Type: Function
The callback function to execute when it is failed.
Note:
docuskyGetDbCorpusDocumentsSimpleUI.getQueryResultDocuments is complicated. For beginners, we recommand you to use docuskyGetDbCorpusDocumentsSimpleUI.getDbCorpusDocuments or docuskyGetDbCorpusDocumentsSimpleUI.getDbCorpusDocumentsGivenPageAndSize. The above two functions are based on this function. If there are troubles, please use our examples and develop your web tools based on them.
docuskyGetDbCorpusDocumentsSimpleUI.getQueryPostClassification(param, evt, succFunc, failFunc)
Get post-classification in corpus with assigned arguments. The result will be stored in docuskyGetDbCorpusDocumentsSimpleUI.postClassification.
param
Type: Object
The specifications are the same as the param of getQueryResultDocuments.
evt
Type: Event
docuskyGetDbCorpusDocumentsSimpleUI.getQueryPostClassification
will be triggered by an event. If there is no event, it could be null.
succFunc
Type: Function
The callback function to execute when it is successful.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyGetDbCorpusDocumentsSimpleUI.getQueryTagAnalysis(param, evt, succFunc, failFunc)
Get tag-analysis in corpus with assigned arguments. The result will be stored in docuskyGetDbCorpusDocumentsSimpleUI.tagAnalysis.
param
Type: Object
The specifications are the same as the param of getQueryResultDocuments.
evt
Type: Event
docuskyGetDbCorpusDocumentsSimpleUI.getQueryTagAnalysis
will be triggered by an event. If there is no event, it could be null.
succFunc
Type: Function
The callback function to execute when it is successful.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyGetDbCorpusDocumentsSimpleUI.updateDocument(ownerUsername, db, corpus, docInfo, succFunc, failFunc)
Update document.
ownerUsername
Type: String
The owner user name of the database.
db
Type: String
The title of the target database.
corpus
Type: String
The title of the target corpus in the selected database.
Use "[ALL]"
if there are multiple corpora in this database and you want to select all of them.
docInfo
Type: Object
It contains the same as the item of docuskyGetDbCorpusDocumentsSimpleUI.docList.
succFunc
Type: Function
The callback function to execute when it is successful.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyGetDbCorpusDocumentsSimpleUI.replaceDocument(ownerUsername, db, corpus, docInfo, succFunc, failFunc)
Replace document.
ownerUsername
Type: String
The owner user name of the database.
db
Type: String
The title of the target database.
corpus
Type: String
The title of the target corpus in the selected database.
Use "[ALL]"
if there are multiple corpora in this database and you want to select all of them.
docInfo
Type: Object
It contains the same as the item of docuskyGetDbCorpusDocumentsSimpleUI.docList.
succFunc
Type: Function
The callback function to execute when it is successful.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyGetDbCorpusDocumentsSimpleUI.setDbListOption(param)
Set some options. There is only includeFriendDb for setting now.
param
Type: Object
Set the property of param as below.
Set true
if we want the users to view and manipulate friend's database. On the contrary, it would be false. The default value is false.
docuskyGetDbCorpusDocumentsSimpleUI.utility.setStyle(param)
Set the style of the widget UI.
param
Type: Object
Set the property of param as below.
To upload, retrieve, rename and delete data except DocuXML, you need to use this widget.
docuskyManageDataFileListSimpleUI.Error
This is a global property for the developers to set a callback function when functions in this widget occurrs an error. If you invoke a function without setting a fail(error)
callback function in the argument, docuskyManageDataFileListSimpleUI.Error
will be invoked. docuskyManageDataFileListSimpleUI.Error
will receive Connection Error
or Server Error
when an error occurred. For example, it could be used as following:
docuskyManageDataFileListSimpleUI.maxResponseTimeout
This is the value of maxResponseTimeout
for uploading data via docuskyManageDataFileListSimpleUI.jsonTransporter.storeJson
.
The default value is 300000
(5 minutes).
For example, it could be used as following:
docuskyManageDbListSimpleUI.maxRetryCount
If the developers don't set any fail callback function while invoking the functions in this widget, it will retry the invoked function automatically. The number of times of retrial is defined in docuskyManageDataFileListSimpleUI.maxRetryCount
, and the default value is 10
. For example, it could be used as following:
docuskyManageDataFileListSimpleUI.uploadProgressFunc
This is a global property for the developers to set a callback function for uploading data. If docuskyManageDataFileListSimpleUI.jsonTransporter.storeJson
is invoked for uploading data successfully, docuskyManageDataFileListSimpleUI.uploadProgressFunc
will receive the progress percentage of uploading. For example, it could be used as following:
docuskyManageDataFileListSimpleUI.jsonTransporter.storeJson(category, datapath, filename, jsonObj, succFunc, failFunc)
Store JSON, CSV, or TXT.
category
Type: String
datapath
Type: String
filename
Type: String
jsonObj
Type: Object
The object wiil be stored.
succFunc
Type: Function
The callback function to execute when it is successful.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyManageDataFileListSimpleUI.jsonTransporter.retrieveJson(category, datapath, filename, succFunc, failFunc)
Retrieve JSON, CSV, or TXT.
The data will be stroed in docuskyManageDataFileListSimpleUI.jsonTransporter.jsonObj
.
category
Type: String
datapath
Type: String
filename
Type: String
succFunc
Type: Function
The callback function to execute when it is successful.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyManageDataFileListSimpleUI.jsonTransporter.deleteDataFile(category, datapath, filename, succFunc, failFunc)
Delete JSON, CSV, or TXT in the widget.
category
Type: String
datapath
Type: String
filename
Type: String
succFunc
Type: Function
The callback function to execute when it is successful.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyManageDataFileListSimpleUI.jsonTransporter.listCategoryDataFiles(category, datapath, succFunc, failFunc)
Get list of data files in the specific category and datapath. The list will be stroed in docuskyManageDataFileListSimpleUI.jsonTransporter.jsonObj
.
category
Type: String
datapath
Type: String
succFunc
Type: Function
The callback function to execute when it is successful.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyManageDataFileListSimpleUI.jsonTransporter.renameDataFile(category, datapath, fromFilename, toFilename, succFunc, failFunc)
Rename a file.
category
Type: String
datapath
Type: String
fromFilename
Type: String
toFilename
Type: String
succFunc
Type: Function
The callback function to execute when it is successful.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyManageDataFileListSimpleUI.login(username, password, succFunc, failFunc)
For user login.
username
Type: String
The username is usually an Email.
password
Type: String
succFunc
Type: Function
The callback function to execute when it is successful.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyManageDataFileListSimpleUI.hideWidget(is_hidden)
Hide this widget display on the web. The widget is displayed on the web as default.
is_hidden
Type: Boolean
Whether or not the widget is hidden.
docuskyManageDataFileListSimpleUI.manageDataFileList(evt, succFunc, failFunc)
It is used to open the widget UI and get list of data files. The list of data files will be stored in docuskyManageDataFileListSimpleUI.categoryFilenameList
.
evt
Type: Event
docuskyManageDataFileListSimpleUI.manageDataFileList
will be triggered by an event. If there is no event, it could be null
.
succFunc
Type: Function
The callback function to execute when it is successful.
failFunc
Type: Function
The callback function to execute when it is failed.
docuskyManageDataFileListSimpleUI.utility.setStyle(param)
Set the style of the widget UI.
param
Type: Object
Set the property of param as below.