Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysbrettbowen committed Jul 27, 2011
0 parents commit 2419a28
Show file tree
Hide file tree
Showing 16 changed files with 923 additions and 0 deletions.
52 changes: 52 additions & 0 deletions HTMLmod.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<body>
<textarea id="textarea" rows=20 cols=50></textarea>
<br>
<input type=button onClick='compute()' value='go'/>
<br>
<div id="result">
<script>
function findAllIndexes(regex,string){
var ret = [];
var last = 0;
while(r=regex.exec(string.substring(last))){
ret.push({string: r.toString(), index: r.index});
}
return ret;
}

function getClosest(num,arr){
for(var n=arr.length-1;arr[n]>num||n>=0;n--);
return arr[n];
}

function compute(){
var result ="";
value = document.getElementById("textarea").value.replace(/\r\f/g,"");

ss = findAllIndexes(/<\s*script[^>]*>/gi,value);
es = findAllIndexes(/<\/\s*script[^>]*>/gi,value);
//sc = findAllIndexes(/<\!--/g,value);
//ec = findAllIndexes(/-->/g,value);

for(i=0;i<ss.length-1;i++){
while(ss[i+1]&&ss[i+1].index<es[i].index)ss.splice(i+1,1);
}

start = 0;
for(i = 0; i<ss.length;i++){
if(ss[i].string.search(/\ssrc\s*=\s*/)>-1)
result += "document.write('"+value.substring(start,es[i].index+es[i].string.length).replace(/\\/g,'\\\\').replace(/'/g,"\\'").replace(/script/g,"scr'+'ipt").replace(/\n/g,"');\ndocument.write('")+"');\n";
else if(ss[i].string.search(/\stype\s*=\s*['"]?/)>-1&&ss[i].string.search(/\stype\s*=\s*['"]?text\/javascript/)<0)
result += "document.write('"+value.substring(start,es[i].index+es[i].string.length).replace(/\\/g,'\\\\').replace(/'/g,"\\'").replace(/script/g,"scr'+'ipt").replace(/\n/g,"');\ndocument.write('")+"');\n";
else
result += "document.write('"+value.substring(start,ss[i].index).replace(/\\/g,'\\\\').replace(/'/g,"\\'").replace(/\n/g,"');\ndocument.write('")+"');\n"+value.substring(ss[i].index+ss[i].string.length,es[i].index)+"\n";
start = es[i].index+es[i].string.length;
}
result += "document.write('"+value.substring(start).replace(/\\/g,'\\\\').replace(/'/g,"\\'").replace(/\n/,"');\ndocument.write('")+"');\n";

var ind = [];

document.getElementById("result").innerHTML = result.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>");
}
</script>
</body>
Empty file added README
Empty file.
Binary file added dump.rdb
Binary file not shown.
2 changes: 2 additions & 0 deletions files/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

this is the first creative
1 change: 1 addition & 0 deletions files/okay.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
t's okay!
22 changes: 22 additions & 0 deletions logger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var fs = require('fs');

function Logger(name){
this.ws = fs.createWriteStream(name,{flags:'a',encoding:null,mode:0666});
this.data = [];
}

Logger.prototype.endDay(newFile){
this.ws.end(data.join("\n"));
this.ws = fs.createWriteStream(newFile,{flags:'w',encoding:null,mode:0666});
this.data = [];
}

Logger.prototype.write(d){
this.data.push(d);
if(data.length>=1000){
data = [];
this.ws.write(this.data.join("\n"));
}
}

module.exports.Logger = Logger;
10 changes: 10 additions & 0 deletions mem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var net = require('net');



var socket = net.createConnection(11211);
socket.on('connect',function(){console.log("connected!");});

socket.on('data',function(data){console.log(data.toString());});
socket.write("hello\r\n");

Loading

0 comments on commit 2419a28

Please sign in to comment.