1
0
mirror of https://github.com/TeamPiped/Piped.git synced 2024-12-15 14:50:28 +05:30
Piped/src/main.js

79 lines
2.5 KiB
JavaScript
Raw Normal View History

import { createApp } from "vue";
import { library } from "@fortawesome/fontawesome-svg-core";
2021-06-17 00:44:46 +05:30
import { faThumbsUp, faThumbsDown, faEye, faThumbtack, faCheck, faHeart, faHeadphones } from "@fortawesome/free-solid-svg-icons";
import { faGithub, faBitcoin } from "@fortawesome/free-brands-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
2021-06-17 00:44:46 +05:30
library.add(faThumbsUp, faThumbsDown, faEye, faGithub, faBitcoin, faThumbtack, faCheck, faHeart, faHeadphones);
2020-11-17 10:45:35 +05:30
import("uikit/dist/css/uikit-core.css");
import("uikit/dist/js/uikit-core.min");
2020-11-17 10:45:35 +05:30
import router from "@/router/router";
import App from "./App.vue";
2020-11-17 10:45:35 +05:30
import DOMPurify from 'dompurify';
2021-05-10 23:44:28 +05:30
import("./registerServiceWorker");
2020-11-17 10:45:35 +05:30
2020-11-27 12:16:36 +05:30
const mixin = {
methods: {
2021-05-10 23:44:28 +05:30
timeFormat: function (duration) {
var pad = function (num, size) {
2020-11-27 12:16:36 +05:30
return ("000" + num).slice(size * -1);
};
var time = parseFloat(duration).toFixed(3),
hours = Math.floor(time / 60 / 60),
minutes = Math.floor(time / 60) % 60,
seconds = Math.floor(time - minutes * 60);
var str = "";
2021-01-07 13:33:10 +05:30
if (hours > 0) str += hours + ":";
2020-11-27 12:16:36 +05:30
str += pad(minutes, 2) + ":" + pad(seconds, 2);
return str;
2021-02-24 15:05:41 +05:30
},
2021-05-31 03:36:35 +05:30
numberFormat(num) {
const digits = 2;
const si = [
{ value: 1, symbol: "" },
{ value: 1E3, symbol: "k" },
{ value: 1E6, symbol: "M" },
{ value: 1E9, symbol: "B" }
];
const rx = /\.0+$|(\.[0-9]*[1-9])0+$/;
for (var i = si.length - 1; i > 0; i--) {
if (num >= si[i].value) {
break;
}
}
return (num / si[i].value).toFixed(digits).replace(rx, "$1") + si[i].symbol;
},
2021-06-03 00:22:58 +05:30
addCommas(num) {
num = parseInt(num)
return num.toLocaleString('en-US')
},
fetchJson: function (url, params, options) {
if (params) {
url = new URL(url);
for (var param in params)
url.searchParams.set(param, params[param])
}
return fetch(url, options).then(response => {
return response.json();
});
},
purifyHTML(original) {
return DOMPurify.sanitize(original);
}
},
};
const app = createApp(App);
app.use(router);
app.mixin(mixin);
app.component("font-awesome-icon", FontAwesomeIcon);
app.mount("#app");