var itemsToShow = new Array(); //list of indexes to all dives to view var items = new Array(); var start; //index of first element viewed in itemsToShow var sizeofpage; //size of viewed page var numberofwords=0; //just for stats var olditemstoshow; //to reference the indexes to all dives if changed ////////////////////////////////// // // // View Model // // // ////////////////////////////////// /** *This Method view all items *View N pages each of sizeofpage size items. *starting from zero */ function showAllDives(){ for(var i=0 ; i < items.length ; i++){ itemsToShow.push(i); } olditemstoshow = itemsToShow; start=0; viewInPage(); } /** *This function view the 'itemstoshow' in pages. *It start from 'start' variable. *It showes N pages each of sizeofpage size. */ function viewInPage(){ var end = start + sizeofpage -1; if(end >= itemsToShow.length ) end = itemsToShow.length-1; updateView(start,end); } /** *addHTML this Method puts the HTML of items of given indexes *@param {array} indexes array of indexes to put in HTML */ function updateView(start,end){ var divelist = document.getElementById('diveslist'); divelist.innerHTML=""; for(var i=start;i<=end;i++){ divelist.innerHTML+=''+'
'; }; for(var i=0;i'+getlimited(trips[trip].dives[j])+''; } } function unexpand_trip(trip){ trips[trip].expanded = false; var d = document.getElementById("trip_dive_list_"+trip); d.innerHTML=''; } function getItems(){ var count = 0; for(var i in trips){ for(var j in trips[i].dives){ items[count++]=trips[i].dives[j]; } } }