var presentation = ["Lexington and Concord<\/word>","The Sons of Liberty<\/word>","war had broken out<\/word>","In April of 1775, the first shots of the American Revolution were fired at Lexington and Concord<\/strong> in Massachusetts. The British had heard that the colonists were storing guns in Concord. General Gage ordered the arrest of Sam Adams and John Hancock in nearby Lexington. The Sons of Liberty<\/strong> learned of this and sent word with Paul Revere and others to warn them. When the British arrived at Lexington, the Patriots were ready. No one knows who fired first, but war had broken out<\/strong>.<\/phrase>","the Second Continental Congress<\/word>","colonies declared their independence<\/word>","the colonies were free and independent<\/word>","Just after that, on May 10, 1775, the Second Continental Congress<\/strong> met. While they still hoped that peace could be found, it did not seem likely. George Washington was asked to lead the Continental Army to fight against the British.\nThe colonies declared their independence<\/strong> from Britain on July 4, 1776. At this time, they said that the colonies were free from the British. The Declaration of Independence, written mainly by Thomas Jefferson, said several things. First, it gave the reasons that the United States should be free from British rule. It also listed basic rights that citizens should have, including the rights to \"life, liberty, and the pursuit of happiness.\" The declaration listed many complaints against Britain. Finally, the document said that the colonies were free and independent<\/strong>.<\/phrase>","British troops gathered in New York<\/word>","In July, 1776, British troops gathered in New York<\/strong>, and Washington took his army there to defend the city. The British army had the advantage of more troops and a navy. The Patriots fought bravely but were defeated eventually and driven north out of the city. Tired and defeated, they crossed the Delaware River into Pennsylvania.<\/phrase>","colonists were at a disadvantage<\/word>","the Loyalists<\/word>","the Patriots had a strong spirit<\/word>","The colonists were at a disadvantage<\/strong> in this war. They didn't have as big of an army as the British, and the colonial troops were not experienced. The long, cold winters were difficult for the troops. They didn't have enough food or clothing. There were also some colonists, the Loyalists<\/strong>, who didn't support the war. However, the Patriots had a strong spirit<\/strong>. This made them fight hard despite the conditions.<\/phrase>","a surprise attack<\/word>","On Christmas Day, 1776, Washington decided to launch a surprise attack<\/strong> against the British in Trenton, New Jersey. He hoped that they wouldn't expect an attack on the holiday. The weather was freezing and icy, and troops that were supposed to meet up with Washington's army didn't make it. Despite this, though, Washington's army was successful with their surprise attack and captured and killed many British, while sustaining few casualties of their own.<\/phrase>","victories helped the Patriots to attract more soldiers to their cause<\/word>","Washington and his troops stayed on for another week. The British gathered more troops and planned to attack Washington's troops on January 3, but they got away. Washington then went on to win another battle in Princeton, New Jersey. These victories helped the Patriots to attract more soldiers to their cause<\/strong>.<\/phrase>","capturing the city of Philadelphia<\/word>","In 1777, the British had a plan to send three armies to march to Albany, New York. By seizing the Hudson River valley, the British could gain a big advantage. One of armies, led by British General Howe, broke off though. He succeeded in capturing the city of Philadelphia<\/strong> but left the other two armies on their own.<\/phrase>","the Battles of Saratoga<\/word>","a turning point in the overall war<\/word>","In September and October, the Patriots and the British fought several battles, known collectively as the Battles of Saratoga<\/strong>. Benedict Arnold (who would later become known as a traitor to the Patriots after he switched his loyalty) was a hero and led several successful attacks against the British. The exhausted British retreated to a fort at Saratoga, which the Patriots surrounded and attacked. The British surrendered. This is seen as a turning point in the overall war<\/strong>.\nWashington took his army to Valley Forge that winter. They spent a long, cold winter there without enough supplies. Many soldiers died during the winter.<\/phrase>","the French had given secret aid to the Americans<\/word>","Early in the war, the French had given secret aid to the Americans<\/strong>. They wanted the British to be defeated. In 1778, after the Americans proved that they could win battles, the French agreed to fight with them. The French signed two treaties with America and recognized the country's independence. They provided the Americans with much-needed supplies and troops. They also convinced Spain to side with the Americans.<\/phrase>","In 1778, the British troops moved to the south, where there were fewer Patriots and fewer colonial troops. The British also promised southern slaves their freedom if they would fight with the British army.<\/phrase>","In December, 1778, the British captured Savannah, Georgia, which they used as base to take much of the south. The British army went on to lay siege to and ultimately capture Charleston, South Carolina, in one of the worst defeats for the Americans.<\/phrase>","the Battle of Yorktown<\/word>","The fighting continued, and by 1781, the war was focused on Virginia. British General Corwallis moved a large number of British troops to Yorktown, Virginia. Washington headed there with his troops and was met by French troops and 29 ships in the French navy. This set the state for the Battle of Yorktown<\/strong>.<\/phrase>","a great naval battle<\/word>","Cornwallis and the British surrendered<\/word>","There was a great naval battle<\/strong> between French and British warships. The French won, forcing the British ships to retreat to New York for reinforcements. The French ships were then able to cut Cornwallis and his troops off from a retreat. Aided by the French, Washington and his troops began a siege on Yorktown. In mid-October, 1781, Cornwallis and the British surrendered<\/strong>.\nThe Americans had won the war!<\/phrase>"]; var currentPosition = 0; var totalPositions = 0; var timePerWord = 1500; var timePerPhraseWord = 120 var readAheadPlayerTimer; var autoPlay = true; var setMinimized = false; var wordSpeedOptions = {'Slower':2000,'Moderate':1200,'Fast':800}; var phraseSpeedOptions = {'Slower':280,'Moderate':200,'Fast':80}; var defaultWordSpeedOption = 'Moderate'; var defaultPhraseSpeedOption = 'Moderate'; var logToLTI = false; $(window).load(function(){ totalPositions = presentation.length; if (totalPositions > 0){ $('body').prepend('
'); $('body').prepend('
'); $('#read_ahead_player').prepend('
'); initializeReadAheadControls(); initializeReadAheadSlider(); initializeReadAheadSpeedOptions(); currentReadAheadControls(); resumeReadAheadPlayback(); } }); $(document).keyup(function(e){ switch(e.which) { case 37: pauseReadAheadPresentation(); priorReadAheadPresentationItem(); break; case 39: pauseReadAheadPresentation(); nextReadAheadPresentationItem(); break; default: break; } }); function initializeReadAheadControls(){ var s = ''; s += ''; s += ''; s += ''; s += '
'; s += ''; s += ''; s += ''; s += ''; s += ''; s += ''; s += ''; s += ''; s += ''; s += '
'; $('#read_ahead_player').append(s); } function initializeReadAheadSlider(){ var s = ''; s += '
'; s += '
'; s += '
'; $('#read_ahead_controls').prepend(s); updateReadAheadSliderPosition(); } function initializeReadAheadSpeedOptions(){ var s = '
'; s += '
'; s += ' Word Speed
'; s += '
'; optionCount = 0; for (index in wordSpeedOptions) { optionCount++; } optionWidth = 100 / optionCount; for (index in wordSpeedOptions) { var option = wordSpeedOptions[index]; if (index == defaultWordSpeedOption) { s += ''; updateReadAheadWordSpeed(option); } else { s += ''; } } s += '
'; s += '
'; s += '
'; s += ' Phrase Speed
'; s += '
'; optionCount = 0; for (index in phraseSpeedOptions) { optionCount++; } optionWidth = 100 / optionCount; for (index in phraseSpeedOptions) { var option = phraseSpeedOptions[index]; if (index == defaultWordSpeedOption) { s += ''; updateReadAheadPhraseSpeed(option); } else { s += ''; } } s += '
'; s += '
'; s += '
'; $('#read_ahead_controls').append(s); } function updateReadAheadWordSpeed(microseconds,sender) { microseconds = microseconds != undefined && microseconds > 0 ? microseconds : 0; if (microseconds > 0) { timePerWord = microseconds; } if (sender!=undefined) { $('#slider_control_word_speed').find('a').removeClass('current_speed'); $(sender).addClass('current_speed'); } logReadAheadPlayerAction('updateReadAheadWordSpeed','Presentation',microseconds); } function updateReadAheadPhraseSpeed(microseconds,sender) { microseconds = microseconds != undefined && microseconds > 0 ? microseconds : 0; if (microseconds > 0 ) { timePerPhraseWord = microseconds; } if (sender!=undefined) { $('#slider_control_phrase_speed').find('a').removeClass('current_speed'); $(sender).addClass('current_speed'); } logReadAheadPlayerAction('updateReadAheadPhraseSpeed','Presentation',microseconds); } function updateReadAheadSliderPosition(){ var currentSliderBarWidth = 100 - (100 / totalPositions * (currentPosition + 1)); $('#readAheadSliderBar').css('width',currentSliderBarWidth+'%'); } function currentReadAheadControls(){ $('#read_ahead_player_pause_play').show(); if (currentPosition < totalPositions - 1) { $('#read_ahead_player_next_word').removeClass('disabled'); } else { $('#read_ahead_player_next_word').addClass('disabled'); } if (currentPosition > 0) { $('#read_ahead_player_previous_word').removeClass('disabled'); } else { $('#read_ahead_player_previous_word').addClass('disabled'); } } function restartReadAheadPresentation(){ currentPosition = 0; logReadAheadPlayerAction('restartReadAheadPresentation','Presentation',''); resumeReadAheadPlayback(); } function resumeReadAheadPlayback(){ $('.fa-repeat').removeClass('fa-repeat').addClass('fa-play'); $('#read_ahead_player_pause_play').each(function(){ $(this).find('.fa-play').removeClass('fa-play').addClass('fa-pause'); $(this).off('click'); $(this).attr('onclick','pauseReadAheadPresentation()'); }); logReadAheadPlayerAction('resumeReadAheadPlayback','Presentation',''); playReadAheadPresentation(); } function pauseReadAheadPresentation(){ $('#read_ahead_player_pause_play').each(function(){ $(this).find('.fa-pause').removeClass('fa-pause').addClass('fa-play'); $(this).off('click'); $(this).attr('onclick','resumeReadAheadPlayback()'); }); logReadAheadPlayerAction('pauseReadAheadPresentation','Presentation',''); read_ahead_pause(); } function endReadAheadPresentation(){ $('.fa-play').removeClass('fa-play').addClass('fa-repeat'); $('.fa-pause').removeClass('fa-pause').addClass('fa-repeat'); $('#read_ahead_player_pause_play').each(function(){ $(this).off('click'); $(this).attr('onclick','restartReadAheadPresentation()'); }); logReadAheadPlayerAction('endReadAheadPresentation','Presentation',''); logLTIEndPresentation(); } function playReadAheadPresentation(){ autoPlay=true; currentPosition--; logReadAheadPlayerAction('playReadAheadPresentation','Presentation',''); nextReadAheadPresentationItem(); } function startReadAheadStepper(timeDisplayWord){ clearInterval(readAheadPlayerTimer); readAheadPlayerTimer = setTimeout(function() { read_ahead_step(); },timeDisplayWord); } function stopReadAheadStepper(){ clearInterval(readAheadPlayerTimer); } function read_ahead_step(){ if (autoPlay) { nextReadAheadPresentationItem(); } } function read_ahead_pause(){ autoPlay=false; stopReadAheadStepper(); } function showReadAheadPresentationItem(index){ currentPosition = index; currentPresentationItem = presentation[currentPosition] != undefined ? presentation[currentPosition].trim() : ""; if (currentPresentationItem != "") { currentItemWordCount = presentation[currentPosition].replace("\n","").split(" ").length; if (currentPresentationItem.startsWith("")){ startReadAheadStepper(currentItemWordCount*timePerWord); $('#read_ahead_player_field').html('
'+currentPresentationItem+'
'); logReadAheadPlayerAction('showReadAheadPresentationItem','Word',currentPresentationItem); } else { startReadAheadStepper(currentItemWordCount*timePerPhraseWord); $('#read_ahead_player_field').html('
'+currentPresentationItem.replace("\n","
")+'
'); logReadAheadPlayerAction('showReadAheadPresentationItem','Phrase',''); } } else { if (currentPosition < totalPositions) { nextReadAheadPresentationItem(); } else { endReadAheadPresentation(); read_ahead_minimize(); } } currentReadAheadControls(); updateReadAheadSliderPosition(); saveReadAheadPosition(); } function priorReadAheadPresentationItem(){ stopReadAheadStepper(); logReadAheadPlayerAction('priorReadAheadPresentationItem','Controls',''); showReadAheadPresentationItem(currentPosition-1); } function nextReadAheadPresentationItem(){ stopReadAheadStepper(); logReadAheadPlayerAction('nextReadAheadPresentationItem','Controls',''); showReadAheadPresentationItem(currentPosition+1); } function read_ahead_playAgain(){ currentWordIndex = 0; logReadAheadPlayerAction('read_ahead_playAgain','Controls',''); playReadAheadPresentation(); } function read_ahead_minimize(){ setMinimized = true; logReadAheadPlayerAction('read_ahead_minimize','Controls',''); read_ahead_switch_min_max(); } function read_ahead_maximize(){ setMinimized = false; logReadAheadPlayerAction('read_ahead_maximize','Controls',''); read_ahead_switch_min_max(); } function read_ahead_switch_min_max(forceSwitch){ forceSwitch = forceSwitch != undefined ? forceSwitch : false; if (forceSwitch) { setMinimized = !setMinimized; } if (setMinimized) { $('#read_ahead_player_back').fadeOut(); $('#read_ahead_player').addClass('minimize'); $('.player-icons .fa-stack').removeClass('fa-lg').addClass('fa-sm'); $('.player-icons .fa-minus').removeClass('fa-minus').addClass('fa-expand'); logReadAheadPlayerAction('read_ahead_switch_min_max','Min',''); //$('#read_ahead_player_max_min').each(function(){ // $(this).off('click'); // $(this).attr('onclick','read_ahead_maximize()'); //}); } else { $('#read_ahead_player_back').fadeIn(); $('#read_ahead_player').removeClass('minimize'); $('.player-icons .fa-stack').removeClass('fa-sm').addClass('fa-lg'); $('.player-icons .fa-expand').removeClass('fa-expand').addClass('fa-minus'); logReadAheadPlayerAction('read_ahead_switch_min_max','Max',''); //$('#read_ahead_player_max_min').each(function(){ // $(this).off('click'); // $(this).attr('onclick','read_ahead_minimize()'); //}); } } function saveReadAheadPosition(){ $.ajax({ type:'POST', url:'/ajax/save_user_presentation_position.php', data: { 'id':1853, 'position': currentPosition } }) .done(function(results){ }) .fail(function( jqXHR, textStatus ) { alert( "Request failed: " + textStatus ); }); } function logLTIEndPresentation(action) { if (!logToLTI) { return; } $.ajax({ type:'POST', url:'/lti/presentationEnded.php', data: { 'documentId':1853, 'userId':0, } }) } function logReadAheadPlayerAction(action,area,details){ var d = new Date(); var t = d.getTime(); action = action != undefined ? action.trim() : 'UNKNOWN'; area = area != undefined ? area.trim() : ''; details = details != undefined ? details : ''; // If we are about to show a new word, increase the number of keywords // reinforced so we can log that for the Dashboard page. if (area == 'Word') { window.keywordCount++; } $.ajax({ type:'POST', url:'/logging/logPlayerAction.php', data: { 'documentId':1853, 'userId':0, 'playerAction':action, 'playerArea':area, 'details':details, 'timestamp': t } }) .done(function(results){ }) .fail(function( jqXHR, textStatus ) { alert( "Request failed: " + textStatus ); }); }