"jQuery SugarSync" is a jQuery Plugin to add SugarSync functionality (https://www.sugarsync.com/) to the jQuery Library (http://jquery.com/).
Copyright 2012, Riccardo Re
Dual licensed under the MIT or GPL Version 2 licenses.
$(selector).sugarsync([oOptions]);
selector
The jQuery selector, targeting an element you'd like to use as a sugarsync plugin referenceoOptions
An optional JavaScript object that you may pass if you would like to customize the experience with the plugin. Below is a list of properties that you may set on the options object and their respective effect.oOptions.username
- The username to use for the sugarsync service
oOptions.password
- The password to use for the sugarsync service
oOptions.applicationID
{String: "using jQuery SugarSync's plugin"}
- A sugarsync's application ID ot use a custom application
oOptions.accessKeyID
{String: "using jQuery SugarSync's plugin"}
- A sugarsync's Access Key ID to use a custom application
oOptions.privateAccessKey
{String: "using jQuery SugarSync's plugin"}
- A sugarsync's private access key to use a custom application
$(selector).sugarsync('getUserInfo',fCallback);
selector
The jQuery selector, targeting an element you are using as sugarsync plugin referencefCallback
The callback function receiving a JavaScript object describing the user info as first parameter. Below is a list of properties which describe the user info.username
- The username
nickname
- The nickname
quota.limit
- The limit quota
quota.usage
- The usage quota
workspaces
- The workspace resource
syncfolders
- The syncfolders resource
deleted
- The deleted resource
magicBriefcase
- The magicBriefcase resource
webArchive
- The webArchive resource
mobilePhotos
- The mobilePhotos resource
recentActivities
- The recentActivities resource
receivedShares
- The receivedShares resource
publicLinks
- The publicLinks resource
maximumPublicLinkSize
- The maximumPublicLinkSize number
$(selector).sugarsync('getFolderInfo', sFolderResource, fCallback);
selector
The jQuery selector, targeting an element you are using as sugarsync plugin referencesFolderResource
The string describing a folder resourcefCallback
The callback function receiving a JavaScript object describing the folder info as first parameter. Below is a list of properties which describe the folder info.displayName
- The folder label
dsid
- The folder dsid
timeCreated
- The folder creation time
collections
- The collections resource
files
- The files resource
contents
- The contents resource
$(selector).sugarsync('getFolderContents', sFolderResource, fCallback, oOptions);
selector
The jQuery selector, targeting an element you are using as sugarsync plugin referencesFolderResource
The string describing a folder resourcefCallback
The callback function receiving a JavaScript array describing the folder contents as first parameter. Each element of the array is a JavaScript object. The type property will determine if it's a directory or a file.-
element
folder
- An array of directories inside the resource; each element of the array is a JavaScript object with the following parameters:
type
constant string 'folder'displayName
the labelref
the folder resource
- An array of directories inside the resource; each element of the array is a JavaScript object with the following parameters:
-
element
file
- An array of files inside the resource; each element of the array is a JavaScript object with the following parameters:
type
constant string 'file'displayName
the labelref
the file resourcesize
the file sizelastModified
the last time the file was modifiedmediaType
the file media typepresentOnServer
a flag which shows if the file is present on the serverfileData
the file data resource
- An array of files inside the resource; each element of the array is a JavaScript object with the following parameters:
-
oOptions
An optional JavaScript object that you may pass if you would like to customize the behaviour of the current method. Below is a list of properties that you may set on the options object and their respective effect.oOptions.type
{String: null}
- Set the filter you would like to use on the results; by default no filter is used; you can choose between:
null
value to evade using filtersfolder
string; to receive only foldersfile
string; to receive only files
- Set the filter you would like to use on the results; by default no filter is used; you can choose between:
oOptions.start
{Integer: 0}
- Set the index within the indexed sequence of objects in the folder to start listing folder contents. The default value is 0, meaning that objects in the folder are listed starting with the first object in the sequence. However, you can specify any positive integer value for the starting index.
oOptions.max
{Integer: 500}
- The maximum number of results you'll receive. By default it's set on 500.
oOptions.order
{String: "name"}
- How to order the results; by default it's set on 'name'; the value can be choose between:
name
sort by the display name of the itemslast_modified
sort by the last-modified date (if available) of the itemssize
sort by the size (in bytes) of the itemsextension
sort by the filename extension (if available) of the items
- How to order the results; by default it's set on 'name'; the value can be choose between:
$(selector).sugarsync('download', sFileResource, sDisplayName, sMediatype, fCallback );
sFileResource
The string describing a file resourcesDisplayName
The string describing a the filename to use while saving the filesMediatype
{String: null}
The string describing a file's media typefCallback
The callback function receiving a JavaScript array describing the downloaded file with the following parameters:displayName
the labelmediaType
the file media type
$(selector).sugarsync('getVersionHistory', sFileResource, fCallback );
sFileResource
The string describing a file resourcefCallback
The callback function receiving a JavaScript array describing the folder contents as first parameter. Each element of the array is a JavaScript object with the following parameters:fileData
the file data resourcelastModified
the last time the file was modifiedmediaType
the file media typepresentOnServer
a flag which shows if the file is present on the serverref
the file resourcesize
the file size
A lot of enhancement can be done on this library. Right now I am planning to add as soon as possible:
- Create file
- Upload Data operation to create a file or a folder
- Improve download file operation: still unable to download correctly files with media type different form common text
- Improve "test.html" demo page usability
- 0.0.3
- Update to use correctly jQuery 2.0.0+ library
- Download files using HTML5 specifics
- Added Version History request
- Revisited "test.html" demo page
- 0.0.2
- Updated "getFolderContents" method to return an array of objects where the type property determine if it's a folder or a file
- Added options to "getFolderContents" method
- Improved the test page
- 0.0.1
- Commited on Git Hub first release