Permalink
Browse files

adding simple URL-based security

  • Loading branch information...
Default Username root
Default Username authored and root committed Mar 30, 2012
1 parent cdaf1b8 commit 45dc19c03363f812d0df37f576f0db192cc1d100
Showing with 129 additions and 99 deletions.
  1. +36 −34 public/index.css
  2. +8 −6 public/index.html
  3. +50 −20 public/index.js
  4. +33 −37 public/index.styl
  5. +1 −1 public/js/ace/ace.js
  6. +1 −1 public/js/theme-chaos.js
View
@@ -92,6 +92,42 @@ body {
background: #1a1a1a;
color: rgba(255,255,255,0.98);
}
+#topStatus {
+ position: absolute;
+ top: 8px;
+/*left: 10px; */
+ bottom: 35px;
+}
+#topProjName {
+ display: inline-block;
+ z-index: 0;
+ left: 190px;
+ top: 12px;
+ font-size: 10px;
+ font-weight: 400;
+ text-align: left;
+}
+#topSpaceLink {
+ display: inline-block;
+ padding: 4px;
+ padding-left: 14px;
+ font-size: 10px;
+ z-index: 1000;
+ cursor: pointer;
+ color: #000;
+ letter-spacing: 1px;
+}
+#topSpaceLink:hover {
+ background: #f10;
+ color: #fff;
+}
+#whoIAm {
+ font-family: Arial, sans-serif;
+ font-size: 10px;
+ color: #191919;
+ display: inline-block;
+ top: 12px;
+}
#logWindow {
position: absolute;
right: 15px;
@@ -154,32 +190,6 @@ body {
font-size: 11px;
text-align: right;
}
-#topProjName {
- position: absolute;
- z-index: 0;
- left: 190px;
- top: 12px;
- font-size: 10px;
- font-weight: 400;
- color: rgba(0,0,0,0.40);
- text-align: left;
-}
-#topSpaceLink {
- position: absolute;
- padding: 2px;
- font-size: 10px;
- z-index: 1000;
- cursor: pointer;
- color: #000;
- text-decoration: none;
- left: 10px;
- top: 10px;
- letter-spacing: 1px;
-}
-#topSpaceLink:hover {
- background: #f10;
- color: #fff;
-}
#editor {
margin: 0px;
position: absolute;
@@ -193,14 +203,6 @@ body {
font-family: "Inconsolata", "Courier New", monospace;
/*-webkit-font-smoothing: antialiased;*/
}
-#whoIAm {
- font-family: Arial, sans-serif;
- font-size: 10px;
- color: #191919;
- position: absolute;
- top: 12px;
- left: 115px;
-}
#whoAreThey {
font-family: Arial, sans-serif;
position: absolute;
View
@@ -53,12 +53,14 @@
<pre id="editor"></pre>
<div id="top">
- <a href='http://space.chaoscollective.org'><div id='topSpaceLink'>BACK TO SPACE</div></a>
- <div id="whoIAm"></div>
- <div id='topProjName'></div>
- <div id="whoAreThey" title="No one else is collaborating">0</div>
- <div id='notifications'></div>
- <div id='topMenu'>
+ <div id="topStatus">
+ <a href='http://space.chaoscollective.org'><div id='topSpaceLink'>BACK TO SPACE</div></a>
+ <div id="whoIAm"></div>
+ <div id='topProjName'></div>
+ </div>
+ <div id="whoAreThey" title="No one else is collaborating">0</div>
+ <div id='notifications'></div>
+ <div id='topMenu'>
<div class='topMenuItem' id='topMenu_CMD' onclick='toggleShiftShift();'><span>C</span>MD</div>
<div class='topMenuItem' id='topMenu_HUD' onclick='toggleHUD();'><span>H</span>UD</div>
<div class='topMenuItem' id='topMenu_LOG' onclick='toggleLog();'><span>L</span>OG</div>
View
@@ -505,7 +505,7 @@ now.c_processMessage = function(scope, type, message, fromUserId, fromUse
now.c_confirmProject = function(teamID){
now.teamID = teamID;
console.log("PROJECT: " + now.teamID);
- $("#topProjName").html("// <b>"+teamID+"</b>");
+ $("#topProjName").html("You're editing <b><a href='http://"+teamID+".chaoscollective.org/' target='_APP_"+teamID+"' style='text-decoration: none; color: #000;'>"+teamID+"</a></b>.");
}
// ---------------------------------------------------------
// Main functions...
@@ -594,7 +594,7 @@ function openFileFromServer(fname, forceOpen){
// addFold("...", new Range(8, 44, 13, 4));
ignoreAceChange = false;
editor.setReadOnly(false);
- autoFoldCode();
+ autoFoldCodeProgressive();
previousText = editor.getSession().getValue();
if(isSaved){
setFileStatusIndicator("saved");
@@ -916,7 +916,12 @@ function deleteFile(fname){
// ---------------------------------------------------------
// Code Folding, Cleaning, and other auto tools...
// ---------------------------------------------------------
-function autoFoldCode(){
+function autoFoldCode(levelToFold){
+ if(levelToFold == undefined){
+ levelToFold = 0;
+ }
+ console.log("folding code at level: " + levelToFold);
+ var level = 0;
console.log("Auto Folding all code...");
var lines = editor.getSession().getValue().split("\n");
//console.log(lines);
@@ -925,27 +930,41 @@ function autoFoldCode(){
//var iFn = lines[r].indexOf("function");
//if(iFn >= 0){
var iBracket = lines[r].lastIndexOf("{");
- if(iBracket > 0){
- // fold it!
- //console.log("Fold: row="+r+", col="+iBracket);
- var matchPos = editor.session.findMatchingBracket({row: r, column: iBracket+1});
- if(matchPos != null){
- var range = new Range(r, iBracket+1, matchPos.row, matchPos.column);
- //console.log(range);
- try {
- editor.session.addFold(" ... ", range);
- }catch(ex){
- console.log("AutoFold Exception: " + ex);
+ var jBracket = lines[r].lastIndexOf("}");
+ var commentA = lines[r].indexOf("//");
+ if(iBracket >= 0 && iBracket > jBracket && commentA < 0){
+ level++;
+ if(level > levelToFold){
+ // fold it!
+ //console.log("Fold: row="+r+", col="+iBracket);
+ var matchPos = editor.session.findMatchingBracket({row: r, column: iBracket+1});
+ if(matchPos != null){
+ var range = new Range(r, iBracket+1, matchPos.row, matchPos.column);
+ //console.log(range);
+ try {
+ editor.session.addFold(" ... ", range);
+ }catch(ex){
+ console.log("AutoFold Exception: " + ex);
+ }
+ //console.log(matchPos);
+ r = matchPos.row;
+ continue;
}
- //console.log(matchPos);
- r = matchPos.row;
- continue;
+ }
+ }else{
+ if(jBracket >= 0 && iBracket < 0 && commentA < 0){
+ level--;
}
}
//}
- }
+ }
console.log("Done folding code.");
}
+function autoFoldCodeProgressive(){
+ autoFoldCode(2);
+ autoFoldCode(1);
+ autoFoldCode(0);
+}
// ---------------------------------------------------------
// Shift+Shift
// ---------------------------------------------------------
@@ -1274,6 +1293,17 @@ function launchProject(){
// ---------------------------------------------------------
// URL manipulation.
// ---------------------------------------------------------
+function renameMyself(){
+ setName(prompt("What shall we call thee?"));
+ now.s_sendUserEvent("join"); // let everyone know who I am!
+}
+function setName(newName){
+ now.name = newName;
+ $("#whoIAm").html("// Hello, <b style='cursor: pointer;' onclick='renameMyself();'>"+now.name+"</b>.");
+}
+// ---------------------------------------------------------
+// URL manipulation.
+// ---------------------------------------------------------
function getURLGetVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
@@ -1356,7 +1386,7 @@ now.ready(function(){
setFileStatusIndicator("default");
});
console.log(now);
- $("#whoIAm").html("// Hello, <b>"+now.name+"</b>");
+ setName(now.name);
setTimeout(function(){
$("#logOutputIFrame").attr("src", "http://logs.chaoscollective.org/live?log="+now.teamID);
document.title = now.teamID;
@@ -1433,7 +1463,7 @@ $(window).ready(function() {
sender: 'editor'
},
exec: function(env, args, request) {
- autoFoldCode();
+ autoFoldCodeProgressive();
}
});
/*
View
@@ -97,10 +97,40 @@ body {
}
#topStatus {
position: absolute;
- top: 0px;
- left: 0px;
+ top: 8px;
+ /*left: 10px; */
bottom: 35px;
}
+#topProjName {
+ display: inline-block;
+ z-index: 0;
+ left: 190px;
+ top: 12px;
+ font-size: 10px;
+ font-weight: 400;
+ text-align: left;
+}
+#topSpaceLink {
+ display: inline-block;
+ padding: 4px;
+ padding-left: 14px;
+ font-size: 10px;
+ z-index: 1000;
+ cursor: pointer;
+ color: black;
+ letter-spacing: 1px;
+}
+#topSpaceLink:hover {
+ background: #F10;
+ color: #FFF;
+}
+#whoIAm {
+ font-family: Arial, sans-serif;
+ font-size: 10px;
+ color: #191919;
+ display: inline-block;
+ top: 12px;
+}
#logWindow {
position: absolute;
right: 15px;
@@ -163,33 +193,6 @@ body {
font-size: 11px;
text-align: right;
}
-#topProjName {
- position: absolute;
- z-index: 0;
- left: 190px;
- top: 12px;
- font-size: 10px;
- font-weight: 400;
- color: rgba(0, 0, 0, 0.4);
- text-align: left;
-}
-
-#topSpaceLink {
- position: absolute;
- padding: 2px;
- font-size: 10px;
- z-index: 1000;
- cursor: pointer;
- color: black;
- text-decoration: none;
- left: 10px;
- top: 10px;
- letter-spacing: 1px;
-}
-#topSpaceLink:hover {
- background: #F10;
- color: #FFF;
-}
#editor {
margin: 0px;
@@ -204,14 +207,7 @@ body {
font-family: "Inconsolata", "Courier New", monospace;
/*-webkit-font-smoothing: antialiased;*/
}
-#whoIAm {
- font-family: Arial, sans-serif;
- font-size: 10px;
- color: #191919;
- position: absolute;
- top: 12px;
- left: 115px;
-}
+
#whoAreThey {
font-family: Arial, sans-serif;
position: absolute;
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 45dc19c

Please sign in to comment.