Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function initialise() {
- navMenu(); // Everything related to the navigation menu - navmenu functionallity
- window.setInterval(function(){
- breakingNews() //Everything related to the title changing - ticket functionallity
- },3000);
- stories(); //Implementation of the "stories" functionallity
- story_lists();
- };
- function navMenu() {
- /*Hide all the list items because they are initially shown*/
- var navigate = document.getElementsByClassName("menuitemsholder");
- for (var i = 0 ; i < navigate.length; i++){
- navigate[i].style.display = "none" ;
- }
- /* Change the mouse into a cursor and display the list items when mouseovered*/
- var navigateTitles = document.getElementsByClassName("menutitle");
- for(var i = 0; i < navigateTitles.length; i++){
- /*Add the mouseover event*/
- navigateTitles[i].onmouseover = function(){
- /*Some styling for the cursor : */
- this.style.cursor="pointer";
- /*Set the list's visivility to block*/
- this.parentNode.childNodes[3].style.display = "block";
- };
- /*Add the mouseleave event */
- navigateTitles[i].parentNode.onmouseleave = function(){
- /*Hide the list after the cursor is moved outside the title or the list elements*/
- this.childNodes[3].style.display="none";
- }
- }
- }; /*end nav menu*/
- var i = 1; //My loop helper function
- function breakingNews(){
- //The list of stories that we have to get display in breaking news :
- var contents = document.getElementById("newstories-list");
- //The ul list that in inside the div that we called contentns :
- var list = contents.childNodes[1];
- //The div that contains the breaking new that appears at the moment:
- var toChange = document.getElementById("breaking");
- // Prevent i having undesirable values
- if (i%11===0) {
- i++;
- toChange.innerHTML = "<b>Breaking news:</b> " + list.childNodes[i%11].innerHTML; //change the title
- }
- else{
- toChange.innerHTML = "<b>Breaking news:</b> " + list.childNodes[i%11].innerHTML; //change the title
- }
- i+=2;
- }/* end breaking news ticker */
- function stories(){
- /*VARIABLE DECLARATION*/
- /*EVERYTHING RELATED TO THE LIST AT THE LEFT*/
- var storylists = document.getElementById("storylists"); //The entire div that contains topstories , mostread and newstories.
- var topstories = storylists.childNodes[3]; //The div as one object
- var topstoriesList = topstories.childNodes[1]; //The list as one object
- var topstoriesListElements = topstoriesList.getElementsByClassName("fakelink"); //The list that contains the story elements
- /*EVERYTHING RELATED TO THE CENTRE OF THE PAGE*/
- var header = document.getElementsByClassName("header")[0]; //the header that should change according to the story that we clicked on
- var storypanel = document.getElementById("storypanel"); //The entire storypanel that contains everything at the centre
- var startingStory = storypanel.childNodes[3];
- /*EVERYTHING RELATED ON GIVING THE CENTRE THE INITIAL LOOK THAT IS DESIRED*/
- var notstartingstories = storypanel.getElementsByClassName("story");
- /*END VARIABLE DECLARATION */
- //alert(storypanel.childNodes[5].innerHTML);
- /***************************SET ONLY ONE STORY TO APPEAR ON THE CENTER OF THE WEBPAGE INITIALLY ***************************************/
- header.innerHTML = startingStory.childNodes[1].innerHTML;
- startingStory.childNodes[1].innerHTML = "";
- for(var i = 1 ; i < notstartingstories.length; i++){
- notstartingstories[i].childNodes[1].innerHTML=""; //also delete all the titles from within the stories.
- notstartingstories[i].style.display = "none";
- }
- /************************************************************END************************************************************************/
- /*All the functionallity below*/
- for (var i=0; i < topstoriesListElements.length; i++) {
- topstoriesListElements[i].onclick = function(){
- header.innerHTML = this.innerHTML;
- for(var j = 0; i < notstartingstories.length; j++){
- if (this.id.indexOf(notstartingstories[j].id) > -1) { //Check if the id of the story matches the id that the title has.
- startingStory.style.display="none";
- notstartingstories[j].style.display="block";
- }
- else{
- notstartingstories[j].style.display="none";
- }
- }
- };
- }
- }
- function story_lists() {
- /*******************************VARIABLE DECLARATION*********************************/
- var listheaders = document.getElementById("listheaders");
- var listHeadersEventListeners = listheaders.getElementsByTagName("div");
- var storylists = document.getElementsByClassName("storylist");
- //alert(storylists[0].id);
- for(var i = 0; i < listHeadersEventListeners.length; i++){
- listHeadersEventListeners[i].onclick = function(){
- //alert(this.id);
- for(var j = 0; j < listHeadersEventListeners.length; j++){
- listHeadersEventListeners[j].className ="listheader-hidden";
- if(storylists[j].id.indexOf(this.id) > - 1){
- storylists[j].style.display = "block";
- }
- else{
- storylists[j].style.display = "none";
- }
- }
- this.className = "listheader";
- };
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement