Class: Kepler

Kepler

new Kepler()

Constructs an instance of Kepler API object. The object is a general class that is used to make API calls to the server side application in all of the modules. Each module is a specific JavaScript code that is loaded by the HTML pages.
Author:
  • Joonas Konki
  • Anu Koskela
  • Mikko Kuhno
  • Henrik Paananen
  • Atte Räty
License:
  • BSD 3-clause, see LICENSE for more details.
Source:

Methods

addNoticeBoardNote(callback)

Adds a new notice board note.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

addReservation(callback)

Adds a new reservation for the current user.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

addResource(callback)

Adds a new resource to the database.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

addTimeSlot(callback)

Adds a new reservable time slot to the database.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

addUnit(callback)

Adds a new unit to the database.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

addUnitGroup(callback)

Adds a new unit group to the database.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

addUserGroup(callback)

Creates a new group for the current user.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

clone(obj)

Creates a clone of an object.
Parameters:
Name Type Description
obj The object that has a tree-like structure.
Source:

createLoadElement(elemId, loadFunc)

Replaces the given element in the HTML page temporarily with a new div that contains a gif animation while the data is being fetched from the database.
Parameters:
Name Type Description
elemId The id of the HTML element where the animation is placed.
loadFunc The handler that is called after the request returns.
Source:
Returns:
The original area when a response from the database has been received.

dateString(date)

Formats a Date object to common Finnish date string representation.
Parameters:
Name Type Description
date The Date object to be formatted.
Source:

datetimeIntervalString(start, end)

Formats two Date objects to a string representation of a time interval.
Parameters:
Name Type Description
start A Date object for the start of the interval.
end A Date object for the end of the interval.
Source:
Returns:
A formatted string representing the interval.

datetimeString(date)

Formats a Date object to common Finnish time string representation of hours and minutes (HH:mm).
Parameters:
Name Type Description
date The Date object to be formatted.
Source:

deleteReservation(callback)

Deletes (hides) an existing reservation from the current user.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

deleteResource(callback)

Deletes (hides) an existing resource from the database.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

deleteTimeSlot(callback)

Deletes (hides) an existing reservable time slot to the database.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

deleteUnit(callback)

Deletes (hides) an existing unit from the database.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

deleteUnitGroup(callback)

Deletes (hides) an existing unit group from the database.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

deleteUserGroup(callback)

Deletes (hides) an existing group of the current user from the database.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

editNoticeBoardNote(callback)

Edits an existing notice board note.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

editResource(callback)

Edits an existing resource in the database.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

editUnit(callback)

Edits an existing unit in the database.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

editUnitGroup(callback)

Edits an existing unit group in the database.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

formatDate(date)

The method is used to format ISO8601 date strings to UI strings.
Parameters:
Name Type Description
date Either a date string or a Date object.
Source:
Returns:
The locale formatted time string.

formatDatetime(date)

The method is used to format ISO8601 date strings to UI strings.
Parameters:
Name Type Description
date Either a date string or a Date object.
Source:
Returns:
The locale formatted time string.

getCalendarEvents(callback)

Gets the calendar events of the current user.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

getNoticeBoard(callback)

Gets all notice board notes.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

getNoticeBoardNotes(callback)

Gets all notice board notes with additional information.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

getQueryParam(name)

Returns the parameter with the specified name from the URL query parameters.
Parameters:
Name Type Description
name The URL query parameter's name.
Source:

getReservationsUser(callback, err_elem_id)

Gets the reservations of the current user.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
err_elem_id The ID of the element in which possible error messages are shown.
Source:

getResources(callback)

Gets the list of all resources and their statuses from the database.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

getTimeSlotEditInfo(callback)

Gets the information needed in the time slot adding and editing view.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

getTimeSlotEvents(callback)

Gets the list of time slot events optionally filtered by a time span and the specified unit.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

getTimeSlots(callback)

Gets the list of time slots optionally filtered by a time span and the study level.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

getUnitGroups(callback)

Gets the list of unit groups from the database.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

getUnits(callback)

Gets the list of all units from the database. Additionally, returns the list of all unit types in the system.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

getUnitsEditable(callback)

Gets the list of all units from the database with additional information needed for editing the units.
Parameters:
Name Type Description
callback The handler that is called after the request returns.'
Source:

getUserGroups(callback)

Gets all the groups where the current user belongs to.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

getUserInfo(callback)

Gets the information related to the current user.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

hideNoticeBoardNote(callback)

Hides the notice board note.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

searchUser(params, callback)

Searches for the user that matches the search string. The call returns the user that matches the search string. If no user or many users are found the call returns null.
Parameters:
Name Type Description
params The email or account name used for searching a user.
callback The handler that is called after the request returns.
Source:

setLanguage(locale_name)

Sets the session language based on the given locale name.
Parameters:
Name Type Description
locale_name The locale name of the language to be set.
Source:

setUserLanguage(locale_name, callback)

Sets the user default language based on the specified locale name.
Parameters:
Name Type Description
locale_name The locale name of the language to be set.
callback The handler that is called after the request returns.
Source:

showError(reason, message, elem_id)

Shows an error message in the element specified by the ID. If no ID is given, the element with ID "#error" is used.
Parameters:
Name Type Description
reason string The reason of the error.
message string The error message.
elem_id string The element ID where the error should be shown.
Source:

showNoticeBoardNote(callback)

Shows the notice board note.
Parameters:
Name Type Description
callback The handler that is called after the request returns.
Source:

showResult(result, elem_id)

Shows the result message in the element specified by the ID.
Parameters:
Name Type Description
result object The Kepler API result object.
elem_id string The element ID where the message should be shown.
Source:

stringToDate(date)

Converts a date string to a Date object.
Parameters:
Name Type Description
date The date string to be converted.
Source:
Returns:
The Date object corresponding to given string.

timeString(date)

Formats the given Date object to common Finnish time string representation.
Parameters:
Name Type Description
date The Date object to be formatted.
Source:

translate(translation_id)

Returns the dynamic translation matching the given translation ID.
Parameters:
Name Type Description
translation_id The translation ID of the translation text.
Source:

(inner) addCallbacksToCall()

Adds done and fail callbacks to the specified AJAX call.
Source:

(inner) makeCall(func, data)

The primary utility function that makes Kepler AJAX calls to the server side application.
Parameters:
Name Type Description
func The name of the API function that will be called.
data The parameters of the function passed as the body of POST request.
Source:
Returns:
Returns the created jQuery AJAX call.