diff --git a/computer-science-blog/index.html b/computer-science-blog/index.html index e8cea21..9b888f7 100644 --- a/computer-science-blog/index.html +++ b/computer-science-blog/index.html @@ -68,10 +68,8 @@ The current date is: unknown - + - _____AREA_OF_STUDY_____ Presentation - @@ -89,6 +87,10 @@ Validate with the Luhn Algorithm + _____AREA_OF_STUDY_____ Presentation + + + navigate_before diff --git a/computer-science-blog/scripts/scripts.js b/computer-science-blog/scripts/scripts.js index 7d4547f..27157d1 100644 --- a/computer-science-blog/scripts/scripts.js +++ b/computer-science-blog/scripts/scripts.js @@ -1,6 +1,36 @@ // set page title window.page_title = "Computer Science Blog | Matthew Grove"; + +function nextPage() { + // if there are more slides to come, display the next one + if (window.current_blog_page < window.pages.length) { + displayPage(window.pages[window.current_blog_page + 1]); + } else { + // if end of presentation has been reached, display the first slide + displayPage(window.pages[0]); + } +} + +function previousPage() { + // if there are more slides before the current one, display the previous slide + if (window.current_blog_page >= 1) { + displayPage(window.pages[window.current_blog_page - 1]); + } else { + // if end of presentation has been reached, display the first slide + displayPage(window.pages[window.pages.length - 1]); + } +} + +function displayPage(page) { + // document.getElementById("iframe").src = "pages/" + page + ".html"; + $("#presentation").load(page); +} + +var pages = ["page_01", "page_02", "page_03"]; +var pageIndex = 0; + window.onload = function() { + // set the current date var date = new Date(); @@ -12,24 +42,23 @@ window.onload = function() { // display date $("#current_date").html(current_date); - - // include navbar - $(".blog-insert").load("pages/blog.html", function(){ - - }); -} - -function nextPage() { - displayPage(pages[0]); -} - -function previousPage() { -} - -function displayPage(page) { - document.getElementById("iframe").src = "pages/" + page + ".html"; -} - -var pages = ["page_01", "page_02", "page_03"]; -var pageIndex = 0; + // define variables for blog pages + window.pages = []; + var page_exists = true; + var page_number = 1; + // gets all blog pages and add them to an array (pages[]) + while (page_exists) { + var page = "pages/page_" + page_number + ".html"; + $.get("pages/page_" + page_number + ".html").done(function() { + window.pages.append(page); + }).fail(function() { + page_exists = false; + }); + page_number ++; + } + // displays first blog page + window.current_blog_page = 0; + $("#presentation").load(window.pages[window.current_blog_page]); + $("#blog-insert").load("pages/blog.html"); +} \ No newline at end of file diff --git a/computer-science-blog/scripts/scripts.js~ b/computer-science-blog/scripts/scripts.js~ deleted file mode 100644 index 85494be..0000000 --- a/computer-science-blog/scripts/scripts.js~ +++ /dev/null @@ -1,31 +0,0 @@ -// set page title -window.page_title = "Computer Science Blog | Matthew Grove"; - -window.onload = function() { - // set the current date - var date = new Date(); - - // ternary operator: if the date < 10 then add 0 to the start of it, else display the date - var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate(); - - // set current date - var current_date = day + "-" + (date.getMonth() + 1) + "-" + date.getFullYear(); - - // display date - document.getElementById("current_date").innerHTML = current_date; -} - -function nextPage() { - displayPage(pages[0]); -} - -function previousPage() { - -} - -function displayPage(page) { - document.getElementById("iframe").src = "pages/" + page + ".html"; -} - -var pages = ["page_01", "page_02", "page_03"]; -var pageIndex = 0; \ No newline at end of file
The current date is: unknown