summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'js/portfolio.js')
-rw-r--r--js/portfolio.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/js/portfolio.js b/js/portfolio.js
new file mode 100644
index 0000000..6feeeae
--- /dev/null
+++ b/js/portfolio.js
@@ -0,0 +1,26 @@
1var sleep = function(ms, callback) {
2 setTimeout(function() {
3 callback()
4 }, ms)
5 },
6 favthings = ["Python", "C programming", "raspberrypi", "Linux"],
7 removeClass = function(el, className) {
8 el.classList ? el.classList.remove(className) : el.className = el.className.replace(new RegExp("(^|\\b)" + className.split(" ").join("|") + "(\\b|$)", "gi"), " ")
9 },
10 addClass = function(el, className) {
11 el.classList ? el.classList.add(className) : el.className += " " + className
12 },
13 i = 0,
14 nextThing = function(thing) {
15 i < favthings.length - 1 ? i++ : i = 0, removeClass(thing, "slideInDown"), addClass(thing, "slideOutUp"), sleep(700, function() {
16 thing.innerHTML = favthings[i], removeClass(thing, "slideOutUp"), addClass(thing, "slideInDown")
17 })
18 };
19document.addEventListener("DOMContentLoaded", function() {
20 var thing = document.querySelectorAll(".favthing")[0];
21 setTimeout(function() {
22 nextThing(thing)
23 }, 1e3), setInterval(function() {
24 nextThing(thing)
25 }, 4e3)
26});
Powered by cgit v1.2.3 (git 2.41.0)