You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.8 KiB
76 lines
2.8 KiB
7 years ago
|
import loadPolyfills from 'flavours/glitch/util/load_polyfills';
|
||
|
import ready from 'flavours/glitch/util/ready';
|
||
7 years ago
|
|
||
8 years ago
|
function main() {
|
||
8 years ago
|
const IntlRelativeFormat = require('intl-relativeformat').default;
|
||
7 years ago
|
const emojify = require('flavours/glitch/util/emoji').default;
|
||
7 years ago
|
const { getLocale } = require('locales');
|
||
8 years ago
|
const { localeData } = getLocale();
|
||
7 years ago
|
const VideoContainer = require('flavours/glitch/containers/video_container').default;
|
||
|
const MediaGalleryContainer = require('flavours/glitch/containers/media_gallery_container').default;
|
||
|
const CardContainer = require('flavours/glitch/containers/card_container').default;
|
||
7 years ago
|
const React = require('react');
|
||
|
const ReactDOM = require('react-dom');
|
||
7 years ago
|
|
||
8 years ago
|
localeData.forEach(IntlRelativeFormat.__addLocaleData);
|
||
8 years ago
|
|
||
8 years ago
|
ready(() => {
|
||
|
const locale = document.documentElement.lang;
|
||
7 years ago
|
|
||
8 years ago
|
const dateTimeFormat = new Intl.DateTimeFormat(locale, {
|
||
|
year: 'numeric',
|
||
|
month: 'long',
|
||
|
day: 'numeric',
|
||
|
hour: 'numeric',
|
||
|
minute: 'numeric',
|
||
|
});
|
||
7 years ago
|
|
||
8 years ago
|
const relativeFormat = new IntlRelativeFormat(locale);
|
||
8 years ago
|
|
||
8 years ago
|
[].forEach.call(document.querySelectorAll('.emojify'), (content) => {
|
||
|
content.innerHTML = emojify(content.innerHTML);
|
||
|
});
|
||
8 years ago
|
|
||
8 years ago
|
[].forEach.call(document.querySelectorAll('time.formatted'), (content) => {
|
||
|
const datetime = new Date(content.getAttribute('datetime'));
|
||
|
const formattedDate = dateTimeFormat.format(datetime);
|
||
7 years ago
|
|
||
8 years ago
|
content.title = formattedDate;
|
||
|
content.textContent = formattedDate;
|
||
|
});
|
||
8 years ago
|
|
||
8 years ago
|
[].forEach.call(document.querySelectorAll('time.time-ago'), (content) => {
|
||
|
const datetime = new Date(content.getAttribute('datetime'));
|
||
7 years ago
|
|
||
7 years ago
|
content.title = dateTimeFormat.format(datetime);
|
||
8 years ago
|
content.textContent = relativeFormat.format(datetime);
|
||
8 years ago
|
});
|
||
7 years ago
|
|
||
|
[].forEach.call(document.querySelectorAll('.logo-button'), (content) => {
|
||
|
content.addEventListener('click', (e) => {
|
||
|
e.preventDefault();
|
||
|
window.open(e.target.href, 'mastodon-intent', 'width=400,height=400,resizable=no,menubar=no,status=no,scrollbars=yes');
|
||
|
});
|
||
|
});
|
||
8 years ago
|
|
||
7 years ago
|
[].forEach.call(document.querySelectorAll('[data-component="Video"]'), (content) => {
|
||
|
const props = JSON.parse(content.getAttribute('data-props'));
|
||
|
ReactDOM.render(<VideoContainer locale={locale} {...props} />, content);
|
||
|
});
|
||
8 years ago
|
|
||
7 years ago
|
[].forEach.call(document.querySelectorAll('[data-component="MediaGallery"]'), (content) => {
|
||
|
const props = JSON.parse(content.getAttribute('data-props'));
|
||
|
ReactDOM.render(<MediaGalleryContainer locale={locale} {...props} />, content);
|
||
|
});
|
||
8 years ago
|
|
||
7 years ago
|
[].forEach.call(document.querySelectorAll('[data-component="Card"]'), (content) => {
|
||
|
const props = JSON.parse(content.getAttribute('data-props'));
|
||
|
ReactDOM.render(<CardContainer locale={locale} {...props} />, content);
|
||
|
});
|
||
8 years ago
|
});
|
||
|
}
|
||
8 years ago
|
|
||
8 years ago
|
loadPolyfills().then(main).catch(error => {
|
||
8 years ago
|
console.error(error);
|
||
8 years ago
|
});
|