summaryrefslogtreecommitdiff
path: root/assets/js
diff options
context:
space:
mode:
authorroot <root@starla.laserr.local>2019-04-03 15:47:12 +0200
committerroot <root@starla.laserr.local>2019-04-03 15:47:12 +0200
commit69aa0718b434d55de1ec67a225745f2ae180a0c6 (patch)
tree52931243b79af41130bae5d41bb654c91e967e5b /assets/js
first commit
Diffstat (limited to 'assets/js')
-rwxr-xr-xassets/js/data.js35
-rwxr-xr-xassets/js/script.js37
-rwxr-xr-xassets/js/search.js122
-rwxr-xr-xassets/js/themer.js139
4 files changed, 333 insertions, 0 deletions
diff --git a/assets/js/data.js b/assets/js/data.js
new file mode 100755
index 0000000..e89b2de
--- /dev/null
+++ b/assets/js/data.js
@@ -0,0 +1,35 @@
+var data_links = "links.json";
+
+$(document).ready(function(){
+ $.getJSON(data_links,
+ function (data) {
+ var mysource = $('#links-template').html();
+ var mytemplate = Handlebars.compile(mysource);
+ var myresult = mytemplate(data)
+ $('#links').html(myresult);
+ });
+});
+
+var data_apps = "apps.json";
+
+$(document).ready(function(){
+ $.getJSON(data_apps,
+ function (data) {
+ var mysource = $('#apps-template').html();
+ var mytemplate = Handlebars.compile(mysource);
+ var myresult = mytemplate(data)
+ $('#apps').html(myresult);
+ });
+});
+
+var data_providers = "providers.json";
+
+$(document).ready(function(){
+ $.getJSON(data_providers,
+ function (data) {
+ var mysource = $('#providers-template').html();
+ var mytemplate = Handlebars.compile(mysource);
+ var myresult = mytemplate(data)
+ $('#providers').html(myresult);
+ });
+}); \ No newline at end of file
diff --git a/assets/js/script.js b/assets/js/script.js
new file mode 100755
index 0000000..516498f
--- /dev/null
+++ b/assets/js/script.js
@@ -0,0 +1,37 @@
+function date() {
+ let currentDate = new Date();
+ let dateOptions = {
+ weekday: "long",
+ year: "numeric",
+ month: "long",
+ day: "numeric"
+ };
+ let date = currentDate.toLocaleDateString("en-GB", dateOptions);
+ document.getElementById("header_date").innerHTML = date;
+}
+
+function greet() {
+ let currentTime = new Date();
+ let greet = Math.floor(currentTime.getHours() / 6);
+ switch (greet) {
+ case 0:
+ document.getElementById("header_greet").innerHTML = "Good night!";
+ break;
+ case 1:
+ document.getElementById("header_greet").innerHTML = "Good morning!";
+ break;
+ case 2:
+ document.getElementById("header_greet").innerHTML = "Good afternoon!";
+ break;
+ case 3:
+ document.getElementById("header_greet").innerHTML = "Good evening!";
+ break;
+ }
+}
+
+function loadFunctions() {
+ date();
+ greet();
+}
+
+
diff --git a/assets/js/search.js b/assets/js/search.js
new file mode 100755
index 0000000..14bc979
--- /dev/null
+++ b/assets/js/search.js
@@ -0,0 +1,122 @@
+var sindex = 0;
+var cycle = false;
+
+function start() {
+ var query = getParameterByName('q');
+ if (query) search(query.replaceAll("+", "%2B"));
+
+ document.getElementById('keywords').focus();
+
+ window.setInterval(function () {
+ updatetime();
+ }, 200);
+}
+
+function handleKeyPress(e) {
+ var key = e.keyCode || e.which;
+ var text = document.getElementById("keywords").value.replaceAll("+", "%2B");
+ var option = text.substr(1, text.indexOf(' ') - 1) || text.substr(1);
+ var subtext = text.substr(2 + option.length);
+ if (key == 13) { // Search functions
+ search(text);
+ }
+ if (key == 9) { // Tab Completion Functions
+ e.preventDefault();
+ e.stopPropagation();
+ if (text[0] === ';') {
+ switch (option) {
+ case 't':
+ var streamers = ['admiralbahroo', 'moonmoon_ow', 'witwix'];
+ if (!subtext || cycle) {
+ cycle = true;
+ if (sindex > streamers.length - 1) sindex = 0;
+ document.getElementById("keywords").value = ';t ' + streamers[sindex++];
+ return;
+ }
+ for (var streamer of streamers) {
+ if (subtext === streamer.substr(0, subtext.length)) {
+ document.getElementById("keywords").value = ';t ' + streamer;
+ return;
+ }
+ }
+ break;
+ }
+ }
+ }
+ if(key == 32){ //Space to go to search
+ document.getElementById("keywords").focus();
+ }
+ sindex = 0;
+ cycle = false;
+}
+
+function search(text) {
+ var option = text.substr(1, text.indexOf(' ') - 1) || text.substr(1);
+ var subtext = text.substr(2 + option.length);
+ if (text[0] === '/') {
+ if (text.indexOf(' ') > -1) {
+ switch (option) {
+ case "am":
+ window.location = "https://www.allmusic.com/search/all/" + subtext;
+ break;
+ case "d":
+ window.location = "https://duckduckgo.com/?q=" + subtext;
+ break;
+ case "di":
+ window.location = "https://www.discogs.com/search/?q=" + subtext;
+ break;
+ case "i":
+ window.location = "https://www.imdb.com/find?q=" + subtext;
+ break;
+ case "m":
+ window.location = "https://www.themoviedb.org/search?query=" + subtext;
+ break;
+ case "r":
+ window.location = "https://www.reddit.com/search?q=" + subtext;
+ break;
+ case "q":
+ window.location = "https://www.qwant.com/?q=" + subtext;
+ break;
+ case "so":
+ window.location = "https://soundcloud.com/search?q=" + subtext;
+ break;
+ case "s":
+ window.location = "https://open.spotify.com/search/results/" + subtext;
+ break;
+ case "t":
+ window.location = "https://trakt.tv/search?query=" + subtext;
+ break;
+ case "tv":
+ window.location = "https://www.thetvdb.com/search?q=" + subtext;
+ break;
+ case "y":
+ window.location = "https://www.youtube.com/results?search_query=" + subtext;
+ break;
+ }
+ } else {
+ var option = text.substr(1);
+ switch (option) {
+ case "d":
+ window.location = "https://www.dukduckgo.com";
+ break;
+ case "y":
+ window.location = "https://www.youtube.com";
+ break;
+ case "r":
+ window.location = "https://reddit.com";
+ break;
+ case "s":
+ window.location = "https://open.spotify.com";
+ break;
+ }
+ }
+ } else {
+ window.location = "https://www.google.com/search?q=" + text;
+ }
+}
+
+
+String.prototype.replaceAll = function(search, replacement) {
+ var target = this;
+ return target.split(search).join(replacement);
+}; \ No newline at end of file
diff --git a/assets/js/themer.js b/assets/js/themer.js
new file mode 100755
index 0000000..9c19380
--- /dev/null
+++ b/assets/js/themer.js
@@ -0,0 +1,139 @@
+const setValue = (property, value) => {
+ if (value) {
+ document.documentElement.style.setProperty(`--${property}`, value);
+
+ const input = document.querySelector(`#${property}`);
+ if (input) {
+ value = value.replace('px', '');
+ input.value = value;
+ }
+ }
+};
+
+const setValueFromLocalStorage = property => {
+ let value = localStorage.getItem(property);
+ setValue(property, value);
+};
+
+const setTheme = options => {
+ for (let option of Object.keys(options)) {
+ const property = option;
+ const value = options[option];
+
+ setValue(property, value);
+ localStorage.setItem(property, value);
+ }
+}
+
+document.addEventListener('DOMContentLoaded', () => {
+ setValueFromLocalStorage('color-background');
+ setValueFromLocalStorage('color-text-pri');
+ setValueFromLocalStorage('color-text-acc');
+});
+
+const dataThemeButtons = document.querySelectorAll('[data-theme]');
+
+for (let i = 0; i < dataThemeButtons.length; i++) {
+ dataThemeButtons[i].addEventListener('click', () => {
+ const theme = dataThemeButtons[i].dataset.theme;
+
+ switch (theme) {
+ case 'blackboard':
+ setTheme({
+ 'color-background': '#1a1a1a',
+ 'color-text-pri': '#FFFDEA',
+ 'color-text-acc': '#5c5c5c'
+ });
+ return;
+
+ case 'gazette':
+ setTheme({
+ 'color-background': '#F2F7FF',
+ 'color-text-pri': '#000000',
+ 'color-text-acc': '#5c5c5c'
+ });
+ return;
+
+ case 'espresso':
+ setTheme({
+ 'color-background': '#21211F',
+ 'color-text-pri': '#D1B59A',
+ 'color-text-acc': '#4E4E4E'
+ });
+ return;
+
+ case 'cab':
+ setTheme({
+ 'color-background': '#F6D305',
+ 'color-text-pri': '#1F1F1F',
+ 'color-text-acc': '#424242'
+ });
+ return;
+
+ case 'cloud':
+ setTheme({
+ 'color-background': '#f1f2f0',
+ 'color-text-pri': '#35342f',
+ 'color-text-acc': '#37bbe4'
+ });
+ return;
+
+ case 'lime':
+ setTheme({
+ 'color-background': '#263238',
+ 'color-text-pri': '#AABBC3',
+ 'color-text-acc': '#aeea00'
+ });
+ return;
+
+ case 'white':
+ setTheme({
+ 'color-background': '#ffffff',
+ 'color-text-pri': '#222222',
+ 'color-text-acc': '#dddddd'
+ });
+ return;
+
+ case 'tron':
+ setTheme({
+ 'color-background': '#242B33',
+ 'color-text-pri': '#EFFBFF',
+ 'color-text-acc': '#6EE2FF'
+ });
+ return;
+
+ case 'blues':
+ setTheme({
+ 'color-background': '#2B2C56',
+ 'color-text-pri': '#EFF1FC',
+ 'color-text-acc': '#6677EB'
+ });
+ return;
+
+ case 'passion':
+ setTheme({
+ 'color-background': '#f5f5f5',
+ 'color-text-pri': '#12005e',
+ 'color-text-acc': '#8e24aa'
+ });
+ return;
+
+ case 'chalk':
+ setTheme({
+ 'color-background': '#263238',
+ 'color-text-pri': '#AABBC3',
+ 'color-text-acc': '#FF869A'
+ });
+ return;
+
+ case 'paper':
+ setTheme({
+ 'color-background': '#F8F6F1',
+ 'color-text-pri': '#4C432E',
+ 'color-text-acc': '#AA9A73'
+ });
+ return;
+
+ }
+ })
+} \ No newline at end of file