Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Section
titleDetails

All functions are provided via USERSCRIPT4C_ACTIVE.

Section
titleHelper Functions

The library contains the following helpers to check if the groups, space categories, or page labels contain specific elements.

The following functions return a boolean value.

  • containsAll(requiredValues, actualValues)
    Returns true if every element in the array requiredValues is also a member in the array actualValues,
    false if at least one element in requiredValues is not element in actualValues.
  • containsAny(requiredValues, actualValues)
    Returns true if at least one element in the array requiredValues is also a member in the array actualValues,
    false if no element in requiredValues is also a member of actualValues.
  • contains(requiredElement, actualValues)
    Returns true if the requiredElement is a member in the array actualValues,
    false if it is not.


Section
titleGroup Membership

Access information regarding the groups the current user is member of.

Section
titlegetGroups()

Returns an array with the names of groups the current user is member of.

Code Block
languagejs
const groups = USERSCRIPT4C_SYNCACTIVE.getGroups();

if (USERSCRIPT4C_SYNCACTIVE.contains('confluence-administrators', groups)) {
 ...
}



Section
titleisCurrentUserMemberOfAll(...requiredNames)

Provide a list of requiredNames of groups to check that the current user is member of all of them.

Code Block
languagejs
if (USERSCRIPT4C_SYNCACTIVE.isCurrentUserMemberOfAll('confluence-administrators', 'userscripts-administrators')) {
 ...
}

The function returns true if the current user is member of all specified groups, false if the user is not member of at least one specified group.


Section
titleisCurrentUserMemberOfAny(...requiredNames)

Provide a list of requiredNames of groups to check that the current user is member of at least one of them.

Code Block
languagejs
if (USERSCRIPT4C_SYNCACTIVE.isCurrentUserMemberOfAny('confluence-administrators', 'userscripts-administrators')) {
 ...
}

The function returns true if the current user is member of at least one of the specified groups, false if the user no member of any of the specified groups.



Section
titleSpace Categories

Access information regarding the categories of the space the current user is visiting.

Section
titlegetSpaceCategories()

Returns an array with the names of categories the current space is tagged with. The current space is the space the user is currently visiting.

Code Block
languagejs
const categories = USERSCRIPT4C_SYNCACTIVE.getSpaceCategories();

if (USERSCRIPT4C_SYNCACTIVE.contains('product', categories)) {
 ...
}



Section
titleisCurrentSpaceOfCategoryAll(...requiredNames)

Provide a list of requiredNames of space categories to check that the current space is tagged with all of them.

Code Block
languagejs
if (USERSCRIPT4C_SYNCACTIVE.isCurrentSpaceOfCategoryAll('product', 'tool')) {
 ...
}

The function returns true if the current space is tagged with all specified categories, false if the space is at least not tagged with one of the specified categories.


Section
titleisCurrentSpaceOfCategoryAny(...requiredNames)

Provide a list of requiredNames of space categories to check that the current space is tagged with at least one of them.

Code Block
languagejs
if (USERSCRIPT4C_SYNCACTIVE.isCurrentSpaceOfCategoryAny('product', 'tool')) {
 ...
}

The function returns true if the current space is tagged with at least one of the specified categories, false if the space is not tagged with any of the specified categories.



Section
titlePage Labels

Access information regarding the labels of the page the current user is visiting.

Section
titlegetPageLabels()

Returns an array with the names of labels the current page is tagged with. The current page is the page the user currently is visiting.

Code Block
languagejs
const labels = USERSCRIPT4C_SYNCACTIVE.getPageLabels();

if (USERSCRIPT4C_SYNCACTIVE.contains('important', labels)) {
 ...
}



Section
titleisCurrentPageLabeledWithAll(...requiredNames)

Provide a list of requiredNames of page labels to check that the current page is tagged with all of them.

Code Block
languagejs
if (USERSCRIPT4C_SYNCACTIVE.isCurrentPageLabeledWithAll('important', 'fav')) {
 ...
}

The function returns true if the current page is tagged with all specified labels, false if the page is at least not tagged with one of the specified labels.


Section
titleisCurrentPageLabeledWithAny(...requiredNames)

Provide a list of requiredNames of page labels to check that the current page is tagged with at least one of them.

Code Block
languagejs
if (USERSCRIPT4C_SYNCACTIVE.isCurrentPageLabeledWithAny('important', 'fav')) {
 ...
}

The function returns true if the current page is tagged with at least one of the specified labels, false if the page is not tagged with any of the specified labels.



...