Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
2a5a8eec
Commit
2a5a8eec
authored
Sep 09, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed chat_server dir in examples
parent
ceca52de
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
0 additions
and
530 deletions
+0
-530
favicon.ico
examples/chat_server/web_root/favicon.ico
+0
-0
index.html
examples/chat_server/web_root/index.html
+0
-73
jquery.js
examples/chat_server/web_root/jquery.js
+0
-154
login.html
examples/chat_server/web_root/login.html
+0
-43
logo.png
examples/chat_server/web_root/logo.png
+0
-0
main.js
examples/chat_server/web_root/main.js
+0
-106
style.css
examples/chat_server/web_root/style.css
+0
-154
No files found.
examples/chat_server/web_root/favicon.ico
deleted
100644 → 0
View file @
ceca52de
1.37 KB
examples/chat_server/web_root/index.html
deleted
100644 → 0
View file @
ceca52de
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
dir=
"ltr"
>
<!-- This file is part of the Mongoose project,
http://code.google.com/p/mongoose -->
<head>
<title>
Mongoose chat server
</title>
<meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/>
<link
type=
"text/css"
rel=
"stylesheet"
href=
"style.css"
/>
<script
src=
"jquery.js"
></script>
<script
src=
"main.js"
></script>
</head>
<body>
<div
id=
"header"
>
<div
id=
"logo"
></div>
<div
class=
"rounded infobox help-message"
id=
"motd"
>
Chat room implemented using
<a
href=
"http://code.google.com/p/mongoose"
target=
"_blank"
>
Mongoose
</a>
embeddable web server.
This application was written for educational purposes demonstrating
how web interface could be decoupled from the business logic. Not a
single line of HTML is generated by the server, instead, server
gives data to the client in JSON format.
</div>
</div>
<div>
<div
id=
"middle"
>
<div><center><span
id=
"error"
class=
"rounded"
></span><center></div>
<div
id=
"menu"
>
<div
class=
"menu-item left-rounded menu-item-selected"
name=
"chat"
>
Chat
</div>
<div
class=
"menu-item left-rounded"
name=
"settings"
>
Settings
</div>
</div>
<div
id=
"content"
class=
"rounded"
>
<div
id=
"chat"
class=
"main"
>
<div
class=
"chat-window"
>
<span
class=
"top-rounded chat-title"
>
Main room
</span>
<div
class=
"bottom-rounded chat-content"
>
<div
class=
"message-list"
id=
"mml"
>
</div>
<input
type=
"text"
size=
"40"
class=
"message-input"
></input>
<span
class=
"help-message"
>
Type your message here and press enter
</span>
</div>
</div>
</div>
<div
id=
"settings"
class=
"hidden main"
>
<div>
<span
class=
"top-rounded chat-title"
>
Settings
</span>
<div
class=
"bottom-rounded chat-content"
>
<table>
<tr><td>
Max messages to display:
</td><td>
blah blah
</td></tr>
<tr><td>
Text color:
</td><td>
blah blah
</td></tr>
</table>
</div>
</div>
</div>
</div>
</div>
<div
id=
"footer"
>
Copyright
©
2004-2010 by Sergey Lyubka
</div>
</body>
</html>
examples/chat_server/web_root/jquery.js
deleted
100644 → 0
View file @
ceca52de
This diff is collapsed.
Click to expand it.
examples/chat_server/web_root/login.html
deleted
100644 → 0
View file @
ceca52de
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
dir=
"ltr"
>
<!-- This file is part of the Mongoose project,
http://code.google.com/p/mongoose -->
<head>
<title>
Mongoose chat: login
</title>
<meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/>
<!--
Note that this page is self-sufficient, it does not load any other
CSS or Javascript file. This is done so because only this page is
allowed for non-authorized users. If we want to load other files
from the frontend, we need to change backend code to allow those
for non-authorized users. See chat.c :: must_authorize() function.
-->
</head>
<script>
window
.
onload
=
function
()
{
// Set correct action for the login form. We assume that the SSL port
// is the next one to insecure one.
var
httpsPort
=
location
.
protocol
.
match
(
/https/
)
?
location
.
port
:
parseInt
(
location
.
port
)
+
1
;
document
.
forms
[
0
].
action
=
'https://'
+
location
.
hostname
+
':'
+
httpsPort
+
'/authorize'
;
};
</script>
<body>
<center>
<h2>
Mongoose chat server login
</h2>
<div
style=
"max-width: 30em;"
>
Username and password can be any non-empty strings.
</div>
<br/>
<form>
<input
type=
"text"
name=
"user"
></input><br/>
<input
type=
"text"
name=
"password"
></input><br/>
<input
type=
"submit"
value=
"Login"
></input>
</form>
</center>
</body>
</html>
examples/chat_server/web_root/logo.png
deleted
100644 → 0
View file @
ceca52de
1.56 KB
examples/chat_server/web_root/main.js
deleted
100644 → 0
View file @
ceca52de
// This file is part of Mongoose project, http://code.google.com/p/mongoose
var
chat
=
{
// Backend URL, string.
// 'http://backend.address.com' or '' if backend is the same as frontend
backendUrl
:
'api.lp'
,
maxVisibleMessages
:
10
,
errorMessageFadeOutTimeoutMs
:
2000
,
errorMessageFadeOutTimer
:
null
,
lastMessageId
:
0
,
getMessagesIntervalMs
:
1000
,
};
chat
.
normalizeText
=
function
(
text
)
{
return
text
.
replace
(
'<'
,
'<'
).
replace
(
'>'
,
'>'
);
};
chat
.
refresh
=
function
(
data
)
{
if
(
data
===
undefined
)
{
return
;
}
$
.
each
(
data
,
function
(
index
,
entry
)
{
var
row
=
$
(
'<div>'
).
addClass
(
'message-row'
).
appendTo
(
'#mml'
);
var
timestamp
=
(
new
Date
(
entry
.
timestamp
*
1000
)).
toLocaleTimeString
();
$
(
'<span>'
)
.
addClass
(
'message-timestamp'
)
.
html
(
'['
+
timestamp
+
']'
)
.
prependTo
(
row
);
$
(
'<span>'
)
.
addClass
(
'message-user'
)
.
addClass
(
entry
.
user
?
''
:
'message-user-server'
)
.
html
(
chat
.
normalizeText
((
entry
.
user
||
'[server]'
)
+
':'
))
.
appendTo
(
row
);
$
(
'<span>'
)
.
addClass
(
'message-text'
)
.
addClass
(
entry
.
user
?
''
:
'message-text-server'
)
.
html
(
chat
.
normalizeText
(
entry
.
text
))
.
appendTo
(
row
);
chat
.
lastMessageId
=
Math
.
max
(
chat
.
lastMessageId
,
entry
.
id
)
+
1
;
});
// Keep only chat.maxVisibleMessages, delete older ones.
while
(
$
(
'#mml'
).
children
().
length
>
chat
.
maxVisibleMessages
)
{
$
(
'#mml div:first-child'
).
remove
();
}
};
chat
.
getMessages
=
function
(
enter_loop
)
{
$
.
ajax
({
data
:
{
last_id
:
chat
.
lastMessageId
,
cmd
:
'get_messages'
},
success
:
chat
.
refresh
,
error
:
function
()
{
},
});
if
(
enter_loop
)
{
window
.
setTimeout
(
'chat.getMessages(true)'
,
chat
.
getMessagesIntervalMs
);
}
};
chat
.
handleMenuItemClick
=
function
(
ev
)
{
$
(
'.menu-item'
).
removeClass
(
'menu-item-selected'
);
// Deselect menu buttons
$
(
this
).
addClass
(
'menu-item-selected'
);
// Select clicked button
$
(
'.main'
).
addClass
(
'hidden'
);
// Hide all main windows
$
(
'#'
+
$
(
this
).
attr
(
'name'
)).
removeClass
(
'hidden'
);
// Show main window
};
chat
.
showError
=
function
(
message
)
{
$
(
'#error'
).
html
(
message
).
fadeIn
(
'fast'
);
window
.
clearTimeout
(
chat
.
errorMessageFadeOutTimer
);
chat
.
errorMessageFadeOutTimer
=
window
.
setTimeout
(
function
()
{
$
(
'#error'
).
fadeOut
(
'slow'
);
},
chat
.
errorMessageFadeOutTimeoutMs
);
};
chat
.
handleMessageInput
=
function
(
ev
)
{
var
input
=
ev
.
target
;
if
(
ev
.
keyCode
!=
13
||
!
input
.
value
)
return
;
//input.disabled = true;
$
.
ajax
({
data
:
{
text
:
input
.
value
,
cmd
:
'send_message'
},
success
:
function
(
ev
)
{
input
.
value
=
''
;
input
.
disabled
=
false
;
chat
.
getMessages
(
false
);
},
error
:
function
(
ev
)
{
chat
.
showError
(
'Error sending message'
);
input
.
disabled
=
false
;
},
});
};
$
(
document
).
ready
(
function
()
{
$
.
ajaxSetup
({
dataType
:
'json'
,
url
:
chat
.
backendUrl
});
$
(
'.menu-item'
).
click
(
chat
.
handleMenuItemClick
);
$
(
'.message-input'
).
keypress
(
chat
.
handleMessageInput
);
chat
.
getMessages
(
true
);
});
// vim:ts=2:sw=2:et
examples/chat_server/web_root/style.css
deleted
100644 → 0
View file @
ceca52de
/*
* vim:ts=2:sw=2:et:ai
*/
body
{
font
:
13px
Arial
;
margin
:
0.5em
1em
;
}
#logo
{
background
:
url('logo.png')
no-repeat
;
width
:
160px
;
height
:
40px
;
float
:
left
;
}
td
{
text-align
:
left
;
}
#motd
{
margin-left
:
170px
;
}
.infobox
{
background
:
#eed
;
padding
:
1px
1em
;
}
.help-message
{
color
:
#aaa
;
}
#middle
{
margin
:
0.5em
0
;
}
#error
{
background
:
#c44
;
color
:
white
;
font-weight
:
bold
;
}
#content
,
.menu-item-selected
,
.chat-title
,
.chat-content
{
background
:
#c3d9ff
;
}
#content
{
overflow
:
hidden
;
min-height
:
7em
;
padding
:
1em
;
}
.chat-title
{
padding
:
1px
1ex
;
}
.chat-content
{
padding
:
1ex
;
}
.chat-window
{
}
.message-row
{
margin
:
2px
;
border-bottom
:
1px
solid
#bbb
;
}
.message-timestamp
{
color
:
#484
;
}
.message-user
{
margin-left
:
0.5em
;
font-weight
:
bold
;
}
.message-text
{
margin-left
:
0.5em
;
}
.message-user-server
{
color
:
purple
;
}
.message-text-server
{
font-style
:
italic
;
}
.main
{
padding
:
0.5em
;
background
:
#f0fcff
;
}
#menu
{
margin-top
:
1em
;
min-width
:
7em
;
float
:
left
;
}
#footer
{
position
:
fixed
;
bottom
:
0
;
right
:
0
;
color
:
#ccc
;
padding
:
0.5em
;
}
.section
{
clear
:
both
;
}
.hidden
{
display
:
none
;
}
.menu-item
{
cursor
:
pointer
;
padding
:
0.1em
0.5em
;
}
.menu-item-selected
{
font-weight
:
bold
;
}
.message-list
{
min-height
:
1em
;
background
:
white
;
margin
:
0.5em
0
;
}
.rounded
{
border-radius
:
6px
;
-moz-border-radius
:
6px
;
-webkit-border-radius
:
6px
;
}
.left-rounded
{
border-radius
:
6px
0
0
6px
;
-moz-border-radius
:
6px
0
0
6px
;
-webkit-border-radius
:
6px
0
0
6px
;
}
.bottom-rounded
{
border-radius
:
0
0
6px
6px
;
-moz-border-radius
:
0
0
6px
6px
;
-webkit-border-radius
:
0
0
6px
6px
;
}
.top-rounded
{
border-radius
:
6px
6px
0
0
;
-moz-border-radius
:
6px
6px
0
0
;
-webkit-border-radius
:
6px
6px
0
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment