clean up a bit
This commit is contained in:
parent
c27d0760ea
commit
48fa50ab85
|
@ -56,10 +56,9 @@ final class Mobilizon_Connector {
|
|||
$settings = array(
|
||||
'isShortOffsetNameShown' => MobilizonConnector\Settings::isShortOffsetNameShown(),
|
||||
'locale' => str_replace('_', '-', get_locale()),
|
||||
'timeZone' => wp_timezone_string(),
|
||||
'url' => MobilizonConnector\Settings::getUrl()
|
||||
'timeZone' => wp_timezone_string()
|
||||
);
|
||||
wp_add_inline_script($scriptName, 'var MOBILIZON_CONNECTOR = ' . json_encode($settings), 'before'); // TODO remove url
|
||||
wp_add_inline_script($scriptName, 'var MOBILIZON_CONNECTOR = ' . json_encode($settings), 'before');
|
||||
}
|
||||
|
||||
public function register_api() {
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
import {
|
||||
clearEventsList,
|
||||
displayEvents,
|
||||
displayErrorMessage,
|
||||
hideErrorMessages,
|
||||
showLoadingIndicator,
|
||||
} from './events-displayer.js'
|
||||
import * as GraphqlWrapper from './graphql-wrapper.js'
|
||||
|
||||
const NAME = '<wordpress-name>'
|
||||
const URL_SUFFIX = '/api'
|
||||
|
||||
document.addEventListener('DOMContentLoaded', loadEventLists)
|
||||
|
||||
function loadEventLists() {
|
||||
const eventLists = document.getElementsByClassName(NAME + '_events-list')
|
||||
for (const list of eventLists) {
|
||||
loadEventList(list)
|
||||
}
|
||||
}
|
||||
|
||||
export function loadEventList(container) {
|
||||
const url = MOBILIZON_CONNECTOR.url + URL_SUFFIX
|
||||
const limit = parseInt(container.getAttribute('data-maximum'))
|
||||
const groupName = container.getAttribute('data-group-name')
|
||||
hideErrorMessages(container)
|
||||
clearEventsList(container)
|
||||
showLoadingIndicator(container)
|
||||
if (groupName) {
|
||||
GraphqlWrapper.getUpcomingEventsByGroupName({ url, limit, groupName })
|
||||
.then((data) => displayEvents({ data, document, container }))
|
||||
.catch((data) => displayErrorMessage({ data, container }))
|
||||
} else {
|
||||
GraphqlWrapper.getUpcomingEvents({ url, limit })
|
||||
.then((data) => displayEvents({ data, document, container }))
|
||||
.catch((data) => displayErrorMessage({ data, container }))
|
||||
}
|
||||
}
|
||||
|
||||
// TODO delete file and generated file events-loader.js?
|
Loading…
Reference in New Issue