Change to .NET 3.5

This commit is contained in:
2015-05-29 23:26:32 +02:00
parent 453e637504
commit eef5e3dbbf
28 changed files with 2270 additions and 2217 deletions

View File

@@ -1,57 +1,57 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Scrummer.Code
{
public class Bundler
{
#region Declarations
private string _path = null;
private List<string> _files = null;
#endregion
#region Properties
private List<string> Files
{
get
{
if (_files != null) { return _files; }
DirectoryInfo dir = new DirectoryInfo(_path);
FileInfo[] files = dir.GetFiles();
_files = files.OrderBy(file => file.FullName).Select(file2 => file2.FullName).ToList();
return _files;
}
}
#endregion
#region Creator
public Bundler(string path)
{
_path = path;
}
#endregion
#region Public methods
public void WriteResponse(Stream outStream)
{
foreach (string fileName in Files)
{
string fileContent = File.ReadAllText(fileName);
byte[] byteArray = Encoding.UTF8.GetBytes(fileContent);
outStream.Write(byteArray, 0, byteArray.Length);
}
}
#endregion
}
}
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Scrummer.Code
{
public class Bundler
{
#region Declarations
private string _path = null;
private List<string> _files = null;
#endregion
#region Properties
private List<string> Files
{
get
{
if (_files != null) { return _files; }
DirectoryInfo dir = new DirectoryInfo(_path);
FileInfo[] files = dir.GetFiles();
_files = files.OrderBy(file => file.FullName).Select(file2 => file2.FullName).ToList();
return _files;
}
}
#endregion
#region Creator
public Bundler(string path)
{
_path = path;
}
#endregion
#region Public methods
public void WriteResponse(Stream outStream)
{
foreach (string fileName in Files)
{
string fileContent = File.ReadAllText(fileName);
byte[] byteArray = Encoding.UTF8.GetBytes(fileContent);
outStream.Write(byteArray, 0, byteArray.Length);
}
}
#endregion
}
}

View File

@@ -1,41 +1,41 @@
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Scrummer.Code.Controls
{
public class CLabel : Label
{
#region Declarations
private string _tagName = "span";
#endregion
#region Properties
public string Tag
{
get { return _tagName; }
set { _tagName = value; }
}
#endregion
#region Life cycle
public override void RenderBeginTag(HtmlTextWriter writer)
{
if (string.IsNullOrEmpty(_tagName) == false)
{
this.AddAttributesToRender(writer);
writer.RenderBeginTag(_tagName);
}
else
{
base.RenderBeginTag(writer);
}
}
#endregion
}
}
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Scrummer.Code.Controls
{
public class CLabel : Label
{
#region Declarations
private string _tagName = "span";
#endregion
#region Properties
public string Tag
{
get { return _tagName; }
set { _tagName = value; }
}
#endregion
#region Life cycle
public override void RenderBeginTag(HtmlTextWriter writer)
{
if (string.IsNullOrEmpty(_tagName) == false)
{
this.AddAttributesToRender(writer);
writer.RenderBeginTag(_tagName);
}
else
{
base.RenderBeginTag(writer);
}
}
#endregion
}
}

View File

@@ -1,131 +1,127 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
namespace Scrummer.Code.Controls
{
public class ChatControl : Control
{
#region Declarations
private string _serviceUrl = "ChatHandler";
private int _idBoard = 0;
private string _userName = string.Empty;
private Unit _width = new Unit(500, UnitType.Pixel);
private Unit _height = new Unit(300, UnitType.Pixel);
private Panel _divChatWindow = null;
#endregion
#region Properties
public string ServiceUrl
{
get { return _serviceUrl; }
set { _serviceUrl = value; }
}
public int IDBoard
{
get { return _idBoard; }
set { _idBoard = value; }
}
public string UserName
{
get { return _userName; }
set { _userName = value; }
}
public Unit Width
{
get { return _width; }
set
{
_width = value;
if (_divChatWindow != null)
{
_divChatWindow.Width = value;
}
}
}
public Unit Height
{
get { return _height; }
set
{
_height = value;
if (_divChatWindow != null)
{
_divChatWindow.Height = value;
}
}
}
#endregion
#region Control Life cycle
public ChatControl()
{
Init += ChatControl_Init;
}
void ChatControl_Init(object sender, EventArgs e)
{
InitializeControls();
}
#endregion
#region Private methods
private void InitializeControls()
{
_divChatWindow = new Panel { ID = "divChatWindow", CssClass = "divChatWindow" };
Controls.Add(_divChatWindow);
_divChatWindow.Width = _width;
_divChatWindow.Height = _height;
var divChat = new Panel { ID = "divChat", CssClass = "divChat" };
_divChatWindow.Controls.Add(divChat);
var divChatControls = new Panel { ID = "divChatControls", CssClass = "divChatControls" };
_divChatWindow.Controls.Add(divChatControls);
var hidUserName = new HiddenField { ID = "hidUserName", Value = _userName };
divChatControls.Controls.Add(hidUserName);
var hidIDMessage = new HiddenField { ID = "hidIDMessage", Value = "0" };
divChatControls.Controls.Add(hidIDMessage);
var hidLastUser = new HiddenField { ID = "hidLastUser", Value = "" };
divChatControls.Controls.Add(hidLastUser);
var txtText = new TextBox { ID = "txtText", CssClass = "chatTextBox" };
txtText.Attributes.Add("autocomplete", "off");
divChatControls.Controls.Add(txtText);
var btnSend = new Button { ID = "btnSend", Text = "Send", CssClass = "chatButton" };
divChatControls.Controls.Add(btnSend);
btnSend.Attributes.Add("onclick", String.Format("SendChat('{0}', '{1}', {2}, '{3}'); return false;",
_serviceUrl, txtText.ClientID, _idBoard, hidUserName.ClientID));
LiteralControl litScript = new LiteralControl();
litScript.Text = String.Format("<script>RunChat('{0}', '{1}', {2}, '{3}', '{4}', '{5}');</script>",
_serviceUrl, divChat.ClientID, _idBoard, hidIDMessage.ClientID, hidUserName.ClientID, hidLastUser.ClientID);
Controls.Add(litScript);
}
#endregion
}
}
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Scrummer.Code.Controls
{
public class ChatControl : Control
{
#region Declarations
private string _serviceUrl = "ChatHandler";
private int _idBoard = 0;
private string _userName = string.Empty;
private Unit _width = new Unit(500, UnitType.Pixel);
private Unit _height = new Unit(300, UnitType.Pixel);
private Panel _divChatWindow = null;
#endregion
#region Properties
public string ServiceUrl
{
get { return _serviceUrl; }
set { _serviceUrl = value; }
}
public int IDBoard
{
get { return _idBoard; }
set { _idBoard = value; }
}
public string UserName
{
get { return _userName; }
set { _userName = value; }
}
public Unit Width
{
get { return _width; }
set
{
_width = value;
if (_divChatWindow != null)
{
_divChatWindow.Width = value;
}
}
}
public Unit Height
{
get { return _height; }
set
{
_height = value;
if (_divChatWindow != null)
{
_divChatWindow.Height = value;
}
}
}
#endregion
#region Control Life cycle
public ChatControl()
{
Init += ChatControl_Init;
}
void ChatControl_Init(object sender, EventArgs e)
{
InitializeControls();
}
#endregion
#region Private methods
private void InitializeControls()
{
_divChatWindow = new Panel { ID = "divChatWindow", CssClass = "divChatWindow" };
Controls.Add(_divChatWindow);
_divChatWindow.Width = _width;
_divChatWindow.Height = _height;
var divChat = new Panel { ID = "divChat", CssClass = "divChat" };
_divChatWindow.Controls.Add(divChat);
var divChatControls = new Panel { ID = "divChatControls", CssClass = "divChatControls" };
_divChatWindow.Controls.Add(divChatControls);
var hidUserName = new HiddenField { ID = "hidUserName", Value = _userName };
divChatControls.Controls.Add(hidUserName);
var hidIDMessage = new HiddenField { ID = "hidIDMessage", Value = "0" };
divChatControls.Controls.Add(hidIDMessage);
var hidLastUser = new HiddenField { ID = "hidLastUser", Value = "" };
divChatControls.Controls.Add(hidLastUser);
var txtText = new TextBox { ID = "txtText", CssClass = "chatTextBox" };
txtText.Attributes.Add("autocomplete", "off");
divChatControls.Controls.Add(txtText);
var btnSend = new Button { ID = "btnSend", Text = "Send", CssClass = "chatButton" };
divChatControls.Controls.Add(btnSend);
btnSend.Attributes.Add("onclick", String.Format("SendChat('{0}', '{1}', {2}, '{3}'); return false;",
_serviceUrl, txtText.ClientID, _idBoard, hidUserName.ClientID));
LiteralControl litScript = new LiteralControl();
litScript.Text = String.Format("<script>RunChat('{0}', '{1}', '{2}', '{3}', '{4}', '{5}');</script>",
_serviceUrl, divChat.ClientID, _idBoard, hidIDMessage.ClientID, hidUserName.ClientID, hidLastUser.ClientID);
Controls.Add(litScript);
}
#endregion
}
}

View File

@@ -1,141 +1,142 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using Scrummer.Code.JSON;
namespace Scrummer.Code
{
public class Message
{
public int IDMessage { get; set; }
public string UserName { get; set; }
public string Text { get; set; }
};
public class MessageBoard
{
private List<Message> _messages = new List<Message>();
private int lastIDMessage = 0;
public List<Message> Messages_GetList(int idMessage)
{
List<Message> listMessages = new List<Message>();
for (int i = 0, n = _messages.Count; i < n; i++)
{
Message msg = _messages[i];
if (msg.IDMessage > idMessage)
{
listMessages.Insert(0, msg);
}
else
{
break;
}
}
return listMessages;
}
public void Message_Add(string userName, string text)
{
lastIDMessage++;
Message msg = new Message();
msg.IDMessage = lastIDMessage;
msg.UserName = userName;
msg.Text = text;
_messages.Insert(0, msg);
}
}
public class ChatHandler : IHttpHandler
{
private static object _monitor = new object();
private static Dictionary<int, MessageBoard> _chatBoards = new Dictionary<int, MessageBoard>();
public bool IsReusable
{
get { throw new NotImplementedException(); }
}
public void ProcessRequest(HttpContext context)
{
if (context.Request.RequestType == "GET")
{
ProcessRevicer(context);
}
if (context.Request.RequestType == "POST")
{
ProcessSender(context);
}
}
private void ProcessRevicer(HttpContext context)
{
int idBoard = Convert.ToInt32(context.Request.Params["idBoard"]);
int idMessage = Convert.ToInt32(context.Request.Params["idMessage"]);
MessageBoard messageBoard;
bool mustWait = true;
do
{
if (_chatBoards.ContainsKey(idBoard))
{
messageBoard = _chatBoards[idBoard];
List<Message> listMessages = messageBoard.Messages_GetList(idMessage);
if (listMessages.Count > 0)
{
mustWait = false;
ResponseObject(context, listMessages);
}
}
if (mustWait)
{
lock (_monitor) { Monitor.Wait(_monitor, 10000); }
}
} while (mustWait);
}
private void ProcessSender(HttpContext context)
{
string strIDBoard = GetRequestParm(context, "idBoard");
int idBoard = Convert.ToInt32(string.IsNullOrEmpty(strIDBoard) ? "0" : strIDBoard);
string userName = Convert.ToString(GetRequestParm(context, "userName"));
string text = Convert.ToString(GetRequestParm(context, "text"));
lock (_chatBoards)
{
MessageBoard messageBoard;
if (_chatBoards.ContainsKey(idBoard))
{
messageBoard = _chatBoards[idBoard];
}
else
{
messageBoard = new MessageBoard();
_chatBoards[idBoard] = messageBoard;
}
messageBoard.Message_Add(userName, text);
lock (_monitor) { Monitor.PulseAll(_monitor); }
}
}
private string GetRequestParm(HttpContext context, string parm)
{
foreach (string key in context.Request.Params.AllKeys)
{
if (string.IsNullOrEmpty(key) == false && key.EndsWith(parm))
{
return context.Request.Params[key];
}
}
return string.Empty;
}
private void ResponseObject(HttpContext context, object obj)
{
var jsonWritter = new JSONWriter(true);
context.Response.ContentType = "text/json";
context.Response.Write(jsonWritter.Write(obj));
}
}
}
using System;
using System.Collections.Generic;
using System.Threading;
using System.Web;
using Scrummer.Code.JSON;
namespace Scrummer.Code
{
public class Message
{
public int IDMessage { get; set; }
public string UserName { get; set; }
public string Text { get; set; }
public DateTime Date { get; set; }
};
public class MessageBoard
{
private List<Message> _messages = new List<Message>();
private int lastIDMessage = 0;
public List<Message> Messages_GetList(int idMessage)
{
List<Message> listMessages = new List<Message>();
for (int i = 0, n = _messages.Count; i < n; i++)
{
Message msg = _messages[i];
if (msg.IDMessage > idMessage)
{
listMessages.Insert(0, msg);
}
else
{
break;
}
}
return listMessages;
}
public void Message_Add(string userName, string text)
{
lastIDMessage++;
Message msg = new Message();
msg.IDMessage = lastIDMessage;
msg.UserName = userName;
msg.Text = text;
msg.Date = DateTime.UtcNow;
_messages.Insert(0, msg);
}
}
public class ChatHandler : IHttpHandler
{
private static object _monitor = new object();
private static Dictionary<int, MessageBoard> _chatBoards = new Dictionary<int, MessageBoard>();
public bool IsReusable
{
get { throw new NotImplementedException(); }
}
public void ProcessRequest(HttpContext context)
{
if (context.Request.RequestType == "GET")
{
ProcessRevicer(context);
}
if (context.Request.RequestType == "POST")
{
ProcessSender(context);
}
}
private void ProcessRevicer(HttpContext context)
{
int idBoard = Convert.ToInt32(context.Request.Params["idBoard"]);
int idMessage = Convert.ToInt32(context.Request.Params["idMessage"]);
MessageBoard messageBoard;
bool mustWait = true;
do
{
if (_chatBoards.ContainsKey(idBoard))
{
messageBoard = _chatBoards[idBoard];
List<Message> listMessages = messageBoard.Messages_GetList(idMessage);
if (listMessages.Count > 0)
{
mustWait = false;
ResponseObject(context, listMessages);
}
}
if (mustWait)
{
lock (_monitor) { Monitor.Wait(_monitor, 10000); }
}
} while (mustWait);
}
private void ProcessSender(HttpContext context)
{
string strIDBoard = GetRequestParm(context, "idBoard");
int idBoard = Convert.ToInt32(string.IsNullOrEmpty(strIDBoard) ? "0" : strIDBoard);
string userName = Convert.ToString(GetRequestParm(context, "userName"));
string text = Convert.ToString(GetRequestParm(context, "text"));
lock (_chatBoards)
{
MessageBoard messageBoard;
if (_chatBoards.ContainsKey(idBoard))
{
messageBoard = _chatBoards[idBoard];
}
else
{
messageBoard = new MessageBoard();
_chatBoards[idBoard] = messageBoard;
}
messageBoard.Message_Add(userName, text);
lock (_monitor) { Monitor.PulseAll(_monitor); }
}
}
private string GetRequestParm(HttpContext context, string parm)
{
foreach (string key in context.Request.Params.AllKeys)
{
if (string.IsNullOrEmpty(key) == false && key.EndsWith(parm))
{
return context.Request.Params[key];
}
}
return string.Empty;
}
private void ResponseObject(HttpContext context, object obj)
{
var jsonWritter = new JSONWriter(true);
context.Response.ContentType = "text/json";
context.Response.Write(jsonWritter.Write(obj));
}
}
}

View File

@@ -1,64 +1,64 @@
using System;
using System.Text;
using System.Web;
using Scrummer.Code.Pages;
namespace Scrummer.Code
{
public static class GlobalErrorHandler
{
#region Private methods
private static void ShowInternalError(HttpContext context, Exception ex)
{
context.Response.StatusCode = 500;
context.Response.Clear();
StringBuilder sbOutput = new StringBuilder();
sbOutput.Append("<h2>Internal error</h2>");
Exception exAux = ex;
if (exAux is HttpUnhandledException && exAux.InnerException != null) { exAux = exAux.InnerException; }
while (exAux != null)
{
sbOutput.AppendFormat("<p><b>Message:</b> {0}</p>", exAux.Message);
sbOutput.AppendFormat("<p><b>StackTrace:</b></p> <pre><code>{0}</code></pre>", exAux.StackTrace);
exAux = exAux.InnerException;
}
// Fill response to 512 bytes to avoid browser "beauty" response of errors.
long fillResponse = 512 - sbOutput.Length;
if (fillResponse > 0)
{
sbOutput.Append("<!--");
for (int i = 0; i < fillResponse; i++)
{
sbOutput.Append("A");
}
sbOutput.Append("-->");
}
context.Response.Write(sbOutput.ToString());
}
#endregion
#region Public methods
public static void HandleError(HttpContext context, Exception ex)
{
try
{
IHttpHandler frmError = new FrmError(ex);
context.Response.Clear();
context.Handler = frmError;
frmError.ProcessRequest(context);
}
catch
{
ShowInternalError(context, ex);
}
}
#endregion
}
}
using System;
using System.Text;
using System.Web;
using Scrummer.Code.Pages;
namespace Scrummer.Code
{
public static class GlobalErrorHandler
{
#region Private methods
private static void ShowInternalError(HttpContext context, Exception ex)
{
context.Response.StatusCode = 500;
context.Response.Clear();
StringBuilder sbOutput = new StringBuilder();
sbOutput.Append("<h2>Internal error</h2>");
Exception exAux = ex;
if (exAux is HttpUnhandledException && exAux.InnerException != null) { exAux = exAux.InnerException; }
while (exAux != null)
{
sbOutput.AppendFormat("<p><b>Message:</b> {0}</p>", exAux.Message);
sbOutput.AppendFormat("<p><b>StackTrace:</b></p> <pre><code>{0}</code></pre>", exAux.StackTrace);
exAux = exAux.InnerException;
}
// Fill response to 512 bytes to avoid browser "beauty" response of errors.
long fillResponse = 512 - sbOutput.Length;
if (fillResponse > 0)
{
sbOutput.Append("<!--");
for (int i = 0; i < fillResponse; i++)
{
sbOutput.Append("A");
}
sbOutput.Append("-->");
}
context.Response.Write(sbOutput.ToString());
}
#endregion
#region Public methods
public static void HandleError(HttpContext context, Exception ex)
{
try
{
IHttpHandler frmError = new FrmError(ex);
context.Response.Clear();
context.Handler = frmError;
frmError.ProcessRequest(context);
}
catch
{
ShowInternalError(context, ex);
}
}
#endregion
}
}

View File

@@ -1,411 +1,411 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Scrummer.Code.JSON
{
public class JSONParser
{
#region Declarations
private ParserContext ctx;
private bool tainted = false;
#endregion
#region Private methods
private int ParseHexShort()
{
int value = 0;
for (int i = 0; i < 4; i++)
{
char c = ctx.Next();
if (Char.IsDigit(c))
{
value = (value << 4) | (c - '0');
}
else
{
c = Char.ToLower(c);
if (c >= 'a' && c <= 'f')
{
value = (value << 4) | ((c - 'a') + 10);
}
}
}
return value;
}
private String ParseQuotedString()
{
StringBuilder scratch = new StringBuilder();
char c = ctx.SkipWhite();
if (c == '"')
{
c = ctx.Next();
}
do
{
if (c == '\\')
{
c = ctx.Next();
if (c == '"')
{
scratch.Append('"');
}
else if (c == '\\')
{
scratch.Append('\\');
}
else if (c == '/')
{
scratch.Append('/');
}
else if (c == 'b')
{
scratch.Append('\b');
}
else if (c == 'f')
{
scratch.Append('\f');
}
else if (c == 'n')
{
scratch.Append('\n');
}
else if (c == 'r')
{
scratch.Append('\r');
}
else if (c == 't')
{
scratch.Append('\t');
}
else if (c == 'u')
{
scratch.Append((char)ParseHexShort());
}
c = ctx.Next();
}
else if (c == '"')
{
break;
}
else
{
scratch.Append(c);
c = ctx.Next();
}
} while (!ctx.AtEnd());
if (c == '"')
{
ctx.Next();
}
return scratch.ToString();
}
private String ParseString()
{
char c = ctx.SkipWhite();
if (c == '"')
{
return ParseQuotedString();
}
StringBuilder scratch = new StringBuilder();
while (!ctx.AtEnd()
&& (Char.IsLetter(c) || Char.IsDigit(c) || c == '_'))
{
scratch.Append(c);
c = ctx.Next();
}
return scratch.ToString();
}
private Object ParseNumber()
{
StringBuilder scratch = new StringBuilder();
bool isFloat = false;
int numberLenght = 0;
char c;
c = ctx.SkipWhite();
// Sign
if (c == '-')
{
scratch.Append('-');
c = ctx.Next();
}
// Integer part
while (Char.IsDigit(c))
{
scratch.Append(c);
c = ctx.Next();
numberLenght++;
}
// Decimal part
if (c == '.')
{
isFloat = true;
scratch.Append('.');
c = ctx.Next();
while (Char.IsDigit(c))
{
scratch.Append(c);
c = ctx.Next();
numberLenght++;
}
}
if (numberLenght == 0)
{
tainted = true;
return null;
}
// Exponential part
if (c == 'e' || c == 'E')
{
isFloat = true;
scratch.Append('E');
c = ctx.Next();
if (c == '+' || c == '-')
{
scratch.Append(c);
}
while (Char.IsDigit(c))
{
scratch.Append(c);
c = ctx.Next();
numberLenght++;
}
}
// Build number object from the parsed string
String s = scratch.ToString();
return isFloat ? (numberLenght < 17) ? (Object)Double.Parse(s)
: Decimal.Parse(s) : (numberLenght < 19) ? (Object)System.Int32.Parse(s)
: (Object)System.Int32.Parse(s);
}
private List<object> ParseArray()
{
char c = ctx.SkipWhite();
List<object> array = new List<object>();
if (c == '[')
{
ctx.Next();
}
do
{
c = ctx.SkipWhite();
if (c == ']')
{
ctx.Next();
break;
}
else if (c == ',')
{
ctx.Next();
}
else
{
array.Add(ParseValue());
}
} while (!ctx.AtEnd());
return array;
}
private Dictionary<string, object> ParseObject()
{
char c = ctx.SkipWhite();
Dictionary<string, object> obj = new Dictionary<string, object>();
if (c == '{')
{
ctx.Next();
c = ctx.SkipWhite();
}
String attributeName;
Object attributeValue;
do
{
attributeName = ParseString();
c = ctx.SkipWhite();
if (c == ':')
{
ctx.Next();
attributeValue = ParseValue();
if (attributeName.Length > 0)
{
obj.Add(attributeName, attributeValue);
}
}
else if (c == ',')
{
ctx.Next();
c = ctx.SkipWhite();
}
else if (c == '}')
{
ctx.Next();
break;
}
else
{
// Unexpected character
tainted = true;
break;
}
} while (!ctx.AtEnd());
if (obj.Count == 0)
{
return null;
}
return obj;
}
private Object ParseValue()
{
Object token = null;
char c = ctx.SkipWhite();
switch (c)
{
case '"':
token = ParseQuotedString();
break;
case '{':
token = ParseObject();
break;
case '[':
token = ParseArray();
break;
default:
if (Char.IsDigit(c) || c == '-')
{
token = ParseNumber();
}
else
{
String aux = ParseString();
if (aux.CompareTo("true") == 0)
{
token = true;
}
else if (aux.CompareTo("false") == 0)
{
token = false;
}
else if (aux.CompareTo("null") == 0)
{
token = null;
}
else
{
// Unexpected string
if (aux.Length == 0)
{
ctx.Next();
}
tainted = true;
token = null;
}
}
break;
}
return token;
}
private String CleanIdentifier(String input)
{
int i;
char c;
i = input.Length - 1;
if (i < 0)
{
return input;
}
c = input[i];
while (Char.IsLetter(c) || Char.IsDigit(c) || c == '_')
{
i--;
if (i < 0)
{
break;
}
c = input[i];
}
return input.Substring(i + 1);
}
#endregion
#region Public methods
public Object Parse(String text)
{
// Get the first object
ctx = new ParserContext(text);
tainted = false;
ctx.Mark();
Object obj = ParseValue();
if (ctx.AtEnd())
{
return obj;
}
// "But wait, there is more!"
int idx = 0;
String name = "";
String strInvalidPrev = "";
Dictionary<string, object> superObject = new Dictionary<string, object>();
do
{
// Add the object to the superObject
if (!tainted && name.Length > 0 && obj != null)
{
if (name.Length == 0)
{
name = String.Format("{0:D2}", idx);
}
superObject.Add(name, obj);
idx++;
name = "";
}
else
{
String strInvalid = ctx.GetMarked();
strInvalid = strInvalid.Trim();
if (strInvalidPrev.Length > 0
&& "=".CompareTo(strInvalid) == 0)
{
name = CleanIdentifier(strInvalidPrev);
}
else
{
name = "";
}
strInvalidPrev = strInvalid;
}
// Check end
if (ctx.AtEnd())
{
break;
}
// Get next object
tainted = false;
ctx.Mark();
obj = ParseValue();
} while (true);
return superObject;
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Scrummer.Code.JSON
{
public class JSONParser
{
#region Declarations
private ParserContext ctx;
private bool tainted = false;
#endregion
#region Private methods
private int ParseHexShort()
{
int value = 0;
for (int i = 0; i < 4; i++)
{
char c = ctx.Next();
if (Char.IsDigit(c))
{
value = (value << 4) | (c - '0');
}
else
{
c = Char.ToLower(c);
if (c >= 'a' && c <= 'f')
{
value = (value << 4) | ((c - 'a') + 10);
}
}
}
return value;
}
private String ParseQuotedString()
{
StringBuilder scratch = new StringBuilder();
char c = ctx.SkipWhite();
if (c == '"')
{
c = ctx.Next();
}
do
{
if (c == '\\')
{
c = ctx.Next();
if (c == '"')
{
scratch.Append('"');
}
else if (c == '\\')
{
scratch.Append('\\');
}
else if (c == '/')
{
scratch.Append('/');
}
else if (c == 'b')
{
scratch.Append('\b');
}
else if (c == 'f')
{
scratch.Append('\f');
}
else if (c == 'n')
{
scratch.Append('\n');
}
else if (c == 'r')
{
scratch.Append('\r');
}
else if (c == 't')
{
scratch.Append('\t');
}
else if (c == 'u')
{
scratch.Append((char)ParseHexShort());
}
c = ctx.Next();
}
else if (c == '"')
{
break;
}
else
{
scratch.Append(c);
c = ctx.Next();
}
} while (!ctx.AtEnd());
if (c == '"')
{
ctx.Next();
}
return scratch.ToString();
}
private String ParseString()
{
char c = ctx.SkipWhite();
if (c == '"')
{
return ParseQuotedString();
}
StringBuilder scratch = new StringBuilder();
while (!ctx.AtEnd()
&& (Char.IsLetter(c) || Char.IsDigit(c) || c == '_'))
{
scratch.Append(c);
c = ctx.Next();
}
return scratch.ToString();
}
private Object ParseNumber()
{
StringBuilder scratch = new StringBuilder();
bool isFloat = false;
int numberLenght = 0;
char c;
c = ctx.SkipWhite();
// Sign
if (c == '-')
{
scratch.Append('-');
c = ctx.Next();
}
// Integer part
while (Char.IsDigit(c))
{
scratch.Append(c);
c = ctx.Next();
numberLenght++;
}
// Decimal part
if (c == '.')
{
isFloat = true;
scratch.Append('.');
c = ctx.Next();
while (Char.IsDigit(c))
{
scratch.Append(c);
c = ctx.Next();
numberLenght++;
}
}
if (numberLenght == 0)
{
tainted = true;
return null;
}
// Exponential part
if (c == 'e' || c == 'E')
{
isFloat = true;
scratch.Append('E');
c = ctx.Next();
if (c == '+' || c == '-')
{
scratch.Append(c);
}
while (Char.IsDigit(c))
{
scratch.Append(c);
c = ctx.Next();
numberLenght++;
}
}
// Build number object from the parsed string
String s = scratch.ToString();
return isFloat ? (numberLenght < 17) ? (Object)Double.Parse(s)
: Decimal.Parse(s) : (numberLenght < 19) ? (Object)System.Int32.Parse(s)
: (Object)System.Int32.Parse(s);
}
private List<object> ParseArray()
{
char c = ctx.SkipWhite();
List<object> array = new List<object>();
if (c == '[')
{
ctx.Next();
}
do
{
c = ctx.SkipWhite();
if (c == ']')
{
ctx.Next();
break;
}
else if (c == ',')
{
ctx.Next();
}
else
{
array.Add(ParseValue());
}
} while (!ctx.AtEnd());
return array;
}
private Dictionary<string, object> ParseObject()
{
char c = ctx.SkipWhite();
Dictionary<string, object> obj = new Dictionary<string, object>();
if (c == '{')
{
ctx.Next();
c = ctx.SkipWhite();
}
String attributeName;
Object attributeValue;
do
{
attributeName = ParseString();
c = ctx.SkipWhite();
if (c == ':')
{
ctx.Next();
attributeValue = ParseValue();
if (attributeName.Length > 0)
{
obj.Add(attributeName, attributeValue);
}
}
else if (c == ',')
{
ctx.Next();
c = ctx.SkipWhite();
}
else if (c == '}')
{
ctx.Next();
break;
}
else
{
// Unexpected character
tainted = true;
break;
}
} while (!ctx.AtEnd());
if (obj.Count == 0)
{
return null;
}
return obj;
}
private Object ParseValue()
{
Object token = null;
char c = ctx.SkipWhite();
switch (c)
{
case '"':
token = ParseQuotedString();
break;
case '{':
token = ParseObject();
break;
case '[':
token = ParseArray();
break;
default:
if (Char.IsDigit(c) || c == '-')
{
token = ParseNumber();
}
else
{
String aux = ParseString();
if (aux.CompareTo("true") == 0)
{
token = true;
}
else if (aux.CompareTo("false") == 0)
{
token = false;
}
else if (aux.CompareTo("null") == 0)
{
token = null;
}
else
{
// Unexpected string
if (aux.Length == 0)
{
ctx.Next();
}
tainted = true;
token = null;
}
}
break;
}
return token;
}
private String CleanIdentifier(String input)
{
int i;
char c;
i = input.Length - 1;
if (i < 0)
{
return input;
}
c = input[i];
while (Char.IsLetter(c) || Char.IsDigit(c) || c == '_')
{
i--;
if (i < 0)
{
break;
}
c = input[i];
}
return input.Substring(i + 1);
}
#endregion
#region Public methods
public Object Parse(String text)
{
// Get the first object
ctx = new ParserContext(text);
tainted = false;
ctx.Mark();
Object obj = ParseValue();
if (ctx.AtEnd())
{
return obj;
}
// "But wait, there is more!"
int idx = 0;
String name = "";
String strInvalidPrev = "";
Dictionary<string, object> superObject = new Dictionary<string, object>();
do
{
// Add the object to the superObject
if (!tainted && name.Length > 0 && obj != null)
{
if (name.Length == 0)
{
name = String.Format("{0:D2}", idx);
}
superObject.Add(name, obj);
idx++;
name = "";
}
else
{
String strInvalid = ctx.GetMarked();
strInvalid = strInvalid.Trim();
if (strInvalidPrev.Length > 0
&& "=".CompareTo(strInvalid) == 0)
{
name = CleanIdentifier(strInvalidPrev);
}
else
{
name = "";
}
strInvalidPrev = strInvalid;
}
// Check end
if (ctx.AtEnd())
{
break;
}
// Get next object
tainted = false;
ctx.Mark();
obj = ParseValue();
} while (true);
return superObject;
}
#endregion
}
}

View File

@@ -1,328 +1,328 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
namespace Scrummer.Code.JSON
{
public class JSONWriter
{
#region Declarations
private bool indent = false;
private bool useTabForIndent = false;
private int indentChars = 4;
private int indentThresold = 3;
#endregion
#region Creator
public JSONWriter() { }
public JSONWriter(int indentChars)
{
this.indent = true;
this.indentChars = indentChars;
this.useTabForIndent = false;
}
public JSONWriter(bool useTabForIndent)
{
this.indent = true;
this.useTabForIndent = useTabForIndent;
}
#endregion
#region Private methods
private bool IsValue(Object obj)
{
if (obj == null)
{
return true;
}
if ((obj is float) || (obj is double) ||
(obj is System.Int16) || (obj is System.Int32) || (obj is System.Int64)
|| (obj is String) || (obj is Boolean))
{
return true;
}
return false;
}
private void WriteIndent(StringBuilder sbOutput, int level)
{
if (!indent)
{
return;
}
sbOutput.Append('\n');
if (useTabForIndent)
{
for (int i = 0; i < level; i++) { sbOutput.Append('\t'); }
}
else
{
int n = level * indentChars;
for (int i = 0; i < n; i++) { sbOutput.Append(' '); }
}
}
private void WriteString(StringBuilder sbOutput, String str)
{
sbOutput.Append('"');
char c;
int n = str.Length;
for (int i = 0; i < n; i++)
{
c = str[i];
if (c == '"') { sbOutput.Append("\\\""); }
else if (c == '\\') { sbOutput.Append("\\\\"); }
else if (c == '/') { sbOutput.Append("\\/"); }
else if (c == '\b') { sbOutput.Append("\\b"); }
else if (c == '\f') { sbOutput.Append("\\f"); }
else if (c == '\n') { sbOutput.Append("\\n"); }
else if (c == '\r') { sbOutput.Append("\\r"); }
else if (c == '\t') { sbOutput.Append("\\t"); }
else { sbOutput.Append(c); }
// FIXME: Unicode characters
}
sbOutput.Append('"');
}
private void WriteValue(StringBuilder sbOutput, Object obj, int level, bool useReflection)
{
if (obj == null)
{
// NULL
sbOutput.Append("null");
}
else if ((obj is float) || (obj is double) ||
(obj is System.Int16) || (obj is System.Int32) || (obj is System.Int64))
{
// Numbers
sbOutput.Append(obj.ToString());
}
else if (obj is String)
{
// Strings
WriteString(sbOutput, (String)obj);
}
else if (obj is Boolean)
{
// Booleans
sbOutput.Append(((Boolean)obj) ? "true" : "false");
}
else if (obj is IDictionary)
{
// Objects
WriteObject(sbOutput, obj, level);
}
else if (obj is IEnumerable)
{
// Array/List
WriteList(sbOutput, obj, level);
}
else
{
if (useReflection)
{
// Reflected object
WriteReflectedObject(sbOutput, obj, level);
}
else
{
WriteString(sbOutput, Convert.ToString(obj));
}
}
}
private void WriteList(StringBuilder sbOutput, Object obj, int level)
{
IEnumerable list = (IEnumerable)obj;
int n = 0;
// Check if it is a leaf object
bool isLeaf = true;
foreach (object childObj in list)
{
if (!IsValue(childObj))
{
isLeaf = false;
}
n++;
}
// Empty
if (n == 0)
{
sbOutput.Append("[ ]");
return;
}
// Write array
bool first = true;
sbOutput.Append("[ ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
foreach (object childObj in list)
{
if (!first)
{
sbOutput.Append(", ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
}
first = false;
WriteValue(sbOutput, childObj, level + 1, true);
}
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level);
}
sbOutput.Append(" ]");
}
private void WriteObject(StringBuilder sbOutput, Object obj, int level)
{
IDictionary map = (IDictionary)obj;
int n = map.Count;
// Empty
if (map.Count == 0)
{
sbOutput.Append("{ }");
return;
}
// Check if it is a leaf object
bool isLeaf = true;
foreach (object value in map.Values)
{
if (!IsValue(value))
{
isLeaf = false;
break;
}
}
// Write object
bool first = true;
sbOutput.Append("{ ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
foreach (object key in map.Keys)
{
object value = map[key];
if (!first)
{
sbOutput.Append(", ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
}
first = false;
WriteString(sbOutput, Convert.ToString(key));
sbOutput.Append(": ");
WriteValue(sbOutput, value, level + 1, true);
}
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level);
}
sbOutput.Append(" }");
}
private void WriteReflectedObject(StringBuilder sbOutput, Object obj, int level)
{
Type type = obj.GetType();
PropertyInfo[] rawProperties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
List<PropertyInfo> properties = new List<PropertyInfo>();
foreach (PropertyInfo property in rawProperties)
{
if (property.CanRead)
{
properties.Add(property);
}
}
int n = properties.Count;
// Empty
if (n == 0)
{
sbOutput.Append("{ }");
return;
}
// Check if it is a leaf object
bool isLeaf = true;
foreach (PropertyInfo property in properties)
{
object value = property.GetValue(obj, null);
if (!IsValue(value))
{
isLeaf = false;
break;
}
}
// Write object
bool first = true;
sbOutput.Append("{ ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
foreach (PropertyInfo property in properties)
{
object value=null;
MethodInfo getMethod = property.GetMethod;
ParameterInfo[] parameters =getMethod.GetParameters();
if (parameters.Length == 0)
{
value = property.GetValue(obj, null);
}
if (!first)
{
sbOutput.Append(", ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
}
first = false;
WriteString(sbOutput, property.Name);
sbOutput.Append(": ");
WriteValue(sbOutput, value, level + 1, false);
}
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level);
}
sbOutput.Append(" }");
}
#endregion
#region Public methods
public String Write(Object obj)
{
StringBuilder sbOutput = new StringBuilder();
WriteValue(sbOutput, obj, 0, true);
return sbOutput.ToString();
}
#endregion
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
namespace Scrummer.Code.JSON
{
public class JSONWriter
{
#region Declarations
private bool indent = false;
private bool useTabForIndent = false;
private int indentChars = 4;
private int indentThresold = 3;
#endregion
#region Creator
public JSONWriter() { }
public JSONWriter(int indentChars)
{
this.indent = true;
this.indentChars = indentChars;
this.useTabForIndent = false;
}
public JSONWriter(bool useTabForIndent)
{
this.indent = true;
this.useTabForIndent = useTabForIndent;
}
#endregion
#region Private methods
private bool IsValue(Object obj)
{
if (obj == null)
{
return true;
}
if ((obj is float) || (obj is double) ||
(obj is System.Int16) || (obj is System.Int32) || (obj is System.Int64)
|| (obj is String) || (obj is Boolean))
{
return true;
}
return false;
}
private void WriteIndent(StringBuilder sbOutput, int level)
{
if (!indent)
{
return;
}
sbOutput.Append('\n');
if (useTabForIndent)
{
for (int i = 0; i < level; i++) { sbOutput.Append('\t'); }
}
else
{
int n = level * indentChars;
for (int i = 0; i < n; i++) { sbOutput.Append(' '); }
}
}
private void WriteString(StringBuilder sbOutput, String str)
{
sbOutput.Append('"');
char c;
int n = str.Length;
for (int i = 0; i < n; i++)
{
c = str[i];
if (c == '"') { sbOutput.Append("\\\""); }
else if (c == '\\') { sbOutput.Append("\\\\"); }
else if (c == '/') { sbOutput.Append("\\/"); }
else if (c == '\b') { sbOutput.Append("\\b"); }
else if (c == '\f') { sbOutput.Append("\\f"); }
else if (c == '\n') { sbOutput.Append("\\n"); }
else if (c == '\r') { sbOutput.Append("\\r"); }
else if (c == '\t') { sbOutput.Append("\\t"); }
else { sbOutput.Append(c); }
// FIXME: Unicode characters
}
sbOutput.Append('"');
}
private void WriteValue(StringBuilder sbOutput, Object obj, int level, bool useReflection)
{
if (obj == null)
{
// NULL
sbOutput.Append("null");
}
else if ((obj is float) || (obj is double) ||
(obj is System.Int16) || (obj is System.Int32) || (obj is System.Int64))
{
// Numbers
sbOutput.Append(obj.ToString());
}
else if (obj is String)
{
// Strings
WriteString(sbOutput, (String)obj);
}
else if (obj is Boolean)
{
// Booleans
sbOutput.Append(((Boolean)obj) ? "true" : "false");
}
else if (obj is IDictionary)
{
// Objects
WriteObject(sbOutput, obj, level);
}
else if (obj is IEnumerable)
{
// Array/List
WriteList(sbOutput, obj, level);
}
else
{
if (useReflection)
{
// Reflected object
WriteReflectedObject(sbOutput, obj, level);
}
else
{
WriteString(sbOutput, Convert.ToString(obj));
}
}
}
private void WriteList(StringBuilder sbOutput, Object obj, int level)
{
IEnumerable list = (IEnumerable)obj;
int n = 0;
// Check if it is a leaf object
bool isLeaf = true;
foreach (object childObj in list)
{
if (!IsValue(childObj))
{
isLeaf = false;
}
n++;
}
// Empty
if (n == 0)
{
sbOutput.Append("[ ]");
return;
}
// Write array
bool first = true;
sbOutput.Append("[ ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
foreach (object childObj in list)
{
if (!first)
{
sbOutput.Append(", ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
}
first = false;
WriteValue(sbOutput, childObj, level + 1, true);
}
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level);
}
sbOutput.Append(" ]");
}
private void WriteObject(StringBuilder sbOutput, Object obj, int level)
{
IDictionary map = (IDictionary)obj;
int n = map.Count;
// Empty
if (map.Count == 0)
{
sbOutput.Append("{ }");
return;
}
// Check if it is a leaf object
bool isLeaf = true;
foreach (object value in map.Values)
{
if (!IsValue(value))
{
isLeaf = false;
break;
}
}
// Write object
bool first = true;
sbOutput.Append("{ ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
foreach (object key in map.Keys)
{
object value = map[key];
if (!first)
{
sbOutput.Append(", ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
}
first = false;
WriteString(sbOutput, Convert.ToString(key));
sbOutput.Append(": ");
WriteValue(sbOutput, value, level + 1, true);
}
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level);
}
sbOutput.Append(" }");
}
private void WriteReflectedObject(StringBuilder sbOutput, Object obj, int level)
{
Type type = obj.GetType();
PropertyInfo[] rawProperties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
List<PropertyInfo> properties = new List<PropertyInfo>();
foreach (PropertyInfo property in rawProperties)
{
if (property.CanRead)
{
properties.Add(property);
}
}
int n = properties.Count;
// Empty
if (n == 0)
{
sbOutput.Append("{ }");
return;
}
// Check if it is a leaf object
bool isLeaf = true;
foreach (PropertyInfo property in properties)
{
object value = property.GetValue(obj, null);
if (!IsValue(value))
{
isLeaf = false;
break;
}
}
// Write object
bool first = true;
sbOutput.Append("{ ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
foreach (PropertyInfo property in properties)
{
object value = null;
MethodInfo getMethod = property.GetGetMethod();
ParameterInfo[] parameters = getMethod.GetParameters();
if (parameters.Length == 0)
{
value = property.GetValue(obj, null);
}
if (!first)
{
sbOutput.Append(", ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
}
first = false;
WriteString(sbOutput, property.Name);
sbOutput.Append(": ");
WriteValue(sbOutput, value, level + 1, false);
}
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level);
}
sbOutput.Append(" }");
}
#endregion
#region Public methods
public String Write(Object obj)
{
StringBuilder sbOutput = new StringBuilder();
WriteValue(sbOutput, obj, 0, true);
return sbOutput.ToString();
}
#endregion
}
}

View File

@@ -1,84 +1,84 @@
using System;
namespace Scrummer.Code.JSON
{
public class ParserContext
{
#region Declarations
private String text;
private int length;
private int i;
private int markStart;
#endregion
#region Creator
public ParserContext(String text)
{
this.text = text;
this.length = text.Length;
this.i = 0;
this.markStart = 0;
}
#endregion
#region Public methods
public char SkipWhite()
{
while (i < length && Char.IsWhiteSpace(text[i]))
{
i++;
}
if (AtEnd())
{
return (char)0;
}
return text[i];
}
public char Next()
{
i++;
if (AtEnd())
{
return (char)0;
}
return text[i];
}
public bool AtEnd()
{
return i >= length;
}
public void Mark()
{
markStart = this.i;
}
public String GetMarked()
{
if (i < length && markStart < length)
{
return text.Substring(markStart, i);
}
else
{
if (markStart < length)
{
return text.Substring(markStart, length);
}
else
{
return string.Empty;
}
}
}
#endregion
}
}
using System;
namespace Scrummer.Code.JSON
{
public class ParserContext
{
#region Declarations
private String text;
private int length;
private int i;
private int markStart;
#endregion
#region Creator
public ParserContext(String text)
{
this.text = text;
this.length = text.Length;
this.i = 0;
this.markStart = 0;
}
#endregion
#region Public methods
public char SkipWhite()
{
while (i < length && Char.IsWhiteSpace(text[i]))
{
i++;
}
if (AtEnd())
{
return (char)0;
}
return text[i];
}
public char Next()
{
i++;
if (AtEnd())
{
return (char)0;
}
return text[i];
}
public bool AtEnd()
{
return i >= length;
}
public void Mark()
{
markStart = this.i;
}
public String GetMarked()
{
if (i < length && markStart < length)
{
return text.Substring(markStart, i);
}
else
{
if (markStart < length)
{
return text.Substring(markStart, length);
}
else
{
return string.Empty;
}
}
}
#endregion
}
}

View File

@@ -0,0 +1,27 @@
using System;
using Scrummer.Code.Controls;
namespace Scrummer.Code.Pages
{
public class FrmBoard : PageCommon
{
private int _idBoard = 0;
public FrmBoard()
{
Init += FrmBoard_Init;
}
void FrmBoard_Init(object sender, EventArgs e)
{
Title = "Board";
var lblTest = new CLabel { Text = "Hello World", Tag = "h2" };
Controls.Add(lblTest);
ChatControl chatControl = new ChatControl();
chatControl.IDBoard = _idBoard;
chatControl.UserName = Convert.ToString(new Random().Next());
Controls.Add(chatControl);
}
}
}

View File

@@ -1,21 +1,25 @@
using System.Web;
using Scrummer.Code.JSON;
namespace Scrummer.Code.Pages
{
public class FrmEcho : IHttpHandler
{
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
var jsonWritter = new JSONWriter(true);
context.Response.Write("<pre><code>");
context.Response.Write(jsonWritter.Write(context.Request));
context.Response.Write("</code></pre>");
}
}
}
using System.Web;
using Scrummer.Code.JSON;
namespace Scrummer.Code.Pages
{
public class FrmEcho : IHttpHandler
{
#region IHttpHandler
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
var jsonWritter = new JSONWriter(true);
context.Response.Write("<pre><code>");
context.Response.Write(jsonWritter.Write(context.Request));
context.Response.Write("</code></pre>");
}
#endregion
}
}

View File

@@ -1,48 +1,65 @@
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Scrummer.Code.Controls;
namespace Scrummer.Code.Pages
{
public class FrmError : PageCommon
{
Exception _ex = null;
public FrmError(Exception ex)
{
_ex = ex;
Init += FrmError_Init;
}
void FrmError_Init(object sender, EventArgs e)
{
Title = "Application Error";
CLabel lblErrorTitle = new CLabel { Text = Title, Tag = "h2" };
Controls.Add(lblErrorTitle);
Exception exAux = _ex;
if (exAux is HttpUnhandledException && exAux.InnerException != null) { exAux = exAux.InnerException; }
while (exAux != null)
{
CLabel lblMessage = new CLabel { Tag = "P" };
lblMessage.Text = String.Format("<b>{0}:</b> {1}", "Message", HttpUtility.HtmlEncode(exAux.Message));
Controls.Add(lblMessage);
CLabel lblStacktraceTitle = new CLabel { Tag = "p" };
lblStacktraceTitle.Text = String.Format("<b>{0}:</b>", "Stacktrace");
Controls.Add(lblStacktraceTitle);
Panel pnlStacktrace = new Panel();
pnlStacktrace.CssClass = "divCode";
Controls.Add(pnlStacktrace);
LiteralControl litStackTrace = new LiteralControl(
String.Format("<pre><code>{0}</code></pre>", HttpUtility.HtmlEncode(exAux.StackTrace)));
pnlStacktrace.Controls.Add(litStackTrace);
exAux = exAux.InnerException;
}
}
}
}
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Scrummer.Code.Controls;
namespace Scrummer.Code.Pages
{
public class FrmError : PageCommon
{
#region Declarations
Exception _ex = null;
#endregion
#region Page life cycle
public FrmError(Exception ex)
{
_ex = ex;
Init += FrmError_Init;
}
void FrmError_Init(object sender, EventArgs e)
{
InitializeControls();
}
#endregion
#region Private methods
private void InitializeControls()
{
Title = "Application Error";
CLabel lblErrorTitle = new CLabel { Text = Title, Tag = "h2" };
Controls.Add(lblErrorTitle);
Exception exAux = _ex;
if (exAux is HttpUnhandledException && exAux.InnerException != null) { exAux = exAux.InnerException; }
while (exAux != null)
{
CLabel lblMessage = new CLabel { Tag = "P" };
lblMessage.Text = String.Format("<b>{0}:</b> {1}", "Message", HttpUtility.HtmlEncode(exAux.Message));
Controls.Add(lblMessage);
CLabel lblStacktraceTitle = new CLabel { Tag = "p" };
lblStacktraceTitle.Text = String.Format("<b>{0}:</b>", "Stacktrace");
Controls.Add(lblStacktraceTitle);
Panel pnlStacktrace = new Panel();
pnlStacktrace.CssClass = "divCode";
Controls.Add(pnlStacktrace);
LiteralControl litStackTrace = new LiteralControl(
String.Format("<pre><code>{0}</code></pre>", HttpUtility.HtmlEncode(exAux.StackTrace)));
pnlStacktrace.Controls.Add(litStackTrace);
exAux = exAux.InnerException;
}
}
#endregion
}
}

View File

@@ -1,92 +1,92 @@
using System;
using System.Reflection;
using System.Text;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Scrummer.Code.Controls;
namespace Scrummer.Code.Pages
{
public class PageCommon : Page
{
#region Declarations
private HtmlHead _head;
private HtmlGenericControl _body;
private HtmlForm _form;
private Panel _pnlContainer = new Panel();
#endregion
#region Properties
public new ControlCollection Controls
{
get { return _pnlContainer.Controls; }
}
#endregion
#region Life cycle
public PageCommon()
{
Init += PageCommon_Init;
PreRender += PageCommon_PreRender;
}
void PageCommon_Init(object sender, EventArgs e)
{
CreateControls();
}
void PageCommon_PreRender(object sender, EventArgs e)
{
_head.Title = string.IsNullOrEmpty(Title) ? Globals.Title : String.Format("{0}{1}{2}", Globals.Title, Globals.TitleSeparator, Title);
}
#endregion
#region Private methods
private void CreateControls()
{
Context.Response.Charset = Encoding.UTF8.WebName;
var doctype = new LiteralControl("<!DOCTYPE html>\n");
base.Controls.Add(doctype);
var html = new HtmlGenericControl("html");
base.Controls.Add(html);
_head = new HtmlHead();
html.Controls.Add(_head);
_head.Controls.Add(new HtmlMeta { HttpEquiv = "content-type", Content = "text/html; charset=utf-8" });
_head.Controls.Add(new HtmlMeta { Name = "author", Content = Globals.Author });
_head.Controls.Add(new HtmlMeta { Name = "Copyright", Content = Globals.Copyright });
Assembly asm = Assembly.GetExecutingAssembly();
string version = asm.GetName().Version.ToString();
_head.Controls.Add(new LiteralControl(String.Format("<script type=\"text/javascript\" src=\"ScriptsBundler?t={0}\"></script>\n", version)));
_head.Controls.Add(new LiteralControl(String.Format("<link href=\"StylesBundler?t={0}\" type=\"text/css\" rel=\"stylesheet\"/>\n", version)));
_body = new HtmlGenericControl("body");
html.Controls.Add(_body);
_form = new HtmlForm { ID = "formMain" };
_body.Controls.Add(_form);
var pnlHeader = new Panel { CssClass = "divHeader" };
_form.Controls.Add(pnlHeader);
var lblTitle = new CLabel { Text = Globals.Title, Tag = "h1" };
pnlHeader.Controls.Add(lblTitle);
_pnlContainer.CssClass = "divContent";
_form.Controls.Add(_pnlContainer);
}
#endregion
}
}
using System;
using System.Reflection;
using System.Text;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Scrummer.Code.Controls;
namespace Scrummer.Code.Pages
{
public class PageCommon : Page
{
#region Declarations
private HtmlHead _head;
private HtmlGenericControl _body;
private HtmlForm _form;
private Panel _pnlContainer = new Panel();
#endregion
#region Properties
public new ControlCollection Controls
{
get { return _pnlContainer.Controls; }
}
#endregion
#region Life cycle
public PageCommon()
{
Init += PageCommon_Init;
PreRender += PageCommon_PreRender;
}
void PageCommon_Init(object sender, EventArgs e)
{
CreateControls();
}
void PageCommon_PreRender(object sender, EventArgs e)
{
_head.Title = string.IsNullOrEmpty(Title) ? Globals.Title : String.Format("{0}{1}{2}", Globals.Title, Globals.TitleSeparator, Title);
}
#endregion
#region Private methods
private void CreateControls()
{
Context.Response.Charset = Encoding.UTF8.WebName;
var doctype = new LiteralControl("<!DOCTYPE html>\n");
base.Controls.Add(doctype);
var html = new HtmlGenericControl("html");
base.Controls.Add(html);
_head = new HtmlHead();
html.Controls.Add(_head);
_head.Controls.Add(new HtmlMeta { HttpEquiv = "content-type", Content = "text/html; charset=utf-8" });
_head.Controls.Add(new HtmlMeta { Name = "author", Content = Globals.Author });
_head.Controls.Add(new HtmlMeta { Name = "Copyright", Content = Globals.Copyright });
Assembly asm = Assembly.GetExecutingAssembly();
string version = asm.GetName().Version.ToString();
_head.Controls.Add(new LiteralControl(String.Format("<script type=\"text/javascript\" src=\"ScriptsBundler?t={0}\"></script>\n", version)));
_head.Controls.Add(new LiteralControl(String.Format("<link href=\"StylesBundler?t={0}\" type=\"text/css\" rel=\"stylesheet\"/>\n", version)));
_body = new HtmlGenericControl("body");
html.Controls.Add(_body);
_form = new HtmlForm { ID = "formMain" };
_body.Controls.Add(_form);
var pnlHeader = new Panel { CssClass = "divHeader" };
_form.Controls.Add(pnlHeader);
var lblTitle = new CLabel { Text = Globals.Title, Tag = "h1" };
pnlHeader.Controls.Add(lblTitle);
_pnlContainer.CssClass = "divContent";
_form.Controls.Add(_pnlContainer);
}
#endregion
}
}

View File

@@ -1,20 +1,20 @@
using System.Web;
namespace Scrummer.Code
{
public class ScriptsBundler : IHttpHandler
{
#region IHttpHandler
public bool IsReusable { get { return false; } }
public void ProcessRequest(HttpContext context)
{
Bundler bundler = new Bundler(context.Server.MapPath("~/Scripts/"));
context.Response.ContentType = "text/javascript";
bundler.WriteResponse(context.Response.OutputStream);
}
#endregion
}
}
using System.Web;
namespace Scrummer.Code
{
public class ScriptsBundler : IHttpHandler
{
#region IHttpHandler
public bool IsReusable { get { return false; } }
public void ProcessRequest(HttpContext context)
{
Bundler bundler = new Bundler(context.Server.MapPath("~/Scripts/"));
context.Response.ContentType = "text/javascript";
bundler.WriteResponse(context.Response.OutputStream);
}
#endregion
}
}

View File

@@ -1,20 +1,20 @@
using System.Web;
namespace Scrummer.Code
{
public class StylesBundler : IHttpHandler
{
#region IHttpHandler
public bool IsReusable { get { return false; } }
public void ProcessRequest(HttpContext context)
{
Bundler bundler = new Bundler(context.Server.MapPath("~/Styles/"));
context.Response.ContentType = "text/css";
bundler.WriteResponse(context.Response.OutputStream);
}
#endregion
}
}
using System.Web;
namespace Scrummer.Code
{
public class StylesBundler : IHttpHandler
{
#region IHttpHandler
public bool IsReusable { get { return false; } }
public void ProcessRequest(HttpContext context)
{
Bundler bundler = new Bundler(context.Server.MapPath("~/Styles/"));
context.Response.ContentType = "text/css";
bundler.WriteResponse(context.Response.OutputStream);
}
#endregion
}
}

View File

@@ -1,117 +1,126 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Web;
using Scrummer.Code;
namespace Scrummer
{
public class GlobalRouter : IHttpHandler
{
#region Handlers
private static Dictionary<string, Type> _handlers = new Dictionary<string, Type>();
private static IHttpHandler GetHandler(string typeName)
{
if (string.IsNullOrEmpty(typeName)) { return null; }
Type type = null;
if (_handlers.ContainsKey(typeName))
{
type = _handlers[typeName];
IHttpHandler handler = Activator.CreateInstance(type) as IHttpHandler;
return handler;
}
// Search type on executing assembly
Type[] types;
Assembly asm = Assembly.GetExecutingAssembly();
types = asm.GetTypes();
foreach (Type typeAux in types)
{
if (typeAux.FullName.EndsWith(typeName))
{
type = typeAux;
break;
}
}
// Search type on all loaded assemblies
if (type == null)
{
Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly asmAux in asms)
{
types = asmAux.GetTypes();
foreach (Type typeAux in types)
{
if (typeAux.FullName.EndsWith(typeName))
{
type = typeAux;
break;
}
}
if (type != null) { break; }
}
}
// Use found type
if (type != null)
{
IHttpHandler handler = Activator.CreateInstance(type) as IHttpHandler;
if (handler != null)
{
lock (_handlers)
{
if (_handlers.ContainsKey(typeName) == false)
{
_handlers.Add(typeName, type);
}
}
}
return handler;
}
return null;
}
#endregion
#region IHttpHandler
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
try
{
string file = Path.GetFileName(context.Request.FilePath);
if (string.IsNullOrEmpty(file))
{
file = Globals.DefaultHandler;
}
IHttpHandler handler = GetHandler(file);
if (handler == null)
{
// TODO: FrmNotFound
throw new Exception("NotFound");
}
// Use handler
context.Response.Clear();
context.Handler = handler;
handler.ProcessRequest(context);
}
catch (Exception ex)
{
GlobalErrorHandler.HandleError(context, ex);
}
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Web;
using Scrummer.Code;
namespace Scrummer
{
public class GlobalRouter : IHttpHandler
{
#region Handlers
private static Dictionary<string, Type> _handlers = new Dictionary<string, Type>();
private static IHttpHandler GetHandler(string typeName)
{
if (string.IsNullOrEmpty(typeName)) { return null; }
Type type = null;
if (_handlers.ContainsKey(typeName))
{
type = _handlers[typeName];
IHttpHandler handler = Activator.CreateInstance(type) as IHttpHandler;
return handler;
}
// Search type on executing assembly
Type[] types;
Assembly asm = Assembly.GetExecutingAssembly();
types = asm.GetTypes();
foreach (Type typeAux in types)
{
if (typeAux.FullName.EndsWith(typeName))
{
type = typeAux;
break;
}
}
// Search type on all loaded assemblies
if (type == null)
{
Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly asmAux in asms)
{
types = asmAux.GetTypes();
foreach (Type typeAux in types)
{
if (typeAux.FullName.EndsWith(typeName))
{
type = typeAux;
break;
}
}
if (type != null) { break; }
}
}
// Use found type
if (type != null)
{
IHttpHandler handler = Activator.CreateInstance(type) as IHttpHandler;
if (handler != null)
{
lock (_handlers)
{
if (_handlers.ContainsKey(typeName) == false)
{
_handlers.Add(typeName, type);
}
}
}
return handler;
}
return null;
}
#endregion
#region IHttpHandler
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
try
{
RouteRequest(context);
}
catch (Exception ex)
{
GlobalErrorHandler.HandleError(context, ex);
}
}
#endregion
#region Private methods
private void RouteRequest(HttpContext context)
{
string file = Path.GetFileName(context.Request.FilePath);
if (string.IsNullOrEmpty(file))
{
file = Globals.DefaultHandler;
}
IHttpHandler handler = GetHandler(file);
if (handler == null)
{
// TODO: FrmNotFound
throw new Exception("NotFound");
}
// Use handler
context.Response.Clear();
context.Handler = handler;
handler.ProcessRequest(context);
}
#endregion
}
}

View File

@@ -1,12 +1,12 @@
namespace Scrummer
{
public static class Globals
{
public const string Title = "Scrummer";
public const string TitleSeparator = " :: ";
public const string Author = "Valeriano Alfonso Rodriguez";
public const string Copyright = "Copyright (c) 2015 by Valeriano Alfonso, All Right Reserved";
public const string DefaultHandler = "FrmBoard";
}
}
namespace Scrummer
{
public static class Globals
{
public const string Title = "Scrummer";
public const string TitleSeparator = " :: ";
public const string Author = "Valeriano Alfonso Rodriguez";
public const string Copyright = "Copyright (c) 2015 by Valeriano Alfonso, All Right Reserved";
public const string DefaultHandler = "FrmBoard";
}
}

View File

@@ -1,34 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Scrummer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("VAR")]
[assembly: AssemblyProduct("Scrummer")]
[assembly: AssemblyCopyright("Copyright © VAR 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4cd25e9d-237f-4a9f-89ac-35e537cf265e")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Scrummer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("VAR")]
[assembly: AssemblyProduct("Scrummer")]
[assembly: AssemblyCopyright("Copyright © VAR 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4cd25e9d-237f-4a9f-89ac-35e537cf265e")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>False</EnableUpdateable>
<DebugSymbols>False</DebugSymbols>
<WDPMergeOption>DonotMerge</WDPMergeOption>
<ExcludeApp_Data>True</ExcludeApp_Data>
<publishUrl>C:\Users\VAR\source\Scrummer\Published</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>

View File

@@ -1,20 +1,20 @@
function GetElement(element) {
if (typeof element == "string") {
element = document.getElementById(element);
}
return element;
}
function escapeHTML(s) {
return s.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
}
function fixedEncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16);
});
}
function GetElement(element) {
if (typeof element == "string") {
element = document.getElementById(element);
}
return element;
}
function escapeHTML(s) {
return s.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
}
function fixedEncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16);
});
}

View File

@@ -1,122 +1,122 @@
function SendRequest(url, onData, onError) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
if (onData) {
onData(xhr.responseText);
}
} else {
if (onError) {
onError();
}
}
}
}
xhr.send(null);
}
function GetDataQueryString(data) {
var queryString = "";
for (var property in data) {
if (data.hasOwnProperty(property)) {
var value = data[property];
queryString += (queryString.length > 0 ? "&" : "")
+ fixedEncodeURIComponent(property) + "="
+ fixedEncodeURIComponent(value ? value : "");
}
}
return queryString;
}
function SendData(url, data, onData, onError) {
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
if (onData) {
onData(xhr.responseText);
}
} else {
if (onError) {
onError();
}
}
}
}
xhr.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
xhr.send(GetDataQueryString(data));
}
function GetFormQueryString(idForm) {
var form = document.getElementById(idForm);
var queryString = "";
if (!form)
return null;
function appendVal(name, value) {
queryString += (queryString.length > 0 ? "&" : "")
+ fixedEncodeURIComponent(name) + "="
+ fixedEncodeURIComponent(value ? value : "");
}
var elements = form.elements;
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var elemType = element.type.toUpperCase();
var elemName = element.name;
if (elemName) {
if (
elemType.indexOf("TEXT") != -1 ||
elemType.indexOf("TEXTAREA") != -1 ||
elemType.indexOf("PASSWORD") != -1 ||
elemType.indexOf("BUTTON") != -1 ||
elemType.indexOf("HIDDEN") != -1 ||
elemType.indexOf("SUBMIT") != -1 ||
elemType.indexOf("IMAGE") != -1
) {
appendVal(elemName, element.value);
} else if (elemType.indexOf("CHECKBOX") != -1 && element.checked) {
appendVal(elemName, element.value ? element.value : "On");
} else if (elemType.indexOf("RADIO") != -1 && element.checked) {
appendVal(elemName, element.value);
} else if (elemType.indexOf("SELECT") != -1) {
for (var j = 0; j < element.options.length; j++) {
var option = element.options[j];
if (option.selected) {
appendVal(elemName,
option.value ? option.value : option.text);
}
}
}
}
}
return queryString;
}
function SendForm(url, idForm, onData, onError) {
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
if (onData) {
onData(xhr.responseText);
}
} else {
if (onError) {
onError();
}
}
}
}
xhr.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
xhr.send(GetFormQueryString(idForm));
}
function SendRequest(url, onData, onError) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
if (onData) {
onData(xhr.responseText);
}
} else {
if (onError) {
onError();
}
}
}
}
xhr.send(null);
}
function GetDataQueryString(data) {
var queryString = "";
for (var property in data) {
if (data.hasOwnProperty(property)) {
var value = data[property];
queryString += (queryString.length > 0 ? "&" : "")
+ fixedEncodeURIComponent(property) + "="
+ fixedEncodeURIComponent(String(value));
}
}
return queryString;
}
function SendData(url, data, onData, onError) {
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
if (onData) {
onData(xhr.responseText);
}
} else {
if (onError) {
onError();
}
}
}
}
xhr.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
xhr.send(GetDataQueryString(data));
}
function GetFormQueryString(idForm) {
var form = document.getElementById(idForm);
var queryString = "";
if (!form)
return null;
function appendVal(name, value) {
queryString += (queryString.length > 0 ? "&" : "")
+ fixedEncodeURIComponent(name) + "="
+ fixedEncodeURIComponent(value ? value : "");
}
var elements = form.elements;
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var elemType = element.type.toUpperCase();
var elemName = element.name;
if (elemName) {
if (
elemType.indexOf("TEXT") != -1 ||
elemType.indexOf("TEXTAREA") != -1 ||
elemType.indexOf("PASSWORD") != -1 ||
elemType.indexOf("BUTTON") != -1 ||
elemType.indexOf("HIDDEN") != -1 ||
elemType.indexOf("SUBMIT") != -1 ||
elemType.indexOf("IMAGE") != -1
) {
appendVal(elemName, element.value);
} else if (elemType.indexOf("CHECKBOX") != -1 && element.checked) {
appendVal(elemName, element.value ? element.value : "On");
} else if (elemType.indexOf("RADIO") != -1 && element.checked) {
appendVal(elemName, element.value);
} else if (elemType.indexOf("SELECT") != -1) {
for (var j = 0; j < element.options.length; j++) {
var option = element.options[j];
if (option.selected) {
appendVal(elemName,
option.value ? option.value : option.text);
}
}
}
}
}
return queryString;
}
function SendForm(url, idForm, onData, onError) {
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
if (onData) {
onData(xhr.responseText);
}
} else {
if (onError) {
onError();
}
}
}
}
xhr.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
xhr.send(GetFormQueryString(idForm));
}

View File

@@ -1,93 +1,93 @@
function RunChat(serviceUrl, divContainer, idBoard, hidIDMessage, hidUserName, hidLastUser) {
divContainer = GetElement(divContainer);
hidIDMessage = GetElement(hidIDMessage);
hidUserName = GetElement(hidUserName);
hidLastUser = GetElement(hidLastUser);
var CreateMessageDOM = function (message, selfMessage, hidLastUser) {
var divMessageRow = document.createElement("DIV");
if (selfMessage) {
divMessageRow.className = "selfMessageRow";
} else {
divMessageRow.className = "messageRow";
}
var divMessage = document.createElement("DIV");
divMessage.className = "message";
divMessageRow.appendChild(divMessage);
if (hidLastUser.value !== message.UserName) {
var divUser = document.createElement("DIV");
divUser.className = "user";
divUser.innerHTML = escapeHTML(message.UserName);
divMessage.appendChild(divUser);
hidLastUser.value = message.UserName;
}
var text = message.Text;
var divText = document.createElement("DIV");
divText.className = "text";
divText.innerHTML = escapeHTML(text);
divMessage.appendChild(divText);
return divMessageRow;
};
var RequestChatData = function () {
var requestUrl = serviceUrl + "?idBoard=" + idBoard + "&idMessage=" + hidIDMessage.value;
var ReciveChatData = function (responseText) {
recvMsgs = JSON.parse(responseText);
if (recvMsgs) {
var idMessage = parseInt(hidIDMessage.value);
var frag = document.createDocumentFragment();
for (var i = 0, n = recvMsgs.length; i < n; i++) {
var msg = recvMsgs[i];
if (idMessage < msg.IDMessage) {
hidIDMessage.value = msg.IDMessage;
idMessage = msg.IDMessage;
var elemMessage = CreateMessageDOM(msg, (msg.UserName == hidUserName.value), hidLastUser);
frag.appendChild(elemMessage);
}
}
divContainer.appendChild(frag);
divContainer.scrollTop = divContainer.scrollHeight;
}
// Reset pool
window.setTimeout(function () {
RequestChatData();
}, 20);
};
var ErrorChatData = function () {
// Retry
window.setTimeout(function () {
RequestChatData();
}, 5000);
};
// Pool data
SendRequest(requestUrl, ReciveChatData, ErrorChatData);
};
RequestChatData();
}
function SendChat(serviceUrl, txtText, idBoard, hidUserName) {
txtText = GetElement(txtText);
hidUserName = GetElement(hidUserName);
if (txtText.value.trim() == "") {
return;
}
var data = {
"text": txtText.value,
"idBoard": idBoard,
"userName": hidUserName.value
};
txtText.value = "";
SendData(serviceUrl, data, null, null);
txtText.focus();
}
function RunChat(serviceUrl, divContainer, idBoard, hidIDMessage, hidUserName, hidLastUser) {
divContainer = GetElement(divContainer);
hidIDMessage = GetElement(hidIDMessage);
hidUserName = GetElement(hidUserName);
hidLastUser = GetElement(hidLastUser);
var CreateMessageDOM = function (message, selfMessage, hidLastUser) {
var divMessageRow = document.createElement("DIV");
if (selfMessage) {
divMessageRow.className = "selfMessageRow";
} else {
divMessageRow.className = "messageRow";
}
var divMessage = document.createElement("DIV");
divMessage.className = "message";
divMessageRow.appendChild(divMessage);
if (hidLastUser.value !== message.UserName) {
var divUser = document.createElement("DIV");
divUser.className = "user";
divUser.innerHTML = escapeHTML(message.UserName);
divMessage.appendChild(divUser);
hidLastUser.value = message.UserName;
}
var text = message.Text;
var divText = document.createElement("DIV");
divText.className = "text";
divText.innerHTML = escapeHTML(text);
divMessage.appendChild(divText);
return divMessageRow;
};
var RequestChatData = function () {
var requestUrl = serviceUrl + "?idBoard=" + idBoard + "&idMessage=" + hidIDMessage.value;
var ReciveChatData = function (responseText) {
recvMsgs = JSON.parse(responseText);
if (recvMsgs) {
var idMessage = parseInt(hidIDMessage.value);
var frag = document.createDocumentFragment();
for (var i = 0, n = recvMsgs.length; i < n; i++) {
var msg = recvMsgs[i];
if (idMessage < msg.IDMessage) {
hidIDMessage.value = msg.IDMessage;
idMessage = msg.IDMessage;
var elemMessage = CreateMessageDOM(msg, (msg.UserName == hidUserName.value), hidLastUser);
frag.appendChild(elemMessage);
}
}
divContainer.appendChild(frag);
divContainer.scrollTop = divContainer.scrollHeight;
}
// Reset pool
window.setTimeout(function () {
RequestChatData();
}, 20);
};
var ErrorChatData = function () {
// Retry
window.setTimeout(function () {
RequestChatData();
}, 5000);
};
// Pool data
SendRequest(requestUrl, ReciveChatData, ErrorChatData);
};
RequestChatData();
}
function SendChat(serviceUrl, txtText, idBoard, hidUserName) {
txtText = GetElement(txtText);
hidUserName = GetElement(hidUserName);
if (txtText.value.trim() == "") {
return;
}
var data = {
"text": txtText.value,
"idBoard": idBoard,
"userName": hidUserName.value
};
txtText.value = "";
SendData(serviceUrl, data, null, null);
txtText.focus();
}

View File

@@ -1,133 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7596FD6B-DAF0-4B22-B356-5CF4629F0436}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Scrummer</RootNamespace>
<AssemblyName>Scrummer</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
</ItemGroup>
<ItemGroup>
<Content Include="Scripts\01. Base.js" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
</None>
<None Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Scripts\02. Ajax.js" />
<Content Include="Scripts\10. Chat.js" />
<Content Include="Styles\01. base.css" />
<Content Include="Styles\10. Chat.css" />
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Code\Bundler.cs" />
<Compile Include="Code\Controls\ChatControl.cs" />
<Compile Include="Code\Controls\ChatHandler.cs" />
<Compile Include="Code\Controls\CLabel.cs" />
<Compile Include="Code\GlobalErrorHandler.cs" />
<Compile Include="Code\JSON\ParserContext.cs" />
<Compile Include="Code\Pages\FrmEcho.cs" />
<Compile Include="Code\Pages\PageCommon.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Code\ScriptsBundler.cs" />
<Compile Include="Code\StylesBundler.cs" />
<Compile Include="GlobalRouter.cs" />
<Compile Include="Code\JSON\JSONParser.cs" />
<Compile Include="Code\JSON\JSONWriter.cs" />
<Compile Include="Code\Pages\FrmError.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Globals.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup />
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>51559</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:51555/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7596FD6B-DAF0-4B22-B356-5CF4629F0436}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Scrummer</RootNamespace>
<AssemblyName>Scrummer</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Configuration" />
</ItemGroup>
<ItemGroup>
<Content Include="Scripts\01. Base.js" />
<None Include="Properties\PublishProfiles\Scrummer.pubxml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
</None>
<None Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Scripts\02. Ajax.js" />
<Content Include="Scripts\10. Chat.js" />
<Content Include="Styles\01. base.css" />
<Content Include="Styles\10. Chat.css" />
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Code\Bundler.cs" />
<Compile Include="Code\Controls\ChatControl.cs" />
<Compile Include="Code\Controls\ChatHandler.cs" />
<Compile Include="Code\Controls\CLabel.cs" />
<Compile Include="Code\GlobalErrorHandler.cs" />
<Compile Include="Code\JSON\ParserContext.cs" />
<Compile Include="Code\Pages\FrmBoard.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Code\Pages\FrmEcho.cs" />
<Compile Include="Code\Pages\PageCommon.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Code\ScriptsBundler.cs" />
<Compile Include="Code\StylesBundler.cs" />
<Compile Include="GlobalRouter.cs" />
<Compile Include="Code\JSON\JSONParser.cs" />
<Compile Include="Code\JSON\JSONWriter.cs" />
<Compile Include="Code\Pages\FrmError.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Globals.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup />
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>51559</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:51555/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<StartPageUrl>
</StartPageUrl>
<StartAction>CurrentPage</StartAction>
<AspNetDebugging>True</AspNetDebugging>
<SilverlightDebugging>False</SilverlightDebugging>
<NativeDebugging>False</NativeDebugging>
<SQLDebugging>False</SQLDebugging>
<ExternalProgram>
</ExternalProgram>
<StartExternalURL>
</StartExternalURL>
<StartCmdLineArguments>
</StartCmdLineArguments>
<StartWorkingDirectory>
</StartWorkingDirectory>
<EnableENC>True</EnableENC>
<AlwaysStartWebServerOnDebug>True</AlwaysStartWebServerOnDebug>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>

View File

@@ -1,65 +1,69 @@
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 12px;
background-color: grey;
color: black;
}
p{
margin-bottom: 0.5em;
text-shadow: 0 1px 1px rgba(255,255,255,0.5);
}
h1 {
font-size: 1.7em;
text-align: center;
margin-top: 1.0em;
margin-bottom: 0.5em;
text-shadow: 0 1px 1px rgba(255,255,255,0.5);
}
h2 {
font-size: 1.5em;
text-align: center;
margin-top: 1.0em;
margin-bottom: 0.5em;
text-shadow: 0 1px 1px rgba(255,255,255,0.5);
}
h3 {
font-size: 1.2em;
text-align: left;
margin-top: 1.0em;
margin-bottom: 0.5em;
text-shadow: 0 1px 1px rgba(255,255,255,0.5);
}
.divHeader {
display: block;
background-color: black;
}
.divHeader h1{
font-size: 30px;
color: yellow;
margin: 0;
text-shadow: none;
}
.divContent{
padding-left:10px;
padding-right:10px;
}
.divCode{
background-color: black;
color: green;
font-family: Courier New, Courier, monospace;
text-shadow: none;
overflow:auto;
margin: 5px;
padding: 2px;
box-shadow: 0 0 10px rgb(0,0,0);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 12px;
background-color: grey;
color: black;
}
p {
margin-bottom: 0.5em;
text-shadow: 0 1px 1px rgba(255,255,255,0.5);
}
h1 {
font-size: 1.7em;
text-align: center;
margin-top: 1.0em;
margin-bottom: 0.5em;
text-shadow: 0 1px 1px rgba(255,255,255,0.5);
}
h2 {
font-size: 1.5em;
text-align: center;
margin-top: 1.0em;
margin-bottom: 0.5em;
text-shadow: 0 1px 1px rgba(255,255,255,0.5);
}
h3 {
font-size: 1.2em;
text-align: left;
margin-top: 1.0em;
margin-bottom: 0.5em;
text-shadow: 0 1px 1px rgba(255,255,255,0.5);
}
.divHeader {
display: block;
background-color: black;
}
.divHeader h1 {
font-size: 30px;
color: yellow;
margin: 0;
text-shadow: none;
}
.divContent {
padding-left: 10px;
padding-right: 10px;
}
.divCode {
background-color: black;
color: green;
font-family: Courier New, Courier, monospace;
text-shadow: none;
overflow: auto;
margin: 5px;
padding: 2px;
box-shadow: 0 0 10px rgb(0,0,0);
}

View File

@@ -1,103 +1,102 @@
.divChatWindow{
box-sizing: border-box;
overflow: hidden;
border: solid 1px black;
padding: 5px;
border-radius: 5px;
background-color: rgb(220,220,220);
box-shadow: 0px 0px 5px black;
}
.divChat {
box-sizing: border-box;
overflow: auto;
height: calc(100% - 37px);
margin-bottom: 5px;
border-radius: 5px;
border: solid 1px black;
box-shadow: inset 0px 0px 5px black;
}
.messageRow,
.selfMessageRow{
vertical-align:top;
display:block;
}
.messageRow {
text-align: left;
}
.selfMessageRow {
text-align: right;
}
.message {
box-sizing: border-box;
display: inline-block;
vertical-align: top;
border: solid 1px rgb(32, 32, 32);
background-color: rgb(220,220,220);
border-radius: 5px;
box-shadow:
0px 0px 10px rgba(0,0,0,0.5),
inset 0px 2px 5px rgba(255,255,255,0.5),
inset 0px -2px 5px rgba(128,128,128,0.5);
margin: 2px;
padding: 5px;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
.messageRow .message {
background-color: rgb(220,200,200);
}
.selfMessageRow .message {
background-color: rgb(200,220,200);
}
.message .user{
box-sizing: border-box;
color:rgb(64,64,64);
text-shadow: 0 0 1px rgba(0,0,0,0.3);
font-size:10px;
font-weight:bold;
}
.message .text{
box-sizing: border-box;
color:rgb(32,32,32);
text-shadow: 0 0 1px rgba(0,0,0,0.3);
font-size:12px;
}
.divChatControls{
}
.chatTextBox {
box-sizing: border-box;
padding: 5px;
box-shadow: inset 0px 0px 5px black;
width: calc(100% - 52px);
border-radius: 5px;
border: solid 1px black;
margin: 0 2px 0 0;
vertical-align: top;
height: 30px;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
font-size: 12px;
text-align: left;
}
.chatButton {
box-sizing: border-box;
padding: 5px;
box-shadow:
0px 0px 10px rgba(0,0,0,0.5),
inset 0px 2px 5px rgba(255,255,255,1),
inset 0px -2px 5px rgba(128,128,128,1);
width: 50px;
vertical-align: top;
border-radius: 5px;
border: solid 1px black;
height: 30px;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
font-size: 12px;
text-align: center;
}
.divChatWindow {
box-sizing: border-box;
overflow: hidden;
border: solid 1px black;
padding: 5px;
border-radius: 5px;
background-color: rgb(220,220,220);
box-shadow: 0px 0px 5px black;
}
.divChat {
box-sizing: border-box;
overflow: auto;
height: calc(100% - 37px);
margin-bottom: 5px;
border-radius: 5px;
border: solid 1px black;
box-shadow: inset 0px 0px 5px black;
}
.messageRow,
.selfMessageRow {
vertical-align: top;
display: block;
}
.messageRow {
text-align: left;
}
.selfMessageRow {
text-align: right;
}
.message {
box-sizing: border-box;
display: inline-block;
vertical-align: top;
border: solid 1px rgb(32, 32, 32);
background-color: rgb(220,220,220);
border-radius: 5px;
box-shadow: 0px 0px 10px rgba(0,0,0,0.5), inset 0px 2px 5px rgba(255,255,255,0.5), inset 0px -2px 5px rgba(128,128,128,0.5);
margin: 2px;
padding: 5px;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
.messageRow .message {
background-color: rgb(220,200,200);
}
.selfMessageRow .message {
background-color: rgb(200,220,200);
}
.message .user {
box-sizing: border-box;
color: rgb(64,64,64);
text-shadow: 0 0 1px rgba(0,0,0,0.3);
font-size: 10px;
font-weight: bold;
}
.message .text {
box-sizing: border-box;
color: rgb(32,32,32);
text-shadow: 0 0 1px rgba(0,0,0,0.3);
font-size: 12px;
}
.divChatControls {
}
.chatTextBox {
box-sizing: border-box;
padding: 5px;
box-shadow: inset 0px 0px 5px black;
width: calc(100% - 52px);
border-radius: 5px;
border: solid 1px black;
margin: 0 2px 0 0;
vertical-align: top;
height: 30px;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
font-size: 12px;
text-align: left;
}
.chatButton {
box-sizing: border-box;
padding: 5px;
box-shadow: 0px 0px 10px rgba(0,0,0,0.5), inset 0px 2px 5px rgba(255,255,255,1), inset 0px -2px 5px rgba(128,128,128,1);
width: 50px;
vertical-align: top;
border-radius: 5px;
border: solid 1px black;
height: 30px;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
font-size: 12px;
text-align: center;
}

View File

@@ -1,12 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
</system.web>
<system.webServer>
<handlers>
<add name="GlobalRouter" path="*" verb="*" type="Scrummer.GlobalRouter"/>
</handlers>
</system.webServer>
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
</system.web>
<system.webServer>
<handlers>
<add name="GlobalRouter" path="*" verb="*" type="Scrummer.GlobalRouter"/>
</handlers>
</system.webServer>
</configuration>