Plan de Ataque Bloc de Notas

  • Autor de hilo DeletedUser30284
  • Fecha de inicio

DeletedUser30284

Guest
Un problema a veces con los planes de ataque, es la cantidad de ordenes que pones en el bloc de notas, y cuando quieres sincronizar, cada vez que miras el bloc de notas, te pierdes entre tanta orden que hay, para saber cual es la que toca.
Este script les pone colores segun: rojo, naranja ya ha pasado la hora, verde falta poco, azul un poco mas.

Modificando estos valores var red = 360, orange = 60, green = 30, blue = 120; Se controlan los minutos para los distintos colores. Las ordenes pasadas las tacha. Y si ha pasado mas tiempo del rojo las oculta de pantalla.
Ademas modifica los enlaces para que los abra en pestaña nueva y no se salga del bloc esta pagina.
los enlcaes que pulsas los pone en violeta, para que sepas los que has pulsado.

b02d0bd6005dcbdab8e191c898b29e00.png



Como Hacerlo funcionar? Desde bloc de notas, ejecutando el script
Nombre de la entrada: Al gusto del consumidor
URL de la imagen: Al gusto del consumidor
URL de destino:
Código:
javascript:
function MemoClass() {
	var self = this;
	var tabs = $(".rename_link");
	var red = 360, orange = 60, green = 30, blue = 120;
	for ( i = 0; i < tabs.length; i++) {
		tabs[i] = $(tabs[i]).parent().parent()[0];
	}
	self.onclick = function(e) {
		$(e).parent().parent().css("color", "fuchsia");
		$(e).parent().parent().css("text-decoration", "line-through");
		return true;
	};
	function setLinks(tab) {
		function setLink(g, id) {
			var a = $(g).find("a")[0];
			a.setAttribute('target', '_blank');
			b = a.href.split("?");
			mv = b[1].split("&")[0];
			if (mv.indexOf("t=") >= 0)
				mv = mv + "&";
			else
				mv = "";
			a.href = b[0] + "?" + mv + "target=" + id + "&village=" + $(g).attr("data-id") + "&screen=place";
			a.setAttribute("onclick", "return s_info.onclick(this)");
			c = a.innerHTML;
			if (c.length > 20) {
				c = c.substring(0, 10) + "..." + c.substring(c.length - 7, c.length);
				a.innerHTML = c;
			}
		};
		var o = $(tab).find("[name=ordenes]"), f = 0, n = o.length, id = 0;
		for (; f < n; f++) {
			var g = $(o[f]).find('.village_anchor');
			if ($(o[f]).find("#salidadate").length == 0) {
				if (g.length > 0)
					id = $(g[0]).attr("data-id");
			} else {
				if (g.length > 1)
					id = $(g[1]).attr("data-id");
				if (g.length > 0)
					setLink(g[0], id);
			}
		}
	};
	function setOrdenes(tab) {
		function splitDate(a) {
			b = a.split("/");
			if (b.length != 3) {
				b = a.split("-");
				if (b.length != 3) {
					b = a.split(".");
				}
			}
			return b;
		};
		var td = $(tab).find(".show_row td:eq(0)"), f = 0, txt = "", boolDura = false;

		el = td[0].lastChild;
		var date = [], time = [], salida = new Date(), span;
		var re;
		if (el.previousSibling) {
			if (el.nodeName === '#text' && el.previousSibling.nodeName === 'BR') {
			} else {
				span = $("<br/>");
				$(el).before(span);
			}
			while (el) {
				if (el.nodeName === '#text') {
					if (el.data.trim() != "")
						txt = el.data;
					else
						txt = "";
				} else if (el.nodeName === 'BR') {
					txt = "";
					if (boolDura)
						$(span).prepend("<span style='width: 65px;display:inline-block;' id='dura' />");
					boolDura = false;
					span = $("<span id='ordenes' name='ordenes' />");
					$(el).before(span);

				} else {
					if (el.outerHTML.indexOf("village_anchor") == -1)
						txt = el.innerHTML;
					else
						txt = "";
				}
				if (txt != "") {
					res = txt.match(/(19|20)\d\d([- /.])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])/);
					if (res) {
						date = splitDate(res[0]);
					} else {
						res = txt.match(/(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d/);
						if (res) {
							date = splitDate(res[0]).reverse();
						}
					}
					res = txt.match(/(([0-1][0-9])|([2][0-3])):([0-5][0-9]):([0-5][0-9])/);
					if (res) {
						time = res[0].split(":");
					}
					if (date.length == 3 && time.length == 3) {
						salida = new Date(date[0], date[1] - 1, date[2], time[0], time[1], time[2]);
						$("<input id='salidadate' name='date' type='hidden' value='" + salida.getTime() + "' />").appendTo(span);
						boolDura = true;
						//$("<span  style='padding-left: 60px;' id='dura' />").appendTo(span);
						time = [];
						date = [];
					}
				}
				if (el.nodeName === 'BR' || el.id == "ordenes") {
					el = el.previousSibling;
				} else {
					re = el;
					el = el.previousSibling;
					if (span) {
						$(re).prependTo(span);
					}
				}
				if (el === null && boolDura) {
					$(span).prepend("<span  style='width: 65px;display:inline-block;' id='dura' />");
				}

			}
		}

	};
	function start() {
		function zeroPad(theString) {
			theInt = parseInt(theString, 10);
			return (theInt > 9 ? theInt : '0' + theInt);
		};
		function duracion(theInt) {
			var a = "";
			if (theInt < 0) {
				theInt = -theInt;
				a = "_";
			}
			if (parseInt(theInt / 3600, 10) > 0) {
				return a + parseInt(theInt / 3600, 10) + ':' + zeroPad(theInt % (3600) / 60) + ':' + zeroPad(theInt % 60);
			} else {
				return a + zeroPad(theInt % (3600) / 60) + ':' + zeroPad(theInt % 60);
			}
		};
		function myMs_Horas(ms) {
			var x = "";
			if (ms < 0) {
				x = "-";
			}
			ms = Math.abs(ms);
			var sec = Math.floor(ms / 1000);
			var hrs = Math.floor(sec / 3600);
			var min = Math.floor((sec % 3600) / 60);
			sec = sec % 60;
			if (sec < 10)
				sec = "0" + sec;
			if (min < 10)
				min = "0" + min;
			return x + hrs + ":" + min + ":" + sec;
		};
		for ( i = 0; i < tabs.length; i++) {

			var a = $(tabs[i]).find("[name=date]"), c = 0, f = 0, n = a.length, b = new Date().getTime(), first = true, min = 0;
			for (; f < n; f++) {

				c = (a[f].value - b) / 1000;

				if ($(a[f]).parent().css("text-decoration") == "none") {
					if (c < -red) {
						t = a[f].parentNode.nextSibling;
						if (t.nodeName === 'BR')
							$(t).remove();
						$(a[f]).parent().remove();
					} else if (c < -orange) {
						$(a[f]).parent().css("color", "red");
						$(a[f]).parent().css("text-decoration", "line-through");
						$(a[f]).parent().find("#dura").html(duracion(c));
					} else if (c < 0) {
						$(a[f]).parent().css("color", "orange");
						$(a[f]).parent().css("text-decoration", "line-through");
						$(a[f]).parent().find("#dura").html(duracion(c));
					} else if (c < green) {
						$(a[f]).parent().css("color", "green");
						$(a[f]).parent().find("#dura").html(duracion(c));
					} else if (c < blue) {
						$(a[f]).parent().css("color", "blue");
						$(a[f]).parent().find("#dura").html(duracion(c));
					} else {
						$(a[f]).parent().find("#dura").html(duracion(c));
					}
				} else
					$(a[f]).parent().find("#dura").html(duracion(c));

				if (c > 0) {
					if (first) {
						min = c;
						first = false;
					} else {
						if (c < min) {
							min = c;
						}
					}
				}
				$(tabs[i]).find("#spanMemoTime")[0].innerHTML = "<b>" + myMs_Horas(min * 1000) + " siguiente ataque.</b>";
			}
		}
	};
	function botonera() {
		var renamelink = $(".rename_link");
		for ( i = 0; i < renamelink.length; i++) {
			str = '<span id="spanMemoTime"></span>';
			$(".rename_link").eq(i).after(str);
		}
	};
	red = red * 60;
	orange = orange * 60;
	green = green * 60;
	blue = blue * 60;
	botonera();
	for ( i = 0; i < tabs.length; i++) {
		setOrdenes(tabs[i]);
		setLinks(tabs[i]);
	}
	start();
	setInterval(start, 5000);
}
var s_info;
s_info = new MemoClass();
 

DeletedUser3479

Guest
Consulta, el script me anduvo (sin color ni nada, pero anduvo) lo único es que no me dá los horarios (las cuentas regresivas en realidad) respetando el reloj del server, si no que pareciera que usara mi reloj de windows (o está puesto en la zona horaria Argentina).
 
Arriba