martes, 14 de julio de 2015

JAVASCRIPT: Mostrar la Última Visita de una Persona en tu Web

En el <HEAD> Y </HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin

var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function Who(info){
var VisitorName = GetCookie('VisitorName')
if (VisitorName == null) {
VisitorName = prompt("Quién eres tú ?");
SetCookie ('VisitorName', VisitorName, exp);
}
return VisitorName;
}
function When(info){
var rightNow = new Date()
var WWHTime = 0;
WWHTime = GetCookie('WWhenH')
WWHTime = WWHTime * 1
var lastHereFormatting = new Date(WWHTime);
var intLastVisit = (lastHereFormatting.getYear() * 10000)+(lastHereFormatting.getMonth() * 100) + lastHereFormatting.getDate()
var lastHereInDateFormat = "" + lastHereFormatting;
var dayOfWeek = lastHereInDateFormat.substring(0,3)
var dateMonth = lastHereInDateFormat.substring(4,11)
var timeOfDay = lastHereInDateFormat.substring(11,16)
var year = lastHereInDateFormat.substring(23,25)
var WWHText = dayOfWeek + ", " + dateMonth + " at " + timeOfDay
SetCookie ("WWhenH", rightNow.getTime(), exp)
return WWHText
}
function Count(info){
var WWHCount = GetCookie('WWHCount')
if (WWHCount == null) {
WWHCount = 0;
}
else{
WWHCount++;
}
SetCookie ('WWHCount', WWHCount, exp);
return WWHCount;
}
function set(){
VisitorName = prompt("Quién eres tú ?");
SetCookie ('VisitorName', VisitorName, exp);
SetCookie ('WWHCount', 0, exp);
SetCookie ('WWhenH', 0, exp);
}
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
// End -->
</SCRIPT>


ENTRE EL <BODY> Y </BODY>


<SCRIPT LANGUAGE="JavaScript">
document.write("Hola " + Who() + ". Tú estuviste aquí " + Count() + " veces. La última vez fué: " + When() +".");
</SCRIPT>

HTML: Buen Script si quieres poner un Color de Fondo Degradado a tu Página

Colocar dentro del <BODY >

Código:

style="filter:progid:DXImageTransform.Microsoft.Gradient( endColorstr='#C0CFE2', startColorstr='#FFFFFF', gradientType='0');"


Ejemplo:

<body style="filter:progid:DXImageTransform.Microsoft.Gradient( endColorstr='#C0CFE2', startColorstr='#FFFFFF', gradientType='0');" >

Calculadora en Consola C# (C Sharp)

namespace parcial
{
class examen
{
static void Main(string[] args)
{
Console.Title = "Calculadora";
Console.SetCursorPosition(55, 5);
Console.Write(" : Negro");
Console.SetCursorPosition(55, 6);
Console.Write(" : Blanco");
Console.SetCursorPosition(55, 7);
Console.Write(" : Amarillo");
Console.SetCursorPosition(55, 8);
Console.Write(" : Rojo");
Console.SetCursorPosition(55, 9);
Console.Write(" : Verde");
fondo();
Console.SetCursorPosition(55, 20);
Console.Write("/1/ : Muy pequeño");
Console.SetCursorPosition(55, 21);
Console.Write("/2/ : Pequeño");
Console.SetCursorPosition(55, 22);
Console.Write("/3/ : Normal");
Console.SetCursorPosition(55, 23);
Console.Write("/4/ : Mediano");
Console.SetCursorPosition(55, 24);
Console.Write("/5/ : Grande");
tamaño();
Console.SetCursorPosition(3, 2);
int a = ingreso();
Console.SetCursorPosition(3, 3);
int b = ingreso();
Console.SetCursorPosition(55, 2);
Console.Write("(+) : suma");
Console.SetCursorPosition(55, 4);
Console.Write("(-) : resta");
Console.SetCursorPosition(55, 6);
Console.Write("(*) : multiplicacion");
Console.SetCursorPosition(55, 8);
Console.Write("(/) : division");
Console.SetCursorPosition(3, 5);
Console.Write("===========================");
Console.SetCursorPosition(3, 11);
Console.Write("===========================");
Console.SetCursorPosition(3,6);
Console.Write("operacion");
operaciones(a, b);
Console.ReadKey();
}
static int ingreso()
{
Console.Write("Ingrese el numero--> ");
int n = Int16.Parse(Console.ReadLine());
return n;
}
static void operaciones(int x, int y)
{
Console.SetCursorPosition(25, 6);
string z = Console.ReadLine();
switch (z)
{
case "+":
Console.SetCursorPosition(25, 9);
Console.Write("{0}", x + y);
resultado();
break;
case "-":
Console.SetCursorPosition(25, 9);
Console.Write("{0}", x - y);
resultado();
break;
case "*":
Console.SetCursorPosition(25, 9);
Console.Write("{0}", x * y);
resultado();
break;
case "/":
Console.SetCursorPosition(25, 9);
Console.Write("{0:0.00}", x / y);
resultado();
break;
default:
Console.Write("Error");
break;
}
}
static void fondo()
{
Console.SetCursorPosition(3, 5);
Console.Write("¡CAMBIA EL COLOR DE FONDO!^^----> ");
char f = char.Parse(Console.ReadLine());
switch (f)
{
case 'N':
Console.BackgroundColor = ConsoleColor.Black;
Console.Clear();
break;
case 'B':
Console.BackgroundColor = ConsoleColor.White;
Console.Clear();
break;
case 'A':
Console.BackgroundColor = ConsoleColor.Yellow;
Console.Clear();
break;
case 'R':
Console.BackgroundColor = ConsoleColor.Red;
Console.Clear();
break;
case 'V':
Console.BackgroundColor = ConsoleColor.DarkGreen;
Console.Clear();
break;
default:
Console.Write("Error");
break;
}
}
static void tamaño()
{
Console.SetCursorPosition(3, 18);
Console.Write("¡VAMOS..AGRANDA O ACHICA!^^----> ");
string t = Console.ReadLine();
switch (t)
{
case "1":
Console.SetWindowSize(5,10);
Console.Clear();
break;
case "2":
Console.SetWindowSize(10,20);
Console.Clear();
break;
case "3":
Console.SetWindowSize(15,25);
Console.Clear();
break;
case "4":
Console.SetWindowSize(25,35);
Console.Clear();
break;
case "5":
Console.SetWindowSize(50,59);
Console.Clear();
break;
default:
Console.Write("Error");
break;
}
}
static void resultado()
{
Console.SetCursorPosition(3, 9);
Console.Write("RESULTADO");
int res = Int16.Parse(Console.ReadLine());
}
}
}