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

2
.gitignore vendored
View File

@@ -1,5 +1,7 @@
*.suo *.suo
*.user
*/bin/* */bin/*
*/obj/* */obj/*
Dotfuscated/* Dotfuscated/*
Published/*

View File

@@ -1,22 +1,27 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013 # Visual Studio 2013
VisualStudioVersion = 12.0.31101.0 VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scrummer", "Scrummer\Scrummer.csproj", "{7596FD6B-DAF0-4B22-B356-5CF4629F0436}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scrummer", "Scrummer\Scrummer.csproj", "{7596FD6B-DAF0-4B22-B356-5CF4629F0436}"
EndProject EndProject
Global Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Notes", "Notes", "{22F69F04-ABC4-44DB-9742-A24012298108}"
GlobalSection(SolutionConfigurationPlatforms) = preSolution ProjectSection(SolutionItems) = preProject
Debug|Any CPU = Debug|Any CPU Notes.txt = Notes.txt
Release|Any CPU = Release|Any CPU EndProjectSection
EndGlobalSection EndProject
GlobalSection(ProjectConfigurationPlatforms) = postSolution Global
{7596FD6B-DAF0-4B22-B356-5CF4629F0436}.Debug|Any CPU.ActiveCfg = Debug|Any CPU GlobalSection(SolutionConfigurationPlatforms) = preSolution
{7596FD6B-DAF0-4B22-B356-5CF4629F0436}.Debug|Any CPU.Build.0 = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
{7596FD6B-DAF0-4B22-B356-5CF4629F0436}.Release|Any CPU.ActiveCfg = Release|Any CPU Release|Any CPU = Release|Any CPU
{7596FD6B-DAF0-4B22-B356-5CF4629F0436}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection
EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution
GlobalSection(SolutionProperties) = preSolution {7596FD6B-DAF0-4B22-B356-5CF4629F0436}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
HideSolutionNode = FALSE {7596FD6B-DAF0-4B22-B356-5CF4629F0436}.Debug|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection {7596FD6B-DAF0-4B22-B356-5CF4629F0436}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobal {7596FD6B-DAF0-4B22-B356-5CF4629F0436}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,84 +1,84 @@
using System; using System;
namespace Scrummer.Code.JSON namespace Scrummer.Code.JSON
{ {
public class ParserContext public class ParserContext
{ {
#region Declarations #region Declarations
private String text; private String text;
private int length; private int length;
private int i; private int i;
private int markStart; private int markStart;
#endregion #endregion
#region Creator #region Creator
public ParserContext(String text) public ParserContext(String text)
{ {
this.text = text; this.text = text;
this.length = text.Length; this.length = text.Length;
this.i = 0; this.i = 0;
this.markStart = 0; this.markStart = 0;
} }
#endregion #endregion
#region Public methods #region Public methods
public char SkipWhite() public char SkipWhite()
{ {
while (i < length && Char.IsWhiteSpace(text[i])) while (i < length && Char.IsWhiteSpace(text[i]))
{ {
i++; i++;
} }
if (AtEnd()) if (AtEnd())
{ {
return (char)0; return (char)0;
} }
return text[i]; return text[i];
} }
public char Next() public char Next()
{ {
i++; i++;
if (AtEnd()) if (AtEnd())
{ {
return (char)0; return (char)0;
} }
return text[i]; return text[i];
} }
public bool AtEnd() public bool AtEnd()
{ {
return i >= length; return i >= length;
} }
public void Mark() public void Mark()
{ {
markStart = this.i; markStart = this.i;
} }
public String GetMarked() public String GetMarked()
{ {
if (i < length && markStart < length) if (i < length && markStart < length)
{ {
return text.Substring(markStart, i); return text.Substring(markStart, i);
} }
else else
{ {
if (markStart < length) if (markStart < length)
{ {
return text.Substring(markStart, length); return text.Substring(markStart, length);
} }
else else
{ {
return string.Empty; return string.Empty;
} }
} }
} }
#endregion #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 System.Web;
using Scrummer.Code.JSON; using Scrummer.Code.JSON;
namespace Scrummer.Code.Pages namespace Scrummer.Code.Pages
{ {
public class FrmEcho : IHttpHandler public class FrmEcho : IHttpHandler
{ {
public bool IsReusable #region IHttpHandler
{
get { return false; } public bool IsReusable
} {
get { return false; }
public void ProcessRequest(HttpContext context) }
{
var jsonWritter = new JSONWriter(true); public void ProcessRequest(HttpContext context)
context.Response.Write("<pre><code>"); {
context.Response.Write(jsonWritter.Write(context.Request)); var jsonWritter = new JSONWriter(true);
context.Response.Write("</code></pre>"); 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;
using System.Web; using System.Web;
using System.Web.UI; using System.Web.UI;
using System.Web.UI.WebControls; using System.Web.UI.WebControls;
using Scrummer.Code.Controls; using Scrummer.Code.Controls;
namespace Scrummer.Code.Pages namespace Scrummer.Code.Pages
{ {
public class FrmError : PageCommon public class FrmError : PageCommon
{ {
Exception _ex = null; #region Declarations
public FrmError(Exception ex) Exception _ex = null;
{
_ex = ex; #endregion
Init += FrmError_Init;
} #region Page life cycle
void FrmError_Init(object sender, EventArgs e) public FrmError(Exception ex)
{ {
Title = "Application Error"; _ex = ex;
Init += FrmError_Init;
CLabel lblErrorTitle = new CLabel { Text = Title, Tag = "h2" }; }
Controls.Add(lblErrorTitle);
void FrmError_Init(object sender, EventArgs e)
Exception exAux = _ex; {
if (exAux is HttpUnhandledException && exAux.InnerException != null) { exAux = exAux.InnerException; } InitializeControls();
while (exAux != null) }
{
CLabel lblMessage = new CLabel { Tag = "P" }; #endregion
lblMessage.Text = String.Format("<b>{0}:</b> {1}", "Message", HttpUtility.HtmlEncode(exAux.Message));
Controls.Add(lblMessage); #region Private methods
CLabel lblStacktraceTitle = new CLabel { Tag = "p" }; private void InitializeControls()
lblStacktraceTitle.Text = String.Format("<b>{0}:</b>", "Stacktrace"); {
Controls.Add(lblStacktraceTitle); Title = "Application Error";
Panel pnlStacktrace = new Panel();
pnlStacktrace.CssClass = "divCode"; CLabel lblErrorTitle = new CLabel { Text = Title, Tag = "h2" };
Controls.Add(pnlStacktrace); Controls.Add(lblErrorTitle);
LiteralControl litStackTrace = new LiteralControl(
String.Format("<pre><code>{0}</code></pre>", HttpUtility.HtmlEncode(exAux.StackTrace))); Exception exAux = _ex;
pnlStacktrace.Controls.Add(litStackTrace); if (exAux is HttpUnhandledException && exAux.InnerException != null) { exAux = exAux.InnerException; }
while (exAux != null)
exAux = exAux.InnerException; {
} 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;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Web.UI; using System.Web.UI;
using System.Web.UI.HtmlControls; using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls; using System.Web.UI.WebControls;
using Scrummer.Code.Controls; using Scrummer.Code.Controls;
namespace Scrummer.Code.Pages namespace Scrummer.Code.Pages
{ {
public class PageCommon : Page public class PageCommon : Page
{ {
#region Declarations #region Declarations
private HtmlHead _head; private HtmlHead _head;
private HtmlGenericControl _body; private HtmlGenericControl _body;
private HtmlForm _form; private HtmlForm _form;
private Panel _pnlContainer = new Panel(); private Panel _pnlContainer = new Panel();
#endregion #endregion
#region Properties #region Properties
public new ControlCollection Controls public new ControlCollection Controls
{ {
get { return _pnlContainer.Controls; } get { return _pnlContainer.Controls; }
} }
#endregion #endregion
#region Life cycle #region Life cycle
public PageCommon() public PageCommon()
{ {
Init += PageCommon_Init; Init += PageCommon_Init;
PreRender += PageCommon_PreRender; PreRender += PageCommon_PreRender;
} }
void PageCommon_Init(object sender, EventArgs e) void PageCommon_Init(object sender, EventArgs e)
{ {
CreateControls(); CreateControls();
} }
void PageCommon_PreRender(object sender, EventArgs e) void PageCommon_PreRender(object sender, EventArgs e)
{ {
_head.Title = string.IsNullOrEmpty(Title) ? Globals.Title : String.Format("{0}{1}{2}", Globals.Title, Globals.TitleSeparator, Title); _head.Title = string.IsNullOrEmpty(Title) ? Globals.Title : String.Format("{0}{1}{2}", Globals.Title, Globals.TitleSeparator, Title);
} }
#endregion #endregion
#region Private methods #region Private methods
private void CreateControls() private void CreateControls()
{ {
Context.Response.Charset = Encoding.UTF8.WebName; Context.Response.Charset = Encoding.UTF8.WebName;
var doctype = new LiteralControl("<!DOCTYPE html>\n"); var doctype = new LiteralControl("<!DOCTYPE html>\n");
base.Controls.Add(doctype); base.Controls.Add(doctype);
var html = new HtmlGenericControl("html"); var html = new HtmlGenericControl("html");
base.Controls.Add(html); base.Controls.Add(html);
_head = new HtmlHead(); _head = new HtmlHead();
html.Controls.Add(_head); html.Controls.Add(_head);
_head.Controls.Add(new HtmlMeta { HttpEquiv = "content-type", Content = "text/html; charset=utf-8" }); _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 = "author", Content = Globals.Author });
_head.Controls.Add(new HtmlMeta { Name = "Copyright", Content = Globals.Copyright }); _head.Controls.Add(new HtmlMeta { Name = "Copyright", Content = Globals.Copyright });
Assembly asm = Assembly.GetExecutingAssembly(); Assembly asm = Assembly.GetExecutingAssembly();
string version = asm.GetName().Version.ToString(); 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("<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))); _head.Controls.Add(new LiteralControl(String.Format("<link href=\"StylesBundler?t={0}\" type=\"text/css\" rel=\"stylesheet\"/>\n", version)));
_body = new HtmlGenericControl("body"); _body = new HtmlGenericControl("body");
html.Controls.Add(_body); html.Controls.Add(_body);
_form = new HtmlForm { ID = "formMain" }; _form = new HtmlForm { ID = "formMain" };
_body.Controls.Add(_form); _body.Controls.Add(_form);
var pnlHeader = new Panel { CssClass = "divHeader" }; var pnlHeader = new Panel { CssClass = "divHeader" };
_form.Controls.Add(pnlHeader); _form.Controls.Add(pnlHeader);
var lblTitle = new CLabel { Text = Globals.Title, Tag = "h1" }; var lblTitle = new CLabel { Text = Globals.Title, Tag = "h1" };
pnlHeader.Controls.Add(lblTitle); pnlHeader.Controls.Add(lblTitle);
_pnlContainer.CssClass = "divContent"; _pnlContainer.CssClass = "divContent";
_form.Controls.Add(_pnlContainer); _form.Controls.Add(_pnlContainer);
} }
#endregion #endregion
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,34 +1,33 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information
// set of attributes. Change these attribute values to modify the information // associated with an assembly.
// associated with an assembly. [assembly: AssemblyTitle("Scrummer")]
[assembly: AssemblyTitle("Scrummer")] [assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("VAR")]
[assembly: AssemblyCompany("VAR")] [assembly: AssemblyProduct("Scrummer")]
[assembly: AssemblyProduct("Scrummer")] [assembly: AssemblyCopyright("Copyright © VAR 2015")]
[assembly: AssemblyCopyright("Copyright © VAR 2015")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// 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
// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type.
// COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)]
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
// The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("4cd25e9d-237f-4a9f-89ac-35e537cf265e")]
[assembly: Guid("4cd25e9d-237f-4a9f-89ac-35e537cf265e")]
// Version information for an assembly consists of the following four values:
// Version information for an assembly consists of the following four values: //
// // Major Version
// Major Version // Minor Version
// Minor Version // Build Number
// Build Number // Revision
// Revision //
// // You can specify all the values or you can default the Revision and Build Numbers
// You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below:
// by using the '*' as shown below: [assembly: AssemblyVersion("1.0.*")]
[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) { function GetElement(element) {
if (typeof element == "string") { if (typeof element == "string") {
element = document.getElementById(element); element = document.getElementById(element);
} }
return element; return element;
} }
function escapeHTML(s) { function escapeHTML(s) {
return s.replace(/&/g, '&amp;') return s.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;') .replace(/"/g, '&quot;')
.replace(/</g, '&lt;') .replace(/</g, '&lt;')
.replace(/>/g, '&gt;'); .replace(/>/g, '&gt;');
} }
function fixedEncodeURIComponent(str) { function fixedEncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16); return '%' + c.charCodeAt(0).toString(16);
}); });
} }

View File

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

View File

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

View File

@@ -1,133 +1,124 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <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')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion> <ProductVersion>
</ProductVersion> </ProductVersion>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7596FD6B-DAF0-4B22-B356-5CF4629F0436}</ProjectGuid> <ProjectGuid>{7596FD6B-DAF0-4B22-B356-5CF4629F0436}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Scrummer</RootNamespace> <RootNamespace>Scrummer</RootNamespace>
<AssemblyName>Scrummer</AssemblyName> <AssemblyName>Scrummer</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress> <UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort /> <IISExpressSSLPort />
<IISExpressAnonymousAuthentication /> <IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication /> <IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode /> <IISExpressUseClassicPipelineMode />
</PropertyGroup> <TargetFrameworkProfile />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> </PropertyGroup>
<DebugSymbols>true</DebugSymbols> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType> <DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize> <DebugType>full</DebugType>
<OutputPath>bin\</OutputPath> <Optimize>false</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants> <OutputPath>bin\</OutputPath>
<ErrorReport>prompt</ErrorReport> <DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>4</WarningLevel> <ErrorReport>prompt</ErrorReport>
</PropertyGroup> <WarningLevel>4</WarningLevel>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> </PropertyGroup>
<DebugType>pdbonly</DebugType> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize> <DebugType>pdbonly</DebugType>
<OutputPath>bin\</OutputPath> <Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants> <OutputPath>bin\</OutputPath>
<ErrorReport>prompt</ErrorReport> <DefineConstants>TRACE</DefineConstants>
<WarningLevel>4</WarningLevel> <ErrorReport>prompt</ErrorReport>
</PropertyGroup> <WarningLevel>4</WarningLevel>
<ItemGroup> </PropertyGroup>
<Reference Include="Microsoft.CSharp" /> <ItemGroup>
<Reference Include="System.Net.Http" /> <Reference Include="System" />
<Reference Include="System.Web.DynamicData" /> <Reference Include="System.Drawing" />
<Reference Include="System.Web.Entity" /> <Reference Include="System.Web" />
<Reference Include="System.Web.ApplicationServices" /> <Reference Include="System.Configuration" />
<Reference Include="System.ComponentModel.DataAnnotations" /> </ItemGroup>
<Reference Include="System" /> <ItemGroup>
<Reference Include="System.Data" /> <Content Include="Scripts\01. Base.js" />
<Reference Include="System.Core" /> <None Include="Properties\PublishProfiles\Scrummer.pubxml" />
<Reference Include="System.Data.DataSetExtensions" /> <None Include="Web.Debug.config">
<Reference Include="System.Web.Extensions" /> <DependentUpon>Web.config</DependentUpon>
<Reference Include="System.Xml.Linq" /> <SubType>Designer</SubType>
<Reference Include="System.Drawing" /> </None>
<Reference Include="System.Web" /> <None Include="Web.Release.config">
<Reference Include="System.Xml" /> <DependentUpon>Web.config</DependentUpon>
<Reference Include="System.Configuration" /> <SubType>Designer</SubType>
<Reference Include="System.Web.Services" /> </None>
<Reference Include="System.EnterpriseServices" /> </ItemGroup>
</ItemGroup> <ItemGroup>
<ItemGroup> <Content Include="Scripts\02. Ajax.js" />
<Content Include="Scripts\01. Base.js" /> <Content Include="Scripts\10. Chat.js" />
<None Include="Web.Debug.config"> <Content Include="Styles\01. base.css" />
<DependentUpon>Web.config</DependentUpon> <Content Include="Styles\10. Chat.css" />
<SubType>Designer</SubType> <Content Include="Web.config" />
</None> </ItemGroup>
<None Include="Web.Release.config"> <ItemGroup>
<DependentUpon>Web.config</DependentUpon> <Compile Include="Code\Bundler.cs" />
<SubType>Designer</SubType> <Compile Include="Code\Controls\ChatControl.cs" />
</None> <Compile Include="Code\Controls\ChatHandler.cs" />
</ItemGroup> <Compile Include="Code\Controls\CLabel.cs" />
<ItemGroup> <Compile Include="Code\GlobalErrorHandler.cs" />
<Content Include="Scripts\02. Ajax.js" /> <Compile Include="Code\JSON\ParserContext.cs" />
<Content Include="Scripts\10. Chat.js" /> <Compile Include="Code\Pages\FrmBoard.cs">
<Content Include="Styles\01. base.css" /> <SubType>ASPXCodeBehind</SubType>
<Content Include="Styles\10. Chat.css" /> </Compile>
<Content Include="Web.config" /> <Compile Include="Code\Pages\FrmEcho.cs" />
</ItemGroup> <Compile Include="Code\Pages\PageCommon.cs">
<ItemGroup> <SubType>ASPXCodeBehind</SubType>
<Compile Include="Code\Bundler.cs" /> </Compile>
<Compile Include="Code\Controls\ChatControl.cs" /> <Compile Include="Code\ScriptsBundler.cs" />
<Compile Include="Code\Controls\ChatHandler.cs" /> <Compile Include="Code\StylesBundler.cs" />
<Compile Include="Code\Controls\CLabel.cs" /> <Compile Include="GlobalRouter.cs" />
<Compile Include="Code\GlobalErrorHandler.cs" /> <Compile Include="Code\JSON\JSONParser.cs" />
<Compile Include="Code\JSON\ParserContext.cs" /> <Compile Include="Code\JSON\JSONWriter.cs" />
<Compile Include="Code\Pages\FrmEcho.cs" /> <Compile Include="Code\Pages\FrmError.cs">
<Compile Include="Code\Pages\PageCommon.cs"> <SubType>ASPXCodeBehind</SubType>
<SubType>ASPXCodeBehind</SubType> </Compile>
</Compile> <Compile Include="Globals.cs" />
<Compile Include="Code\ScriptsBundler.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Code\StylesBundler.cs" /> </ItemGroup>
<Compile Include="GlobalRouter.cs" /> <ItemGroup />
<Compile Include="Code\JSON\JSONParser.cs" /> <PropertyGroup>
<Compile Include="Code\JSON\JSONWriter.cs" /> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<Compile Include="Code\Pages\FrmError.cs"> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<SubType>ASPXCodeBehind</SubType> </PropertyGroup>
</Compile> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Compile Include="Globals.cs" /> <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
</ItemGroup> <ProjectExtensions>
<ItemGroup /> <VisualStudio>
<PropertyGroup> <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> <WebProjectProperties>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> <UseIIS>True</UseIIS>
</PropertyGroup> <AutoAssignPort>True</AutoAssignPort>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <DevelopmentServerPort>51559</DevelopmentServerPort>
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" /> <DevelopmentServerVPath>/</DevelopmentServerVPath>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" /> <IISUrl>http://localhost:51555/</IISUrl>
<ProjectExtensions> <NTLMAuthentication>False</NTLMAuthentication>
<VisualStudio> <UseCustomServer>False</UseCustomServer>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}"> <CustomServerUrl>
<WebProjectProperties> </CustomServerUrl>
<UseIIS>True</UseIIS> <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
<AutoAssignPort>True</AutoAssignPort> </WebProjectProperties>
<DevelopmentServerPort>51559</DevelopmentServerPort> </FlavorProperties>
<DevelopmentServerVPath>/</DevelopmentServerVPath> </VisualStudio>
<IISUrl>http://localhost:51555/</IISUrl> </ProjectExtensions>
<NTLMAuthentication>False</NTLMAuthentication> <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<UseCustomServer>False</UseCustomServer> Other similar extension points exist, see Microsoft.Common.targets.
<CustomServerUrl> <Target Name="BeforeBuild">
</CustomServerUrl> </Target>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> <Target Name="AfterBuild">
</WebProjectProperties> </Target>
</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> </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; } * {
margin: 0;
body { padding: 0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; box-sizing: border-box;
font-size: 12px; }
background-color: grey;
color: black; body {
} font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 12px;
p{ background-color: grey;
margin-bottom: 0.5em; color: black;
text-shadow: 0 1px 1px rgba(255,255,255,0.5); }
}
p {
h1 { margin-bottom: 0.5em;
font-size: 1.7em; text-shadow: 0 1px 1px rgba(255,255,255,0.5);
text-align: center; }
margin-top: 1.0em;
margin-bottom: 0.5em; h1 {
text-shadow: 0 1px 1px rgba(255,255,255,0.5); font-size: 1.7em;
} text-align: center;
margin-top: 1.0em;
h2 { margin-bottom: 0.5em;
font-size: 1.5em; text-shadow: 0 1px 1px rgba(255,255,255,0.5);
text-align: center; }
margin-top: 1.0em;
margin-bottom: 0.5em; h2 {
text-shadow: 0 1px 1px rgba(255,255,255,0.5); font-size: 1.5em;
} text-align: center;
margin-top: 1.0em;
h3 { margin-bottom: 0.5em;
font-size: 1.2em; text-shadow: 0 1px 1px rgba(255,255,255,0.5);
text-align: left; }
margin-top: 1.0em;
margin-bottom: 0.5em; h3 {
text-shadow: 0 1px 1px rgba(255,255,255,0.5); font-size: 1.2em;
} text-align: left;
margin-top: 1.0em;
.divHeader { margin-bottom: 0.5em;
display: block; text-shadow: 0 1px 1px rgba(255,255,255,0.5);
background-color: black; }
}
.divHeader h1{ .divHeader {
font-size: 30px; display: block;
color: yellow; background-color: black;
margin: 0; }
text-shadow: none;
} .divHeader h1 {
font-size: 30px;
.divContent{ color: yellow;
padding-left:10px; margin: 0;
padding-right:10px; text-shadow: none;
} }
.divCode{ .divContent {
background-color: black; padding-left: 10px;
color: green; padding-right: 10px;
font-family: Courier New, Courier, monospace; }
text-shadow: none;
overflow:auto; .divCode {
margin: 5px; background-color: black;
padding: 2px; color: green;
box-shadow: 0 0 10px rgb(0,0,0); 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{ .divChatWindow {
box-sizing: border-box; box-sizing: border-box;
overflow: hidden; overflow: hidden;
border: solid 1px black; border: solid 1px black;
padding: 5px; padding: 5px;
border-radius: 5px; border-radius: 5px;
background-color: rgb(220,220,220); background-color: rgb(220,220,220);
box-shadow: 0px 0px 5px black; box-shadow: 0px 0px 5px black;
} }
.divChat { .divChat {
box-sizing: border-box; box-sizing: border-box;
overflow: auto; overflow: auto;
height: calc(100% - 37px); height: calc(100% - 37px);
margin-bottom: 5px; margin-bottom: 5px;
border-radius: 5px; border-radius: 5px;
border: solid 1px black; border: solid 1px black;
box-shadow: inset 0px 0px 5px black; box-shadow: inset 0px 0px 5px black;
} }
.messageRow, .messageRow,
.selfMessageRow{ .selfMessageRow {
vertical-align:top; vertical-align: top;
display:block; display: block;
} }
.messageRow {
text-align: left; .messageRow {
} text-align: left;
.selfMessageRow { }
text-align: right;
} .selfMessageRow {
.message { text-align: right;
box-sizing: border-box; }
display: inline-block;
vertical-align: top; .message {
border: solid 1px rgb(32, 32, 32); box-sizing: border-box;
background-color: rgb(220,220,220); display: inline-block;
border-radius: 5px; vertical-align: top;
box-shadow: border: solid 1px rgb(32, 32, 32);
0px 0px 10px rgba(0,0,0,0.5), background-color: rgb(220,220,220);
inset 0px 2px 5px rgba(255,255,255,0.5), border-radius: 5px;
inset 0px -2px 5px rgba(128,128,128,0.5); 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; margin: 2px;
padding: 5px; padding: 5px;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
} }
.messageRow .message {
background-color: rgb(220,200,200); .messageRow .message {
} background-color: rgb(220,200,200);
.selfMessageRow .message { }
background-color: rgb(200,220,200);
} .selfMessageRow .message {
background-color: rgb(200,220,200);
.message .user{ }
box-sizing: border-box;
color:rgb(64,64,64); .message .user {
text-shadow: 0 0 1px rgba(0,0,0,0.3); box-sizing: border-box;
font-size:10px; color: rgb(64,64,64);
font-weight:bold; text-shadow: 0 0 1px rgba(0,0,0,0.3);
} font-size: 10px;
.message .text{ font-weight: bold;
box-sizing: border-box; }
color:rgb(32,32,32);
text-shadow: 0 0 1px rgba(0,0,0,0.3); .message .text {
font-size:12px; box-sizing: border-box;
} color: rgb(32,32,32);
text-shadow: 0 0 1px rgba(0,0,0,0.3);
.divChatControls{ font-size: 12px;
}
}
.divChatControls {
.chatTextBox { }
box-sizing: border-box;
padding: 5px; .chatTextBox {
box-shadow: inset 0px 0px 5px black; box-sizing: border-box;
width: calc(100% - 52px); padding: 5px;
border-radius: 5px; box-shadow: inset 0px 0px 5px black;
border: solid 1px black; width: calc(100% - 52px);
margin: 0 2px 0 0; border-radius: 5px;
vertical-align: top; border: solid 1px black;
height: 30px; margin: 0 2px 0 0;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; vertical-align: top;
font-size: 12px; height: 30px;
text-align: left; font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
} font-size: 12px;
text-align: left;
}
.chatButton {
box-sizing: border-box;
padding: 5px; .chatButton {
box-shadow: box-sizing: border-box;
0px 0px 10px rgba(0,0,0,0.5), padding: 5px;
inset 0px 2px 5px rgba(255,255,255,1), 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);
inset 0px -2px 5px rgba(128,128,128,1); width: 50px;
width: 50px; vertical-align: top;
vertical-align: top; border-radius: 5px;
border-radius: 5px; border: solid 1px black;
border: solid 1px black; height: 30px;
height: 30px; font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; font-size: 12px;
font-size: 12px; text-align: center;
text-align: center; }
}

View File

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