Namespace: OC

OC

Classes

ContactsMenu
EventSource
FileUpload

Namespaces

AppConfig
dialogs
Files
L10N
Login
MimeType
msg
Notification
Plugins
search
Share
SystemTags
Uploader
Util

Members

(static) _ajaxConnectionLostHandler

Warn users that the connection to the server was lost temporarily This function is throttled to prevent stacked notfications. After 7sec the first notification is gone, then we can show another one if necessary.
Source:

(static) _capabilities :array

Capabilities
Type:
  • array
Source:

(static) currentUser :String

Currently logged in user or null if none
Type:
  • String
Deprecated:
Source:

(static) MimeTypeList

This file is automatically generated DO NOT EDIT MANUALLY! You can update the list of MimeType Aliases in config/mimetypealiases.json The list of files is fetched from core/img/filetypes To regenerate this file run ./occ maintenance:mimetype:update-js
Source:

(static) webroot :string

Relative path to Nextcloud root. For example: "/nextcloud"
Type:
Deprecated:
  • since 8.2, use OC.getRootPath() instead
Source:
See:
  • OC#getRootPath

Methods

(private, static) _matchMedia()

Wrapper for matchMedia This is makes it possible for unit tests to stub matchMedia (which doesn't work in PhantomJS)
Source:

(static) _processAjaxError()

Process ajax error, redirects to main page if an error/auth error status was returned.
Source:

(static) addScript(app, script, ready)

Load a script for the server and load it. If the script is already loaded, the event handler will be called directly
Parameters:
Name Type Description
app string the app id to which the script belongs
script string the filename of the script
ready event handler to be called when the script is loaded
Source:

(static) addStyle(app, style)

Loads a CSS file
Parameters:
Name Type Description
app string the app id to which the css style belongs
style string the filename of the css file
Source:

(static) addTranslations(app, callback) → {Promise}

Loads translations for the given app asynchronously.
Parameters:
Name Type Description
app String app name
callback function callback to call after loading
Source:
Returns:
Type
Promise

(static) appSettings(appid, loadJS, cacheopt, scriptNameopt)

Opens a popup with the setting for an app.
Parameters:
Name Type Attributes Description
appid string The ID of the app e.g. 'calendar', 'contacts' or 'files'.
loadJS boolean | string If true 'js/settings.js' is loaded. If it's a string it will attempt to load a script by that name in the 'js' directory.
cache boolean <optional>
If true the javascript file won't be forced refreshed. Defaults to true.
scriptName string <optional>
The name of the PHP file to load. Defaults to 'settings.php' in the root of the app directory hierarchy.
Source:

(static) basename(path) → {String}

Returns the base name of the given path. For example for "/abc/somefile.txt" it will return "somefile.txt"
Parameters:
Name Type Description
path String
Source:
Returns:
base name
Type
String

(static) buildQueryString(params) → {string}

Builds a URL query from a JS map.
Parameters:
Name Type Description
params Object.<string, string> map containing key/values matching the URL parameters
Source:
Returns:
String containing a URL query (without question) mark
Type
string

(static) dirname(path) → {String}

Returns the dir name of the given path. For example for "/abc/somefile.txt" it will return "/abc"
Parameters:
Name Type Description
path String
Source:
Returns:
dir name
Type
String

(static) encodePath(path)

URI-Encodes a file path but keep the path slashes.
Parameters:
Name Type Description
path path
Source:
Returns:
encoded path

(static) fileIsBlacklisted(file)

Check if a user file is allowed to be handled.
Parameters:
Name Type Description
file string to check
Source:

(static) filePath(app, type, file) → {string}

Get the absolute url for a file in an app
Parameters:
Name Type Description
app string the id of the app
type string the type of the file to link to (e.g. css,img,ajax.template)
file string the filename
Source:
Returns:
Absolute URL for a file in an app
Type
string

(static) generateUrl(url, paramsopt, optionsopt) → {string}

Generates the absolute url for the given relative url, which can contain parameters. Parameters will be URL encoded automatically.
Parameters:
Name Type Attributes Description
url string
params <optional>
params
options <optional>
options
Properties
Name Type Attributes Default Description
escape bool <optional>
true enable/disable auto escape of placeholders (by default enabled)
Source:
Returns:
Absolute URL for the given relative URL
Type
string

(static) get(name) → {*}

Get a variable by name
Parameters:
Name Type Description
name string
Source:
Returns:
Type
*

(static) getCapabilities() → {array}

Returns the capabilities
Since:
  • 14.0
Source:
Returns:
capabilities
Type
array

(static) getCurrentUser() → {OC.CurrentUser}

Returns the currently logged in user or null if there is no logged in user (public page mode)
Since:
  • 9.0.0
Source:
Returns:
user spec
Type
OC.CurrentUser

(static) getHost() → {string}

Returns the host used to access this Nextcloud instance Host is sometimes the same as the hostname but now always. Examples: http://example.com => example.com https://example.com => example.com http://example.com:8080 => example.com:8080
Since:
  • 8.2
Source:
Returns:
host
Type
string

(static) getHostName() → {string}

Returns the hostname used to access this Nextcloud instance The hostname is always stripped of the port
Since:
  • 9.0
Source:
Returns:
hostname
Type
string

(static) getLanguage() → {String}

Returns the user's language
Source:
Returns:
language string
Type
String

(static) getLocale() → {String}

Returns the user's locale
Source:
Returns:
locale string
Type
String

(static) getPort() → {int}

Returns the port number used to access this Nextcloud instance
Since:
  • 8.2
Source:
Returns:
port number
Type
int

(static) getProtocol() → {string}

Protocol that is used to access this Nextcloud instance
Source:
Returns:
Used protocol
Type
string

(static) getRootPath() → {string}

Returns the web root path where this Nextcloud instance is accessible, with a leading slash. For example "/nextcloud".
Since:
  • 8.2
Source:
Returns:
web root path
Type
string

(static) hideMenus(complete)

Hides any open menus
Parameters:
Name Type Description
complete function callback when the hiding animation is done
Source:

(static) imagePath(app, file) → {string}

get the absolute path to an image file if no extension is given for the image, it will automatically decide between .png and .svg based on what the browser supports
Parameters:
Name Type Description
app string the app id to which the image belongs
file string the name of the image file
Source:
Returns:
Type
string

(static) isSamePath(path1, path2) → {bool}

Returns whether the given paths are the same, without leading, trailing or doubled slashes and also removing the dot sections.
Parameters:
Name Type Description
path1 String first path
path2 String second path
Since:
  • 9.0
Source:
Returns:
true if the paths are the same
Type
bool

(static) isUserAdmin() → {bool}

Returns whether the current user is an administrator
Since:
  • 9.0.0
Source:
Returns:
true if the user is an admin, false otherwise
Type
bool

(static) joinPaths(…path) → {String}

Join path sections
Parameters:
Name Type Attributes Description
path String <repeatable>
sections
Since:
  • 8.2
Source:
Returns:
joined path, any leading or trailing slash will be kept
Type
String

(static) linkTo(app, file) → {string}

Get an absolute url to a file in an app
Parameters:
Name Type Description
app string the id of the app the file belongs to
file string the file path relative to the app folder
Source:
Returns:
Absolute URL to a file
Type
string

(static) linkToOCS(service, version) → {string}

Gets the base path for the given OCS API service.
Parameters:
Name Type Description
service string name
version int OCS API version
Source:
Returns:
OCS API base path
Type
string

(static) linkToRemote(service) → {string}

Parameters:
Name Type Description
service string id
Source:
Returns:
the url
Type
string

(static) linkToRemoteBase(service) → {string}

Creates a relative url for remote use
Parameters:
Name Type Description
service string id
Source:
Returns:
the url
Type
string

(static) parseQueryString(queryString) → {Object.<string, string>}

Parses a URL query string into a JS map
Parameters:
Name Type Description
queryString string query string in the format param1=1234¶m2=abcde¶m3=xyz
Source:
Returns:
map containing key/values matching the URL parameters
Type
Object.<string, string>

(static) redirect(targetURL)

Redirect to the target URL, can also be used for downloads.
Parameters:
Name Type Description
targetURL string URL to redirect to
Source:

(static) registerMenu($toggle, $menuEl, toggle, headerMenu) → {undefined}

For menu toggling
Parameters:
Name Type Description
$toggle jQuery
$menuEl jQuery
toggle function | undefined callback invoked everytime the menu is opened
headerMenu boolean is this a top right header menu?
Source:
To Do:
  • Write documentation
Returns:
Type
undefined

(static) registerXHRForErrorProcessing(xhr)

Registers XmlHttpRequest object for global error processing. This means that if this XHR object returns 401 or session timeout errors, the current page will automatically be reloaded.
Parameters:
Name Type Description
xhr XMLHttpRequest
Source:

(static) reload()

Reloads the current page
Source:

(static) search(query)

Do a search query and display the results
Parameters:
Name Type Description
query string the search query
Source:

(static) set(name, value)

Set a variable by name
Parameters:
Name Type Description
name string
value *
Source:

(static) showMenu($toggleopt, $menuEl, complete)

Shows a given element as menu
Parameters:
Name Type Attributes Default Description
$toggle Object <optional>
null menu toggle
$menuEl Object menu element
complete function callback when the showing animation is done
Source:

(static) unregisterMenu()

Source:
To Do:
  • Write documentation

Type Definitions

CurrentUser

Current user attributes
Type:
  • Object
Properties:
Name Type Description
uid String user id
displayName String display name
Source: