Created CV Section #6

Merged
rodude123 merged 17 commits from cv into master 2021-08-31 18:53:13 +01:00
19 changed files with 3205 additions and 80 deletions

View File

@ -7,6 +7,16 @@ jobs:
steps: steps:
- name: 🚚 Get latest code - name: 🚚 Get latest code
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Use Node.js 12
uses: actions/setup-node@v2-beta
with:
node-version: '12'
- name: 🔨Run Gulp
run: |
npm install
npm start
- name: 📂 Sync files - name: 📂 Sync files
uses: SamKirkland/FTP-Deploy-Action@4.1.0 uses: SamKirkland/FTP-Deploy-Action@4.1.0

5
.gitignore vendored
View File

@ -70,3 +70,8 @@ fabric.properties
# Android studio 3.1+ serialized cache file # Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser .idea/caches/build_file_checksums.ser
# Custom ignores
.env
vendor/*
node_modules/*

13
composer.json Normal file
View File

@ -0,0 +1,13 @@
{
"require": {
"slim/slim-skeleton": "^4.3",
"ext-pdo": "*",
"slim/psr7": "^1.4",
"nyholm/psr7": "^1.4",
"nyholm/psr7-server": "^1.0",
"guzzlehttp/psr7": "^2.0",
"http-interop/http-factory-guzzle": "^1.2",
"laminas/laminas-diactoros": "^2.6",
"laminas/laminas-httphandlerrunner": "^2.0"
}
}

1733
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

59
dist/api/index.php vendored Normal file
View File

@ -0,0 +1,59 @@
<?php
////////////////// Index file //////////////
/// Creates base routes and runs ///
/// respective functions ///
////////////////////////////////////////////
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
//require “routes.php”;
require "../vendor/autoload.php";
include "timelineData.php";
// Start slim
$app = AppFactory::create();
// create middleware
$app->addRoutingMiddleware();
// for error checking
$errorMiddleware = $app->addErrorMiddleware(true, true, true);
$app->setBasePath("/api");
$timelineData = new TimelineData();
$app->get("/timelineData/{timeline}", function (Request $request, Response $response, array $args)
{
global $timelineData;
$json = $result = "";
//check if route is available if it is get the data
//otherwise return an error
if($args["timeline"] == "edu")
{
$result = $timelineData->getEduData();
}
else if($args["timeline"] == "work")
{
$result = $timelineData->getWorkData();
}
else
{
$result = array(array("errorMessage" => "Error, timeline data not found"));
}
$json = json_encode($result);
$response->getBody()->write($json);
//if it is an error give a 404 code since it can't find the data
if(array_key_exists("errorMessage", $result[0]))
{
$response = $response->withStatus(404);
}
//use content type json to indicate json data on frontend.
return $response->withHeader("Content-Type", "application/json");
});
$app->run();

2
dist/css/main.css vendored

File diff suppressed because one or more lines are too long

2
dist/index.html vendored

File diff suppressed because one or more lines are too long

2
dist/js/main.js vendored
View File

@ -1 +1 @@
const scrollLimit=150;window.onscroll=()=>{document.body.scrollTop>=150||document.documentElement.scrollTop>=150?document.querySelector("nav").classList.add("scrolled"):document.querySelector("nav").classList.remove("scrolled");let e="";document.querySelectorAll("section").forEach((t=>{const o=t.offsetTop;window.pageYOffset>=o-60&&(e=t.getAttribute("id"))})),document.querySelectorAll("nav ul li a").forEach((t=>{t.classList.remove("active"),t.href.includes(e)&&""!==e?t.classList.add("active"):""===e&&document.querySelector("nav ul li a").classList.add("active")}))},document.addEventListener("DOMContentLoaded",(()=>{var e=["full stack developer","web designer","student","gamer","drummer"];function t(e,o,n){o<e.length?(document.querySelector("header div h1").innerHTML=e.substring(0,o+1)+'<span aria-hidden="true">_</span>',setTimeout((function(){t(e,o+1,n)}),100)):"function"==typeof n&&setTimeout(n,700)}!function o(n){void 0===e[n]?setTimeout((function(){o(0)}),1500):n<e[n].length&&t(e[n],0,(function(){setTimeout(o,1500,n+1)}))}(0)})); const scrollLimit=150;var dataText=["full stack developer","web designer","student","gamer","drummer"];function typeWriter(t,e,n){e<t.length?(document.querySelector("header div h1").innerHTML=t.substring(0,e+1)+'<span aria-hidden="true">_</span>',setTimeout((function(){typeWriter(t,e+1,n)}),100)):"function"==typeof n&&setTimeout(n,700)}function StartTextAnimation(t){void 0===dataText[t]?setTimeout((function(){StartTextAnimation(0)}),1500):t<dataText[t].length&&typeWriter(dataText[t],0,(function(){setTimeout(StartTextAnimation,1500,t+1)}))}function getTimelineData(){fetch("/api/timelineData/edu").then((t=>{t.json().then((e=>{t.ok&&e.forEach((t=>{let e=document.createElement("div");e.classList.add("timelineItem"),e.innerHTML=`\n\t\t\t\t\t<h3 class="timelineHeader">${t.startPeriod} - ${t.endPeriod}</h3>\n\t\t\t\t\t<span>Grade: ${t.grade}</span>\n\t\t\t\t\t<p class="timelineText">${t.course}</p>\n\t\t\t\t`,document.getElementById("edu").appendChild(e)}))}))})),fetch("/api/timelineData/work").then((t=>{t.json().then((e=>{t.ok&&e.forEach((t=>{let e=document.createElement("div");e.classList.add("timelineItem"),e.innerHTML=`\n\t\t\t\t\t<h3 class="timelineHeader">${t.startPeriod} - ${t.endPeriod}</h3>\n\t\t\t\t\t<span>${t.companyName} - ${t.area}</span>\n\t\t\t\t\t<p class="timelineText">${t.title}</p>\n\t\t\t\t`,document.getElementById("work").appendChild(e)}))}))}))}window.onscroll=()=>{document.body.scrollTop>=150||document.documentElement.scrollTop>=150?document.querySelector("nav").classList.add("scrolled"):document.querySelector("nav").classList.remove("scrolled");let t="";document.querySelectorAll("section").forEach((e=>{const n=e.offsetTop;window.pageYOffset>=n-60&&(t=e.getAttribute("id"))})),document.querySelectorAll("nav ul li a").forEach((e=>{e.classList.remove("active"),e.href.includes(t)&&""!==t?e.classList.add("active"):""===t&&document.querySelector("nav ul li a").classList.add("active")}))},document.addEventListener("DOMContentLoaded",(()=>{StartTextAnimation(0),getTimelineData()}));

BIN
dist/other/rohitpaicv.pdf vendored Normal file

Binary file not shown.

View File

@ -1,8 +1,14 @@
const gulp = require("gulp"); const gulp = require("gulp")
const browserSync = require("browser-sync").create(); const browserSync = require("browser-sync").create();
const htmlMin = require("gulp-htmlmin"); const htmlMin = require("gulp-htmlmin");
const cssMin = require("gulp-clean-css") const cssMin = require("gulp-clean-css")
const terser = require("gulp-terser"); const terser = require("gulp-terser");
const ftp = require("vinyl-ftp");
const env = require("gulp-env");
env({
file: ".env",
type: ".ini"
});
gulp.task("minifyHTML", () => gulp.task("minifyHTML", () =>
{ {
@ -20,18 +26,53 @@ gulp.task("minifyCSS", () =>
gulp.task("minifyJS", () => gulp.task("minifyJS", () =>
{ {
function createErrorHandler(name) { function createErrorHandler(name)
return function (err) { {
return function (err)
{
console.error("Error from " + name + " in compress task", err.toString()); console.error("Error from " + name + " in compress task", err.toString());
}; };
} }
return gulp.src("src/js/*.js") return gulp.src("src/js/*.js")
.on("error", createErrorHandler("gulp.src")) .on("error", createErrorHandler("gulp.src"))
.pipe(terser()) .pipe(terser())
.on("error", createErrorHandler("terser")) .on("error", createErrorHandler("terser"))
.pipe(gulp.dest("dist/js")) .pipe(gulp.dest("dist/js"))
.on("error", createErrorHandler("gulp.dest")); .on("error", createErrorHandler("gulp.dest"));
});
gulp.task("movePHPFiles", () =>
{
return gulp.src("src/api/*.php")
.pipe(gulp.dest("dist/api"))
});
gulp.task("watchFiles", () =>
{
gulp.watch("src/*.html", gulp.task("minifyHTML"));
gulp.watch("src/css/*.css", gulp.task("minifyCSS"));
gulp.watch("src/js/*.js", gulp.task("minifyJS"));
gulp.watch("src/api/*.php", gulp.task("movePHPFiles"))
});
gulp.task("ftp", () =>
{
let conn = ftp.create(
{
host: process.env.host,
user: process.env.user,
pass: process.env.pass,
parallel: 1,
});
return gulp.src("dist/**", {base: "dist", dot: true})
.pipe(conn.newer("/"))
.pipe(conn.dest("/"));
});
gulp.task("deploy", () =>
{
gulp.watch("dist", gulp.task("ftp"));
}); });
gulp.task("browserSync", () => gulp.task("browserSync", () =>
@ -41,11 +82,7 @@ gulp.task("browserSync", () =>
baseDir: "dist" baseDir: "dist"
} }
}); });
gulp.watch("src/*.html", gulp.task("minifyHTML"));
gulp.watch("src/css/*.css", gulp.task("minifyCSS"));
gulp.watch("src/js/*.js", gulp.task("minifyJS"));
gulp.watch("dist").on("change", browserSync.reload) gulp.watch("dist").on("change", browserSync.reload)
}); });
gulp.task("default", gulp.series("browserSync")); gulp.task("default", gulp.series(gulp.parallel("watchFiles", "deploy")));

902
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -15,10 +15,13 @@
"browser-sync": "^2.26.14", "browser-sync": "^2.26.14",
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-clean-css": "^4.3.0", "gulp-clean-css": "^4.3.0",
"gulp-uglify": "^3.0.2", "gulp-deploy-ftp": "^1.0.1",
"gulp-env": "^0.4.0",
"gulp-htmlmin": "^5.0.1", "gulp-htmlmin": "^5.0.1",
"gulp-terser": "^2.0.1", "gulp-terser": "^2.0.1",
"gulp-uglify": "^3.0.2",
"normalize.css": "^8.0.1", "normalize.css": "^8.0.1",
"require": "^0.4.4" "require": "^0.4.4",
"vinyl-ftp": "^0.6.1"
} }
} }

59
src/api/index.php Normal file
View File

@ -0,0 +1,59 @@
<?php
////////////////// Index file //////////////
/// Creates base routes and runs ///
/// respective functions ///
////////////////////////////////////////////
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
//require “routes.php”;
require "../vendor/autoload.php";
include "timelineData.php";
// Start slim
$app = AppFactory::create();
// create middleware
$app->addRoutingMiddleware();
// for error checking
$errorMiddleware = $app->addErrorMiddleware(true, true, true);
$app->setBasePath("/api");
$timelineData = new TimelineData();
$app->get("/timelineData/{timeline}", function (Request $request, Response $response, array $args)
{
global $timelineData;
$json = $result = "";
//check if route is available if it is get the data
//otherwise return an error
if($args["timeline"] == "edu")
{
$result = $timelineData->getEduData();
}
else if($args["timeline"] == "work")
{
$result = $timelineData->getWorkData();
}
else
{
$result = array(array("errorMessage" => "Error, timeline data not found"));
}
$json = json_encode($result);
$response->getBody()->write($json);
//if it is an error give a 404 code since it can't find the data
if(array_key_exists("errorMessage", $result[0]))
{
$response = $response->withStatus(404);
}
//use content type json to indicate json data on frontend.
return $response->withHeader("Content-Type", "application/json");
});
$app->run();

49
src/api/timelineData.php Normal file
View File

@ -0,0 +1,49 @@
<?php
require_once "./config.php";
/**
* TimelineData class
* Define all functions which either get, update, create or delete timeline data
*/
class TimelineData
{
function getEduData()
{
$conn = dbConn();
$stmt = $conn->prepare("SELECT DATE_FORMAT(startPeriod, '%b, %Y') as startPeriod, DATE_FORMAT(endPeriod, '%b, %Y') as endPeriod, grade, course FROM edu ORDER BY startPeriod DESC;");
$stmt->execute();
// set the resulting array to associative
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($result)
{
return $result;
}
else
{
return array(array("errorMessage" => "Error, edu data not found"));
}
}
function getWorkData()
{
$conn = dbConn();
$stmt = $conn->prepare("SELECT DATE_FORMAT(startPeriod, '%b, %Y') as startPeriod, DATE_FORMAT(endPeriod, '%b, %Y') as endPeriod, companyName, area, title FROM work ORDER BY startPeriod DESC;");
$stmt->execute();
// set the resulting array to associative
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($result)
{
return $result;
}
else
{
return array(array("errorMessage" => "Error, work data not found"));
}
}
}

View File

@ -5,13 +5,17 @@
/****** Root Style ******/ /****** Root Style ******/
:root { :root {
/* Colours */ /* Colours */
--primaryDefault: hsla(79, 62%, 51%, 1); --mainHue: 79;
--primaryHover: hsla(79, 75%, 41%, 1); --mainSat: 62%;
--errorDefault: hsla(0, 62%, 51%, 1); --mainLight: 51%;
--primaryDefault: hsla(var(--mainHue), var(--mainSat), var(--mainLight), 1);
--primaryHover: hsla(var(--mainHue), var(--mainSat), calc(var(--mainLight) - 10%), 1);
--timelineItemBrdr: hsla(var(--mainHue), var(--mainSat), calc(var(--mainLight) - 20%), 1);
--errorDefault: hsla(0, var(--mainSat), var(--mainLight), 1);
--grey: hsla(0, 0%, 39%, 1); --grey: hsla(0, 0%, 39%, 1);
--mutedGrey: hsla(0, 0%, 67%, 0.58); --mutedGrey: hsla(0, 0%, 67%, 0.58);
--mutedBlack: hsla(0, 0%, 0%, 0.25); --mutedBlack: hsla(0, 0%, 0%, 0.25);
--navBack: hsl(0, 0%, 30%); --navBack: hsla(0, 0%, 30%, 1);
/* Font Sizes */ /* Font Sizes */
--titleFS: 2.25rem; --titleFS: 2.25rem;
@ -79,7 +83,6 @@ a.btnOutline {
a.btnPrimary:hover, form input[type="submit"]:hover { a.btnPrimary:hover, form input[type="submit"]:hover {
background: var(--primaryHover); background: var(--primaryHover);
} }
a.btn:active, form input[type="submit"]:active { a.btn:active, form input[type="submit"]:active {
@ -98,6 +101,10 @@ a.btn:active, form input[type="submit"]:active {
text-shadow: 0 6px 4px var(--mutedBlack); text-shadow: 0 6px 4px var(--mutedBlack);
} }
section#about, section#curriculumvitae h1 {
padding: 0 5rem;
}
/*** Navigation Styles **/ /*** Navigation Styles **/
header { header {
@ -122,6 +129,7 @@ nav {
nav.scrolled { nav.scrolled {
background-color: var(--navBack); background-color: var(--navBack);
z-index: 1;
} }
nav #nav-check { nav #nav-check {
@ -204,19 +212,156 @@ div h1 span {
/***** About Styles *****/ /***** About Styles *****/
section#about { section#about {
padding: 0 5em; margin-bottom: 5rem;
} }
section#about div { section#about div {
padding: 0.1em 5em; padding: 0.1em 5em;
} }
/****** CV Styles *******/
section#curriculumvitae{
background-color: var(--primaryDefault);
color: #FFFFFF;
padding: 2em 0;
}
section#curriculumvitae .cvGrid {
display: flex;
flex-direction: row;
padding: 0 1.5rem;
flex-wrap: wrap;
}
section#curriculumvitae .cvGrid > div {
width: 45%;
display: flex;
flex-direction: column;
min-height: 100%;
}
section#curriculumvitae .cvGrid h2 {
text-align: center;
}
section#curriculumvitae .timeline {
position: relative;
max-width: 30em;
gap: 1em;
display: flex;
flex-direction: column;
margin: 0 auto;
height: 100%;
}
section#curriculumvitae #work {
margin: 0 auto 0 8rem;
}
section#curriculumvitae .timeline:before {
content: "";
position: absolute;
height: 100%;
border: 4px var(--timelineItemBrdr) solid;
/*border-bottom: 4;*/
right: 194px;
top: 0;
}
section#curriculumvitae .timeline:after {
content: "";
display: table;
clear: both;
}
section#curriculumvitae .timelineItem {
border: 2px solid var(--timelineItemBrdr);
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
padding: 0 1rem;
width: 50%;
position: relative;
background-color: var(--primaryHover);
}
section#curriculumvitae .timelineItem:before, .timelineItem:after {
content: '';
position: absolute;
}
section#curriculumvitae .timelineItem:before{
content: '';
right: -20px;
top: calc(50% - 5px);
border-style: solid;
border-color: var(--timelineItemBrdr) var(--timelineItemBrdr) transparent transparent;
border-width: 20px;
transform: rotate(45deg);
}
section#curriculumvitae .timelineItem:nth-child(2n) {
margin-left: 21em;
}
section#curriculumvitae .timelineItem:nth-child(2n):before {
right: auto;
left: -20px;
border-color: transparent transparent var(--timelineItemBrdr) var(--timelineItemBrdr);
}
section#curriculumvitae .timelineItem h3 {
font-weight: normal;
}
section#curriculumvitae .timelineItem span {
color: hsl(0, 0%, 90%);
}
/**** Media Queries *****/ /**** Media Queries *****/
@media screen and (max-width: 90em) {
/****** CV Styles *******/
section#curriculumvitae .cvGrid {
flex-direction: column;
justify-content: center;
align-items: center;
}
section#curriculumvitae .cvGrid > div {
width: 100%;
}
section#curriculumvitae .cvGrid > div:first-child {
padding-bottom: 2.5em;
margin-bottom: 2.5em;
border-bottom: 5px #FFFFFF solid;
}
section#curriculumvitae .cvGrid h2 {
margin-left: 5em;
}
section#curriculumvitae .cvGrid .timeline {
margin: 0 auto;
}
}
@media screen and (max-width: 75em) { @media screen and (max-width: 75em) {
/*** Template Styles ****/
section#about, section#curriculumvitae h1 {
padding: 0 1em;
}
/*** Navigation Styles **/ /*** Navigation Styles **/
/** Default Nav Styles **/
nav { nav {
display: block; display: block;
height: 50px; height: 50px;
@ -380,16 +525,54 @@ section#about div {
/***** About Styles *****/ /***** About Styles *****/
section#about {
padding: 0 1em;
}
section#about div { section#about div {
padding: 0.1em 2.5em; padding: 0.1em 2.5em;
} }
/****** CV Styles *******/
section#curriculumvitae .cvGrid {
padding: 0;
}
}
@media screen and (max-width: 55em) {
/****** CV Styles *******/
section#curriculumvitae .cvGrid .timeline {
margin: 0 1em;
max-width: 100%;
}
section#curriculumvitae .timeline:before {
border: none;
}
section#curriculumvitae .timelineItem{
width: 95%;
}
section#curriculumvitae .timelineItem:nth-child(2n) {
margin-left: 0;
}
section#curriculumvitae .timelineItem:before {
right: unset;
left: unset;
border:none
}
} }
@media screen and (max-width: 31em) { @media screen and (max-width: 31em) {
/*** Template Styles ****/
section#about, section#curriculumvitae h1 {
padding: 0 1em;
}
/*** Navigation Styles **/ /*** Navigation Styles **/
header div h1 { header div h1 {
@ -399,10 +582,6 @@ section#about div {
/***** About Styles *****/ /***** About Styles *****/
section#about {
padding: 0 0.5em;
}
section#about div { section#about div {
padding: 0.1em 1em; padding: 0.1em 1em;
} }

BIN
src/imgs/hero before.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 KiB

View File

@ -5,7 +5,7 @@
<meta name="viewport" <meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title> <title>Rohit Pai - Portfolio</title>
<link rel="stylesheet" href="css/main.css"> <link rel="stylesheet" href="css/main.css">
<script src="https://kit.fontawesome.com/ed3c25598e.js" crossorigin="anonymous"></script> <script src="https://kit.fontawesome.com/ed3c25598e.js" crossorigin="anonymous"></script>
<script src="js/main.js"></script> <script src="js/main.js"></script>
@ -26,7 +26,7 @@
</div> </div>
<ul> <ul>
<li><a href="#about" class="textShadow active"><span>&lt;</span>about<span>&gt;</span></a></li> <li><a href="#about" class="textShadow active"><span>&lt;</span>about<span>&gt;</span></a></li>
<li><a href="#curiculumvitae" class="textShadow"><span>&lt;</span>cv<span>&gt;</span></a></li> <li><a href="#curriculumvitae" class="textShadow"><span>&lt;</span>cv<span>&gt;</span></a></li>
<li><a href="#projects" class="textShadow"><span>&lt;</span>projects<span>&gt;</span></a></li> <li><a href="#projects" class="textShadow"><span>&lt;</span>projects<span>&gt;</span></a></li>
<li><a href="#contact" class="textShadow"><span>&lt;</span>contact<span>&gt;</span></a></li> <li><a href="#contact" class="textShadow"><span>&lt;</span>contact<span>&gt;</span></a></li>
<li><a href="#" class="textShadow"><span>&lt;</span>blog<span>&gt;</span></a></li> <li><a href="#" class="textShadow"><span>&lt;</span>blog<span>&gt;</span></a></li>
@ -52,16 +52,19 @@
<a href="other/rohitpaicv.pdf" class="btn btnOutline boxShadowIn boxShadowOut" download>Download CV</a> <a href="other/rohitpaicv.pdf" class="btn btnOutline boxShadowIn boxShadowOut" download>Download CV</a>
</div> </div>
</section> </section>
<section id="curiculumvitae"> <section id="curriculumvitae">
<h1>curriculum vitae</h1> <h1>curriculum vitae</h1>
<div class="cvGrid"> <div class="cvGrid">
<!-- https://codepen.io/keithwyland/pen/wqNqvy -->
<div> <div>
<h2>Education</h2> <h2>Education</h2>
<div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Autem ipsum nobis officia sequi. Beatae hic molestiae quibusdam repellendus vero voluptatem!</div> <div class="timeline" id="edu">
</div>
</div> </div>
<div> <div>
<h2>Work</h2> <h2>Work</h2>
<div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid aperiam atque blanditiis doloribus labore minima odio recusandae tempore. Totam, ut!</div> <div class="timeline" id="work">
</div>
</div> </div>
</div> </div>
</section> </section>

View File

@ -1,5 +1,9 @@
// scrolling effect // scrolling effect
const scrollLimit = 150; const scrollLimit = 150;
// array with texts to type in typewriter
var dataText = ["full stack developer", "web designer", "student", "gamer", "drummer"];
window.onscroll = () => window.onscroll = () =>
{ {
// check if scrolled past limit if so add scrolled class to change background of nav // check if scrolled past limit if so add scrolled class to change background of nav
@ -39,47 +43,118 @@ window.onscroll = () =>
}); });
}; };
// typewriter effect
/**
* typeWriter function
* type one character at a time in the typewriter
* keeps calling itself until the text is finished
* @param {string} text text to type
* @param {number} i current index at which the next character should be typed
* @param {function} fnCallback function to call back in this case the StartTextAnimation function
*/
function typeWriter(text, i, fnCallback)
{
// check if text isn't finished yet
if (i < (text.length))
{
// add next character to h1
document.querySelector("header div h1").innerHTML = text.substring(0, i + 1) + "<span aria-hidden=\"true\">_</span>";
// wait for a while and call this function again for next character
setTimeout(function ()
{
typeWriter(text, i + 1, fnCallback)
}, 100);
}
// text finished, call callback if there is a callback function
else if (typeof fnCallback == "function")
{
// call callback after timeout
setTimeout(fnCallback, 700);
}
}
/**
* StartTextAnimation function
* start a typewriter animation for a text in the dataText array
* @param {number} i current index at which text should be typed next
*/
function StartTextAnimation(i)
{
if (typeof dataText[i] === "undefined")
{
setTimeout(function ()
{
StartTextAnimation(0);
}, 1500);
}
else if (i < dataText[i].length)
{
// text exists! start typewriter animation
typeWriter(dataText[i], 0, function ()
{
// after callback (and whole text has been animated), start next text
setTimeout(StartTextAnimation, 1500, i + 1);
});
}
}
// cv timeline data
/**
* getTimelineData function
* Gets the timeline data from backend route and appends the data on to the timeline.
*/
function getTimelineData()
{
fetch("/api/timelineData/edu").then(res =>
{
res.json().then(json =>
{
if (res.ok)
{
json.forEach(item =>
{
let timelineItem = document.createElement("div")
timelineItem.classList.add("timelineItem");
timelineItem.innerHTML = `
<h3 class="timelineHeader">${item["startPeriod"]} - ${item["endPeriod"]}</h3>
<span>Grade: ${item["grade"]}</span>
<p class="timelineText">${item["course"]}</p>
`;
document.getElementById("edu").appendChild(timelineItem);
});
}
})
});
fetch("/api/timelineData/work").then(res =>
{
res.json().then(json =>
{
if (res.ok)
{
json.forEach(item =>
{
let timelineItem = document.createElement("div")
timelineItem.classList.add("timelineItem");
timelineItem.innerHTML = `
<h3 class="timelineHeader">${item["startPeriod"]} - ${item["endPeriod"]}</h3>
<span>${item["companyName"]} - ${item["area"]}</span>
<p class="timelineText">${item["title"]}</p>
`;
document.getElementById("work").appendChild(timelineItem);
})
}
})
})
}
document.addEventListener('DOMContentLoaded', () => document.addEventListener('DOMContentLoaded', () =>
{ {
// array with texts to type in typewriter // start the text animation
var dataText = [ "full stack developer", "web designer", "student", "gamer", "drummer"]; StartTextAnimation(0);
// type one text in the typwriter
// keeps calling itself until the text is finished
function typeWriter(text, i, fnCallback) {
// chekc if text isn't finished yet
if (i < (text.length)) {
// add next character to h1
document.querySelector("header div h1").innerHTML = text.substring(0, i+1) +'<span aria-hidden="true">_</span>';
// wait for a while and call this function again for next character
setTimeout(function() {
typeWriter(text, i + 1, fnCallback)
}, 100);
}
// text finished, call callback if there is a callback function
else if (typeof fnCallback == 'function') {
// call callback after timeout
setTimeout(fnCallback, 700);
}
}
// start a typewriter animation for a text in the dataText array
function StartTextAnimation(i) {
if (typeof dataText[i] === 'undefined'){
setTimeout(function() {
StartTextAnimation(0);
}, 1500);
// StartTextAnimation(0);
}
else if (i < dataText[i].length) {
// text exists! start typewriter animation
typeWriter(dataText[i], 0, function(){
// after callback (and whole text has been animated), start next text
setTimeout(StartTextAnimation, 1500, i + 1);
});
}
}
// start the text animation
StartTextAnimation(0);
});
// get timeline data and add it to the timeline
getTimelineData();
});

BIN
src/other/rohitpaicv.pdf Normal file

Binary file not shown.