1 line
21 KiB
Plaintext
1 line
21 KiB
Plaintext
[{"/home/seanedmunds/dev/home-page/src/index.js":"1"},{"size":19454,"mtime":1639516153474,"results":"2","hashOfConfig":"3"},{"filePath":"4","messages":"5","errorCount":0,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"6"},"szjdbt","/home/seanedmunds/dev/home-page/src/index.js",["7","8"],"import React from 'react';\nimport { useState, useEffect } from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\n\nconst setValueFromLocalStorage = property => {\n let value = localStorage.getItem(property);\n setValue(property, value);\n};\nconst setValue = (property, value) => {\n if (value) {\n document.documentElement.style.setProperty(`--${property}`, value);\n\n const input = document.querySelector(`#${property}`);\n if (input) {\n value = value.replace('px', '');\n input.value = value;\n }\n }\n};\n\nfunction Homepage() {\n setTheme();\n \n return (\n <main id=\"container\" className=\"fade\">\n <div>\n <Search />\n </div>\n <div>\n <Header\n date={date()}\n greet={greet()}\n />\n </div>\n <div>\n <Applications />\n </div>\n <div>\n <Bookmarks />\n </div>\n <div>\n <ModalMenu />\n </div>\n <div>\n <ModalInit />\n </div>\n </main>\n );\n}\n\nfunction Search() {\n return (\n <section id=\"search\">\n <div className=\"abackground\">\n <input name=\"keywords\" type=\"text\" className=\"keyword\" id=\"keywords\" size=\"50\" spellCheck=\"true\" placeholder=\"\" autoComplete=\"off\" autoFocus={true} onKeyUp={handleKeyPress}/>\n <label id=\"searchType\" className=\"Input-label\">Google search</label>\n </div>\n </section>\n )\n}\n\nfunction Header(props) {\n return (\n <section id=\"header\">\n <div id=\"greeting_block\">\n <h1 id=\"header_greet\">{props.greet}</h1>\n </div>\n <div id=\"date_block\">\n <h2 id=\"header_date\">{props.date}</h2>\n <Clock />\n </div>\n </section>\n );\n}\n\nfunction Applications() {\n let appList = getApps();\n var items = [];\n for (var i = 0; i < appList.apps.length; i++) {\n var safe = appList.apps[i].NSFW;\n var NSFWEnabled = localStorage.getItem(\"contenttype\");\n if (safe === \"SAFE\") {\n items.push(\n <App\n key={i}\n name={appList.apps[i].name}\n url={appList.apps[i].url}\n icon={appList.apps[i].icon}\n NSFW={appList.apps[i].NSFW}\n />\n );\n } else if (safe === \"NSFW\" && NSFWEnabled) {\n items.push(\n <App\n key={i}\n name={appList.apps[i].name}\n url={appList.apps[i].url}\n icon={appList.apps[i].icon}\n NSFW={appList.apps[i].NSFW}\n />\n );\n } else {\n \n }\n \n }\n return (\n <section id=\"apps\">\n <h3>Applications</h3>\n <div id=\"apps_loop\">\n {items}\n </div>\n </section>\n );\n}\n\nfunction App(props) {\n \n let classNameType = props.NSFW + \"-content\";\n let hrefUrl = \"https://\" + props.url;\n let iconName = \"mdi-\" + props.icon;\n return (\n <div className={classNameType}>\n <a href={hrefUrl}>\n <div className=\"apps_item\">\n <div className=\"apps_icon\">\n <span className=\"iconify icon\" data-icon={iconName}></span>\n </div>\n <div className=\"apps_text\">\n <span id=\"app-name\">{props.name}</span>\n <span id=\"app-address\">{props.url}</span>\n </div>\n </div>\n </a>\n </div>\n );\n}\n\nfunction Bookmarks() {\n let bookmarkList = getLinks();\n var items = [];\n for (var i = 0; i < bookmarkList.bookmarks.length; i++) {\n items.push(\n <LinkGroups\n key={i}\n category={bookmarkList.bookmarks[i].category}\n links={bookmarkList.bookmarks[i].links}\n />\n );\n }\n return (\n <section id=\"links\">\n <h3>Bookmarks</h3>\n <div id=\"links_loop\">\n {items}\n </div>\n </section>\n );\n}\n\nfunction LinkGroups(props) {\n var items = [];\n for (var i = 0; i < props.links.length; i++) {\n items.push(\n <LinkItem\n key={i}\n link={props.links[i]}\n />\n );\n }\n return (\n <div id=\"links_item\">\n <h4>{props.category}</h4>\n {items}\n </div>\n );\n}\n\nfunction LinkItem(props) {\n return (\n <div>\n <a href={props.link.url} className=\"theme_color-border theme_text-select\">{props.link.name}</a>\n </div>\n );\n}\n\nfunction ModalMenu() {\n var providers = getProviders();\n var items = [];\n var isChecked = localStorage.getItem(\"contenttype\");\n console.log(localStorage.getItem(\"contenttype\"));\n for (var i = 0; i < providers.providers.length; i++) {\n items.push(\n <Provider \n key={i}\n provider={providers.providers[i]}\n />\n );\n }\n return (\n <section id=\"modal\">\n <div>\n <header id=\"modal-header\">\n <h1>Options</h1>\n <a href=\"#\" title=\"Close\" className=\"modal-close\">\n <span className=\"iconify\" data-icon=\"mdi-close\"></span>\n </a>\n </header>\n\n <h2>Color themes</h2>\n\n <div id=\"modal-theme\">\n <button data-theme=\"blackboard\" className=\"theme-button theme-blackboard\" onClick={updateTheme}>Blackboard</button>\n <button data-theme=\"gazette\" className=\"theme-button theme-gazette\" onClick={updateTheme}>Gazette</button>\n <button data-theme=\"espresso\" className=\"theme-button theme-espresso\" onClick={updateTheme}>Espresso</button>\n <button data-theme=\"cab\" className=\"theme-button theme-cab\" onClick={updateTheme}>Cab</button>\n <button data-theme=\"cloud\" className=\"theme-button theme-cloud\" onClick={updateTheme}>Cloud</button>\n <button data-theme=\"lime\" className=\"theme-button theme-lime\" onClick={updateTheme}>Lime</button>\n <button data-theme=\"passion\" className=\"theme-button theme-passion\" onClick={updateTheme}>Passion</button>\n <button data-theme=\"blues\" className=\"theme-button theme-blues\" onClick={updateTheme}>Blues</button>\n <button data-theme=\"chalk\" className=\"theme-button theme-chalk\" onClick={updateTheme}>Chalk</button>\n <button data-theme=\"tron\" className=\"theme-button theme-tron\" onClick={updateTheme}>Tron</button>\n <button data-theme=\"paper\" className=\"theme-button theme-paper\" onClick={updateTheme}>Paper</button>\n <button data-theme=\"cyberpunk\" className=\"theme-button theme-cyberpunk\" onClick={updateTheme}>Cyberpunk</button>\n <button data-theme=\"quadra\" className=\"theme-button theme-panam\" onClick={updateTheme}>Quadra</button>\n <button data-theme=\"panam\" className=\"theme-button theme-panam\" onClick={updateTheme}>Panam</button>\n <button data-theme=\"touch\" className=\"theme-button theme-touch\" onClick={updateTheme}>Touch</button>\n <button data-theme=\"peek\" className=\"theme-button theme-peek\" onClick={updateTheme}>Peek</button>\n </div>\n\n\n <h2>Search options</h2>\n <section id=\"providers\">\n <table>\n <tbody>\n <tr>\n <th>Website</th>\n <th>Prefix</th>\n </tr>\n {items}\n </tbody>\n </table>\n </section>\n\n <header id=\"modal-footer\">\n <a href=\"https://github.com/jeroenpardon/\"><span className=\"iconify\" data-icon=\"mdi-github-box\"></span></a>\n <a href=\"https://materialdesignicons.com/\"><span className=\"iconify\" data-icon=\"mdi-material-design\"></span></a>\n <HideButton \n checked = {isChecked}\n />\n </header>\n </div>\n </section>\n );\n}\n\nfunction HideButton(props) {\n console.log(props.checked);\n if(props.checked === \"true\") {\n console.log(\"icon should be grey\");\n return (\n <div className=\"sneaky\"><input type=\"checkbox\" id=\"contenttype\" onChange={udpateDisplayedItems} defaultChecked={true}></input>\n <label for=\"contenttype\"><span className=\"iconify\" data-icon=\"mdi-domino-mask\"></span></label></div>\n );\n } else {\n console.log(\"icon should be white\");\n return (\n <div className=\"sneaky\"><input type=\"checkbox\" id=\"contenttype\" onChange={udpateDisplayedItems} defaultChecked={false}></input>\n <label for=\"contenttype\"><span className=\"iconify\" data-icon=\"mdi-domino-mask\"></span></label></div>\n );\n }\n}\n\nfunction Provider(props) {\n return (\n <tr>\n <td><a href={props.provider.url}>{props.provider.name}</a></td>\n <td>{props.provider.prefix}</td>\n </tr>\n );\n}\n\nfunction ModalInit() {\n setDisplayedItems();\n return (\n <div id=\"modal_init\">\n <a className=\"btn\" href=\"#modal\">\n <span className=\"iconify icon\" data-icon=\"mdi-xbox-controller-menu\"></span>\n </a>\n </div>\n );\n}\n\nReactDOM.render(\n <Homepage />,\n document.getElementById('root')\n);\n\n//Functions below this line are for calculating data for\n//other functions\n\nfunction date() {\n let currentDate = new Date();\n let dateOptions = {\n weekday: \"long\",\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\"\n };\n let date = currentDate.toLocaleDateString(\"en-GB\", dateOptions);\n return date;\n}\nfunction fixDigits(k) {\n if (k < 10) {\n return \"0\" + k;\n }\n else {\n return k;\n }\n}\nfunction greet() {\n let currentTime = new Date();\n let greet = Math.floor(currentTime.getHours() / 6);\n let easterEggChance = Math.floor(Math.random() * 100);\n let greetings = require('./messages.json');\n let timeBased = [];\n let easterEggs = [];\n for (var i = 0; i < greetings.messages.length; i++) {\n if (greetings.messages[i].easteregg === \"FALSE\") {\n timeBased = timeBased.concat(greetings.messages[i]);\n } else {\n easterEggs = easterEggs.concat(greetings.messages[i]);\n }\n }\n if (easterEggChance > 10) {\n return timeBased[greet].message;\n } else {\n let easterEggText = Math.floor(Math.random() * easterEggs.length);\n return easterEggs[easterEggText].message;\n }\n}\nfunction Clock() {\n const [date, setDate] = useState(new Date());\n\n function refreshClock() {\n setDate(new Date());\n }\n useEffect(() => {\n const timerId = setInterval(refreshClock, 1000);\n return function cleanup() {\n clearInterval(timerId);\n };\n }, []);\n\n var hour = date.getHours();\n var minutes = date.getMinutes();\n //var seconds = date.getSeconds();\n var midday = \"AM\";\n midday = (hour >= 12) ? \"PM\" : \"AM\";\n hour = (hour === 0) ? 12 : ((hour > 12) ? (hour - 12) : hour);\n minutes = fixDigits(minutes);\n //seconds = fixDigits(seconds);\n let time = hour + \":\" + minutes + \" \" + midday;\n\n return (\n <h2 id=\"clock\">{time}</h2>\n\n );\n}\nfunction getApps() {\n let applications = require('./apps.json');\n return applications;\n}\nfunction getLinks() {\n let links = require('./links.json');\n return links;\n}\nfunction getProviders() {\n let providers = require('./providers.json');\n return providers;\n}\nfunction getThemes() {\n let themes = require('./themes.json');\n return themes;\n}\nfunction updateTheme(e) {\n var themes = getThemes();\n var themeName = e.target.innerHTML.toLowerCase();\n var index = themes.themes.findIndex(function(item, i){\n return item.name === themeName;\n });\n localStorage.setItem(\"image-background\", themes.themes[index].imagebackground);\n localStorage.setItem(\"color-background\", themes.themes[index].colorbackground);\n localStorage.setItem(\"color-search-background\", themes.themes[index].colorserachbackground);\n localStorage.setItem(\"color-text-pri\",themes.themes[index].colortextpri);\n localStorage.setItem(\"color-text-acc\", themes.themes[index].colortextacc);\n localStorage.setItem(\"color-border\", themes.themes[index].colorborder);\n \n //document.documentElement.style.setProperty(prop, `var(--${themeName}${prop.substring(10)})`);\n setTheme();\n}\nfunction setTheme() {\n setValueFromLocalStorage('image-background');\n setValueFromLocalStorage('color-background');\n setValueFromLocalStorage('color-search-background');\n setValueFromLocalStorage('color-text-pri');\n setValueFromLocalStorage('color-text-acc');\n setValueFromLocalStorage('color-border');\n setValueFromLocalStorage('content-display');\n}\nfunction handleKeyPress(e) {\n var sindex = 0;\n var cycle = false;\n var key = e.keyCode || e.which;\n var text = e.target.value.replaceAll(\"+\", \"%2B\");\n var option = text.substr(1, text.indexOf(' ') - 1) || text.substr(1);\n var subtext = text.substr(2 + option.length);\n if (key === 13) { // Search functions\n search(text);\n }\n if (key === 9) { // Tab Completion Functions\n e.preventDefault();\n e.stopPropagation();\n if (text[0] === ';') {\n switch (option) {\n case 't':\n var streamers = ['admiralbahroo', 'moonmoon_ow', 'witwix'];\n if (!subtext || cycle) {\n cycle = true;\n if (sindex > streamers.length - 1) sindex = 0;\n document.getElementById(\"keywords\").value = ';t ' + streamers[sindex++];\n return;\n }\n for (var streamer of streamers) {\n if (subtext === streamer.substr(0, subtext.length)) {\n document.getElementById(\"keywords\").value = ';t ' + streamer;\n return;\n }\n }\n break;\n default :\n break;\n }\n }\n }\n if(key === 32){ //Space to go to search\n updateLabel(text);\n }\n sindex = 0;\n cycle = false;\n updateLabel(text);\n}\nfunction updateLabel(text) {\n var option = text.substr(1, text.indexOf(' ') - 1) || text.substr(1);\n if (text[0] === '/') {\n// if (text.indexOf(' ') > -1) {\n switch (option) {\n case \"am\":\n document.getElementById(\"searchType\").innerHTML = \"Allmusic search\";\n break;\n case \"d\":\n document.getElementById(\"searchType\").innerHTML = \"Duck Duck Go search\";\n break;\n case \"di\":\n document.getElementById(\"searchType\").innerHTML = \"Discogs search\";\n break;\n case \"i\":\n document.getElementById(\"searchType\").innerHTML = \"IMDB search\";\n break;\n case \"m\":\n document.getElementById(\"searchType\").innerHTML = \"TheMovieDB search\";\n break;\n case \"r\":\n document.getElementById(\"searchType\").innerHTML = \"Reddit search\";\n break;\n case \"q\":\n document.getElementById(\"searchType\").innerHTML = \"Qwant search\";\n break;\n case \"so\":\n document.getElementById(\"searchType\").innerHTML = \"Soundcloud search\";\n break;\n case \"s\":\n document.getElementById(\"searchType\").innerHTML = \"Spotify search\";\n break;\n case \"tv\":\n document.getElementById(\"searchType\").innerHTML = \"TheTVDB search\";\n break;\n case \"t\":\n document.getElementById(\"searchType\").innerHTML = \"Trakt search\";\n break;\n case \"y\":\n document.getElementById(\"searchType\").innerHTML = \"YouTube search\";\n break;\n case \"w\":\n document.getElementById(\"searchType\").innerHTML = \"Wikipedia search\";\n break;\n case \"p\":\n document.getElementById(\"searchType\").innerHTML = \"Plex search\";\n break;\n case \"rt\":\n document.getElementById(\"searchType\").innerHTML = \"Rotten Tomatoes search\";\n break;\n default:\n document.getElementById(\"searchType\").innerHTML = \"Invalid search\";\n break;\n }\n}else {\n document.getElementById(\"searchType\").innerHTML = \"Google search\";\n }\n}\nfunction search(text) {\n if (text[0] === '/') {\n if (text.indexOf(' ') > -1) {\n let option = text.substr(1, text.indexOf(' ') - 1) || text.substr(1);\n var subtext = text.substr(2 + option.length);\n switch (option) {\n case \"am\":\n window.location = \"https://www.allmusic.com/search/all/\" + subtext;\n break;\n case \"d\":\n window.location = \"https://duckduckgo.com/?q=\" + subtext;\n break;\n case \"di\":\n window.location = \"https://www.discogs.com/search/?q=\" + subtext;\n break;\n case \"i\":\n window.location = \"https://www.imdb.com/find?q=\" + subtext;\n break;\n case \"m\":\n window.location = \"https://www.themoviedb.org/search?query=\" + subtext;\n break;\n case \"r\":\n window.location = \"https://www.reddit.com/search?q=\" + subtext;\n break;\n case \"q\":\n window.location = \"https://www.qwant.com/?q=\" + subtext;\n break;\n case \"so\":\n window.location = \"https://soundcloud.com/search?q=\" + subtext;\n break;\n case \"s\":\n window.location = \"https://open.spotify.com/search/results/\" + subtext;\n break;\n case \"t\":\n window.location = \"https://trakt.tv/search?query=\" + subtext;\n break;\n case \"tv\":\n window.location = \"https://www.thetvdb.com/search?query=\" + subtext;\n break;\n case \"y\":\n window.location = \"https://www.youtube.com/results?search_query=\" + subtext;\n break;\n case \"w\":\n window.location = \"https://en.wikipedia.org/w/index.php?search=\" + subtext;\n break;\n case \"p\":\n window.location = \"https://app.plex.tv/desktop/#!/search?query=\" + subtext;\n break;\n case \"rt\":\n window.location = \"https://www.rottentomatoes.com/search?search=\" + subtext;\n break;\n default :\n break;\n }\n } else {\n let option = text.substr(1);\n switch (option) {\n case \"d\":\n window.location = \"https://www.duckduckgo.com\";\n break;\n case \"y\":\n window.location = \"https://www.youtube.com\";\n break;\n case \"r\":\n window.location = \"https://reddit.com\";\n break;\n case \"s\":\n window.location = \"https://open.spotify.com\";\n break;\n default :\n break;\n }\n }\n } else if (validURL(text)) {\n if (containsProtocol(text))\n window.location = text;\n else\n window.location = \"https://\" + text;\n } else {\n window.location = \"https://www.google.com/search?q=\" + text;\n }\n}\nfunction validURL(str) {\n var pattern = new RegExp('^(https?:\\\\/\\\\/)?' + // protocol\n '((([a-z\\\\d]([a-z\\\\d-]*[a-z\\\\d])*)\\\\.)+[a-z]{2,}|' + // domain name\n '((\\\\d{1,3}\\\\.){3}\\\\d{1,3}))' + // OR ip (v4) address\n '(\\\\:\\\\d+)?(\\\\/[-a-z\\\\d%_.~+]*)*' + // port and path\n '(\\\\?[;&a-z\\\\d%_.~+=-]*)?' + // query string\n '(\\\\#[-a-z\\\\d_]*)?$', 'i'); // fragment locator\n return !!pattern.test(str);\n}\nfunction containsProtocol(str) {\n var pattern = new RegExp('^(https?:\\\\/\\\\/){1}.*', 'i');\n return !!pattern.test(str);\n}\nString.prototype.replaceAll = function(search, replacement) {\n var target = this;\n return target.split(search).join(replacement);\n};\nfunction udpateDisplayedItems(e) {\n localStorage.setItem('contenttype', e.target.checked);\n if (e.target.checked) {\n localStorage.setItem('content-display', 'none');\n } else {\n localStorage.setItem('content-display', 'block');\n }\n setDisplayedItems();\n}\nfunction setDisplayedItems() {\n setValueFromLocalStorage('contenttype');\n setValueFromLocalStorage('content-display');\n}",{"ruleId":"9","severity":1,"message":"10","line":206,"column":11,"nodeType":"11","endLine":206,"endColumn":61},{"ruleId":"12","severity":1,"message":"13","line":607,"column":1,"nodeType":"14","messageId":"15","endLine":610,"endColumn":2},"jsx-a11y/anchor-is-valid","The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/HEAD/docs/rules/anchor-is-valid.md","JSXOpeningElement","no-extend-native","String prototype is read only, properties should not be added.","AssignmentExpression","unexpected"] |