/* * polozky slovniku, kodovani UTF-8 */ var dictionary = new Array(); dictionary[0] = ['fairway bunker', 'sand hazard towards hole or at its end, usually there to forbid shortening of the game']; dictionary[1] = ['G&CC', 'golf & country club']; dictionary[2] = ['GC', 'golf club']; dictionary[3] = ['LPGA', '„Ladies Professional Golf Association“']; dictionary[4] = ['side bunker', 'sand hazard in the hole neighbourhood, complicating a loop to the green']; dictionary[5] = ['soft green', 'a soft green subsoil']; dictionary[6] = ['stimp', 'unofficial unit of measure used for the speed on the green - it defines the distance the ball makes when turning on a "stimpmeter"']; dictionary[7] = ['stimpmeter', 'a tool to measure the speed on the green']; /* * vyberu nahodne polozku pro prvni zobrazeni */ var dict_index = Math.floor(Math.random() * dictionary.length); Event.onDOMReady(function() { dict_update() }); /* * zobrazeni hesla po nahrani stranky volanim Event.onDOMReady * a po prepnuti polozky volanim dict_prev() a dict_next() */ function dict_update() { if(dictionary.length == 0) return; $('rp-dict-keyword').innerHTML = dictionary[dict_index][0]; $('rp-dict-desc').innerHTML = dictionary[dict_index][1]; $('rp-dict-status').innerHTML = (dict_index + 1) + ' / ' + dictionary.length; } /* * prepnuti na nahodnou predchozi polozku (0 - 10) */ function dict_prev() { step = Math.ceil(Math.random() * 10); dict_index -= step; if(dict_index < 0) dict_index += dictionary.length; dict_update(); } /* * prepnuti na nahodnout nasledujici polozku (0 - 10) */ function dict_next() { step = Math.ceil(Math.random() * 10); dict_index += step; if(dict_index >= dictionary.length) dict_index -= dictionary.length; dict_update(); }