window._ = require('lodash');
window.Popper = require('popper.js').default;
window.pixelfed = window.pixelfed || {};
window.$ = window.jQuery = require('jquery');
require('bootstrap');
window.axios = require('axios');
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
require('readmore-js');
let token = document.head.querySelector('meta[name="csrf-token"]');
if (token) {
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
console.error('CSRF token not found.');
}
window.App = window.App || {};
window.App.redirect = function() {
document.querySelectorAll('a').forEach(function(i,k) {
let a = i.getAttribute('href');
if(a && a.length > 5 && a.startsWith('https://')) {
let url = new URL(a);
if(url.host !== window.location.host && url.pathname !== '/i/redirect') {
i.setAttribute('href', '/i/redirect?url=' + encodeURIComponent(a));
}
}
});
}
window.App.boot = function() {
new Vue({ el: '#content'});
}
window.App.util = {
compose: {
post: (function() {
let path = window.location.pathname;
let whitelist = [
'/',
'/timeline/public'
];
if(whitelist.includes(path)) {
$('#composeModal').modal('show');
} else {
window.location.href = '/?a=co';
}
}),
circle: (function() {
console.log('Unsupported method.');
}),
collection: (function() {
console.log('Unsupported method.');
}),
loop: (function() {
console.log('Unsupported method.');
}),
story: (function() {
console.log('Unsupported method.');
}),
},
time: (function() {
return new Date;
}),
version: 1,
format: {
count: (function(count = 0, locale = 'en-GB', notation = 'compact') {
if(count < 1) {
return 0;
}
return new Intl.NumberFormat(locale, { notation: notation , compactDisplay: "short" }).format(count);
})
},
filters: [
['1977','filter-1977'],
['Aden','filter-aden'],
['Amaro','filter-amaro'],
['Ashby','filter-ashby'],
['Brannan','filter-brannan'],
['Brooklyn','filter-brooklyn'],
['Charmes','filter-charmes'],
['Clarendon','filter-clarendon'],
['Crema','filter-crema'],
['Dogpatch','filter-dogpatch'],
['Earlybird','filter-earlybird'],
['Gingham','filter-gingham'],
['Ginza','filter-ginza'],
['Hefe','filter-hefe'],
['Helena','filter-helena'],
['Hudson','filter-hudson'],
['Inkwell','filter-inkwell'],
['Kelvin','filter-kelvin'],
['Kuno','filter-juno'],
['Lark','filter-lark'],
['Lo-Fi','filter-lofi'],
['Ludwig','filter-ludwig'],
['Maven','filter-maven'],
['Mayfair','filter-mayfair'],
['Moon','filter-moon'],
['Nashville','filter-nashville'],
['Perpetua','filter-perpetua'],
['Poprocket','filter-poprocket'],
['Reyes','filter-reyes'],
['Rise','filter-rise'],
['Sierra','filter-sierra'],
['Skyline','filter-skyline'],
['Slumber','filter-slumber'],
['Stinson','filter-stinson'],
['Sutro','filter-sutro'],
['Toaster','filter-toaster'],
['Valencia','filter-valencia'],
['Vesper','filter-vesper'],
['Walden','filter-walden'],
['Willow','filter-willow'],
['X-Pro II','filter-xpro-ii']
],
emoji: ['๐','๐ฏ','โค๏ธ','๐','๐','๐','๐','๐ฏ','๐ข','๐
','๐','๐','๐','๐','๐คฃ','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐ค','๐คฉ','๐ค','๐คจ','๐','๐','๐ถ','๐','๐','๐ฃ','๐ฅ','๐ฎ','๐ค','๐ช','๐ซ','๐ด','๐','๐','๐','๐','๐คค','๐','๐','๐','๐','๐','๐ค','๐ฒ','๐','๐','๐','๐','๐ค','๐ญ','๐ฆ','๐ง','๐จ','๐ฉ','๐คฏ','๐ฌ','๐ฐ','๐ฑ','๐ณ','๐คช','๐ต','๐ก','๐ ','๐คฌ','๐ท','๐ค','๐ค','๐คข','๐คฎ','๐คง','๐','๐ค ','๐คก','๐คฅ','๐คซ','๐คญ','๐ง','๐ค','๐','๐ฟ','๐น','๐บ','๐','๐ป','๐ฝ','๐ค','๐ฉ','๐บ','๐ธ','๐น','๐ป','๐ผ','๐ฝ','๐','๐ฟ','๐พ','๐คฒ','๐','๐ค','๐','๐','๐','โ','๐ค','๐ค','๐ค','โ๏ธ','๐ค','๐ค','๐','๐','๐','๐','โ๏ธ','โ','๐ค','๐','๐','๐','๐ค','๐ช','๐','โ๏ธ','๐','๐','๐','๐','๐','๐
','๐','๐','๐ฃ','๐','๐','๐ง ','๐ฃ','๐ค','๐ฅ'
],
embed: {
post: (function(url, caption = true, likes = false, layout = 'full') {
let u = url + '/embed?';
u += caption ? 'caption=true&' : 'caption=false&';
u += likes ? 'likes=true&' : 'likes=false&';
u += layout == 'compact' ? 'layout=compact' : 'layout=full';
return '