Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: towski/blongo
base: fcfcb114e5
...
head fork: towski/blongo
compare: aca17922e1
Checking mergeability… Don't worry, you can still create the pull request.
  • 6 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
3  .nodemonignore
@@ -1,2 +1,3 @@
-
+*.html
db/*
+*.cached
View
18 ajax.js
@@ -1,8 +1,10 @@
+$(document).on('dom:loaded', function(){
+
new Ajax.Request('/application', {
method: 'get',
onSuccess: function(response){
var app = response.responseJSON
- if(!window.cached || app.authenticated){
+ if(!window.cached){
if($('logs')){
new Ajax.Request('/logs', {
onSuccess: function(response){
@@ -21,7 +23,9 @@ new Ajax.Request('/application', {
method: "get"
});
}
-
+ }
+
+ if(app.authenticated){
if($('edit-form')){
new Ajax.Request('/log', {
method: "get",
@@ -34,14 +38,22 @@ new Ajax.Request('/application', {
}
});
}
+
+ new Ajax.Updater('css-form', '/css-form.html', {
+ onComplete: function(){
+ $('css-text').value = buildCSS()
+ }
+ })
}
if(!window.cached && !app.authenticated){
setTimeout(function(){
new Ajax.Request('/cache', {
- parameters: { head: document.head.innerHTML, body: document.body.innerHTML }
+ parameters: { file: "index.html", body: document.body.innerHTML }
});
}, 1000);
}
}
+})
+
})
View
6 css-form.html
@@ -0,0 +1,6 @@
+<form id='css-form' action='/cache' onsubmit='addCSS(); return false; '>
+ <p><textarea rows=20 cols=100 id='css-text' name='content'></textarea></p>
+ Add CSS Rule:
+ <p>style:<input type='text' id='css-style'/> property:<input type='text' id='css-property'/> value:<input type='text' id='css-value'/><input type='submit' value='add'></p>
+</form>
+<input type='submit' onclick='submitCSS()'>
View
30 edit.html
@@ -1,14 +1,16 @@
-<html><head>
- <script src="/prototype.js" type="text/javascript"></script>
- <script src="/cookie.js" type="text/javascript"></script>
- <script src="/ajax.js" type="text/javascript"></script>
- <script src="/functions.js" type="text/javascript"></script>
-</head><body>
- <a href='/'>Home</a>
- <div id='log'></div>
- <form id='edit-form' action='/logs' onsubmit='submitForm(); return false;'>
- <input id='id' name='id' type='hidden'>
- <textarea rows=20 cols=100 id='text' name='content'></textarea>
- <input type='submit'>
- </form>
-</body></html>
+<a href='/'>Home</a>
+<div id='log'></div>
+<table>
+ <tr>
+ <td>
+<form id='edit-form' action='/logs' onsubmit='submitForm(); return false;'>
+ <input id='id' name='id' type='hidden'>
+ <p><textarea rows=20 cols=100 id='text' name='content'></textarea></p>
+ <input type='submit'>
+</form>
+</td>
+<td>
+ <div id='css-form'></div>
+</td>
+</tr>
+</table>
View
4 form.html
@@ -1,4 +0,0 @@
-<form id='form' action='/logs' onsubmit='submitForm(); return false; '>
- <textarea rows=20 cols=100 id='text' name='content'></textarea>
- <input type='submit'>
-</form>
View
59 functions.js
@@ -18,3 +18,62 @@ function submitForm(form) {
}
return false;
}
+
+
+function changeCSS(className , propertyName , value) {
+ if((className == '' ) || (propertyName == '' ) || (value == '' )) {
+ return ;
+ }
+
+ var propertyIndexName = false;
+ var falg = false;
+ var numberOfStyles = document.styleSheets.length
+
+ if (document.styleSheets[0]['rules']) {
+ propertyIndexName = 'rules';
+ } else if (document.styleSheets[0]['cssRules']) {
+ propertyIndexName = 'cssRules';
+ }
+
+ for (var i = 0; i < numberOfStyles; i++) {
+ for (var j = 0; j < document.styleSheets[i][propertyIndexName].length; j++) {
+ if (document.styleSheets[i][propertyIndexName][j].selectorText == className) {
+ if(document.styleSheets[i][propertyIndexName][j].style[propertyName]){
+ document.styleSheets[i][propertyIndexName][j].style[propertyName] = value;
+ falg=true;
+ break;
+ }
+ }
+ }
+ if(!falg){
+ if(document.styleSheets[i].insertRule){
+ document.styleSheets[i].insertRule(className+' { '+propertyName+': '+value+'; }',document.styleSheets[i][propertyIndexName].length);
+ } else if (document.styleSheets[i].addRule) {
+ document.styleSheets[i].addRule(className,propertyName+': '+value+';');
+ }
+ }
+ }
+}
+
+function buildCSS(){
+ var content = ""
+ $A(document.styleSheets[0]['rules']).each(function(rule){
+ content += rule.cssText + "\n\n"
+ })
+ return content
+}
+
+function addCSS(){
+ changeCSS($('css-style').value, $('css-property').value, $('css-value').value)
+ $('css-text').value = buildCSS()
+}
+
+function submitCSS(){
+ var location = document.location.href
+ new Ajax.Request('/cache', {
+ parameters: { file:"rules.css", body: $('css-text').value },
+ onSuccess: function(){
+ document.location.href = location
+ }
+ });
+}
View
9 index.html
@@ -1,10 +1,3 @@
-<html><head>
- <script src="/prototype.js" type="text/javascript"></script>
- <script src="/cookie.js" type="text/javascript"></script>
- <script src="/ajax.js" type="text/javascript"></script>
- <script src="/functions.js" type="text/javascript"></script>
-</head><body>
<h1>&lt; towski &gt;</h1>
<div id="logs"></div>
-<a href='/new.html'>new</a>
-</body></html>
+<a href='/new.html'>new</a>
View
21 new.html
@@ -1,14 +1,7 @@
-<html><head>
- <script src="/prototype.js" type="text/javascript"></script>
- <script src="/cookie.js" type="text/javascript"></script>
- <script src="/ajax.js" type="text/javascript"></script>
- <script src="/functions.js" type="text/javascript"></script>
-</head><body>
- <a href='/'>Home</a>
- <div id='log'></div>
- <form id='new-form' action='/logs' onsubmit='submitForm(); return false;'>
- <input id='id' name='id' type='hidden'>
- <textarea rows=20 cols=100 id='text' name='content'></textarea>
- <input type='submit'>
- </form>
-</body></html>
+<a href='/'>Home</a>
+<div id='log'></div>
+<form id='new-form' action='/logs' onsubmit='submitForm(); return false;'>
+ <input id='id' name='id' type='hidden'>
+ <textarea rows=20 cols=100 id='text' name='content'></textarea>
+ <input type='submit'>
+</form>
View
19 server.js
@@ -48,6 +48,7 @@ mongodb.connect(mongo_config, function(error, db){
db.collection('logs', function(error, collection){
collection.update({"_id": db.bson_serializer.ObjectID(match[1])}, {$set: {text: parsed.text}})
})
+ fs.unlink("index.html.cached")
res.writeHead(200, {'Content-Type': 'application/json'})
res.end()
});
@@ -85,8 +86,14 @@ mongodb.connect(mongo_config, function(error, db){
});
request.addListener('end', function(){
var parsed = qs.parse(content)
- fs.open('index.html.cached', 'w+', 0666, function(err, fd){
- var buffer = new Buffer("<html><head><script type='text/javascript'>var cached = true;</script>" + parsed.head + "</head><body>"+ parsed.body +"</body></html>")
+ fs.open(parsed.file + '.cached', 'w+', 0666, function(err, fd){
+ if(parsed.file.match(/.html$/)){
+ var buffer = new Buffer("<html><head><script type='text/javascript'>var cached = true;</script>" +
+ fs.readFileSync('head.html') +
+ "</head><body>" + parsed.body + "</body></html>")
+ } else {
+ var buffer = new Buffer(parsed.body)
+ }
fs.write(fd, buffer, 0, buffer.length)
})
res.writeHead(200, {'Content-Type': 'application/json'})
@@ -99,7 +106,11 @@ mongodb.connect(mongo_config, function(error, db){
fs.stat("." + path, function(err, stats){
res.writeHead(200, {'Content-Type': 'text/html'})
fs.readFile("." + path, function(err, data){
- res.end(data)
+ if(path.match(/.html$/)){
+ res.end("<html><head>" + fs.readFileSync('head.html') + "</head><body>" + data + "</body>")
+ } else {
+ res.end(data)
+ }
})
})
} else {
@@ -111,5 +122,5 @@ mongodb.connect(mongo_config, function(error, db){
})
}
}
- }).listen(10331)
+ }).listen(10336)
});

No commit comments for this range

Something went wrong with that request. Please try again.