Permalink
Browse files

resolve conflict

  • Loading branch information...
1 parent de2bfb1 commit bc3260cd7a705c72c506031756dae40a340b0dcb @remy committed Aug 29, 2011
Showing with 113 additions and 9 deletions.
  1. +18 −5 console.css
  2. +94 −3 console.js
  3. +1 −1 index.html
View
@@ -61,12 +61,12 @@ iframe { display: none; }
/* input style - note: moz-shadow purposely omitted because it affects layout */
form { padding: 5px; border-bottom: 1px solid #AAABB8; background: #E6E8F2; -webkit-box-shadow: 0px 2px 10px rgba(0,0,0,.3); -o-box-shadow: 0px 2px 10px rgba(0,0,0,.3); box-shadow: 0px 2px 10px rgba(0,0,0,.3); }
-#exec { resize: none; position: absolute; left: 0; right: 0; border: 0; /*padding: 5px; */outline: 0; background: #E6E8F2; color: #000; height: 24px; line-height: 24px; overflow: hidden; }
+#exec, .fakeInput { resize: none; position: absolute; left: 0; right: 0; border: 0; /*padding: 5px; */outline: 0; background: #E6E8F2; color: #000; height: 24px; line-height: 24px; overflow: hidden; }
/* HACK */
form { position: fixed; top: 0; width: 100%; z-index: 2; }
#console { padding-top: 35px; }
-#exec { position: relative; height: auto; }
+#exec, .fakeInput { position: relative; height: auto; }
/* footer, credit, etc */
#footer { position: fixed; bottom: 0; left: 0; right: 0; height: 34px; background-color: #9E9E9E; color: #9E9F9E; color: rgba(158, 158, 158, 0.5); width: 100%; color: #fff; text-shadow: 1px 1px 0 #000; line-height: 24px; border-top: 1px solid #CED1CE; -webkit-transition: background-color ease-out 100ms; -moz-transition: background-color ease-out 100ms; -o-transition: background-color ease-out 100ms; transition: background-color ease-out 100ms; }
@@ -75,15 +75,15 @@ form { position: fixed; top: 0; width: 100%; z-index: 2; }
/* font size control */
/*#console { top: 35px; bottom: 35px; }*/
-#output li, #exec { min-height: 20px; font-size: 15px; font-family: "Menlo", consolas, monospace; }
+#output li, #exec, .fakeInput { min-height: 20px; font-size: 15px; font-family: "Menlo", consolas, monospace; }
/* code complete visual tweaks */
#cursor { display: inline-block; height: 24px; min-width: 1px; outline: 0; top: 0; left: 0; z-index: 999;}
/* HACK */
#cursor { height: auto; white-space: pre-wrap; }
-#exec { cursor: text; }
+#exec, .fakeInput { cursor: text; }
#exec .suggest { color: #999; }
/* large command input */
@@ -129,6 +129,19 @@ body.large #cursor { padding: 5px; }
#footer:hover {
opacity: 1;
}
+
+.fakeInput {
+ display: block;
+ position: absolute;
+ top: 0;
+ left: 0;
+ padding: 5px;
+ border: 0;
+ color: red;
+ opacity: 0.5;
+ /* pointer-events: auto !important;*/
+}
+
/*#footer {
-webkit-animation-name: hidefooter;
-webkit-animation-duration: 200ms;
@@ -164,7 +177,7 @@ body.large #cursor { padding: 5px; }
#output .echo .permalink { width: 18px; height: 20px; }
#footer { display: none; }
- #exec { font-weight: bold; padding-right: 10px; }
+ #exec, .fakeInput { font-weight: bold; padding-right: 10px; }
#output li { min-height: 20px; font-size: 14px; padding: 2px 5px 0 5px; }
#output > li > div { margin-left: 12px; line-height: 20px; }
View
@@ -471,7 +471,9 @@ function codeComplete(event) {
which = whichKey(event),
cc,
props = [];
-
+
+ console.log(which);
+
if (cmd) {
// get the command without the dot to allow us to introspect
if (cmd.substr(-1) == '.') {
@@ -483,10 +485,8 @@ function codeComplete(event) {
} else {
props = getProps(parts.slice(0, parts.length - 1).join('.') || 'window', parts[parts.length - 1]);
}
-
if (props.length) {
if (which == 9) { // tabbing cycles through the code completion
-
// however if there's only one selection, it'll auto complete
if (props.length === 1) {
ccPosition = false;
@@ -495,6 +495,7 @@ function codeComplete(event) {
// backwards
ccPosition = ccPosition == 0 ? props.length - 1 : ccPosition-1;
} else {
+ console.log('inc prop position');
ccPosition = ccPosition == props.length - 1 ? 0 : ccPosition+1;
}
}
@@ -689,17 +690,31 @@ var exec = document.getElementById('exec'),
return 'Creating connection...';
}
},
+ fakeInput = null,
// I hate that I'm browser sniffing, but there's issues with Firefox and execCommand so code completion won't work
iOSMobile = navigator.userAgent.indexOf('AppleWebKit') !== -1 && navigator.userAgent.indexOf('Mobile') !== -1,
// TODO try and detect this - currently Firefox doesn't allow me to clear the contents :(
enableCC = navigator.userAgent.indexOf('AppleWebKit') !== -1 && navigator.userAgent.indexOf('Mobile') === -1 && navigator.userAgent.indexOf('iPhone OS 5_0') !== -1;
+if (iOSMobile) enableCC = true;
+
+iOSMobile = true;
+
if (enableCC) {
exec.parentNode.innerHTML = '<div autofocus id="exec" spellcheck="false"><span id="cursor" contenteditable></span></div>';
exec = document.getElementById('exec');
cursor = document.getElementById('cursor');
}
+if (iOSMobile) {
+ fakeInput = document.createElement('input');
+ fakeInput.className = 'fakeInput';
+ fakeInput.setAttribute('spellcheck', 'false');
+ fakeInput.setAttribute('autocorrect', 'off');
+ fakeInput.setAttribute('autocapitalize', 'off');
+ exec.parentNode.appendChild(fakeInput);
+}
+
if (!injected) {
body.appendChild(sandboxframe);
sandboxframe.setAttribute('id', 'sandbox');
@@ -774,6 +789,7 @@ exec.onkeyup = function (event) {
};
if (enableCC) {
+ // disabled for now
cursor.__onpaste = function (event) {
setTimeout(function () {
// this causes the field to lose focus - I'll leave it here for a while, see how we get on.
@@ -871,6 +887,81 @@ exec.onkeydown = function (event) {
}
};
+if (iOSMobile) {
+ fakeInput.onkeydown = function (event) {
+ var which = whichKey(event);
+
+ if (which == 13 || which == 10) {
+ removeSuggestion();
+ post(this.value);
+ this.value = '';
+ cursor.innerHTML = '';
+ return false;
+ }
+ };
+
+ fakeInput.onkeyup = function (event) {
+ cursor.innerHTML = cleanse(this.value);
+ var which = whichKey(event);
+ if (enableCC && which != 9 && which != 16) {
+ clearTimeout(codeCompleteTimer);
+ codeCompleteTimer = setTimeout(function () {
+ codeComplete(event);
+ }, 200);
+ }
+ };
+
+ var dblTapTimer = null,
+ taps = 0;
+
+ // fakeInput.onclick =
+ document.addEventListener('touchstart', function (event) {
+ console.log(event.target.innerHTML);
+ if (event.target.className == 'fakeInput') {
+ window.scrollTo(0,0);
+ console.log('ok: ' + ccPosition);
+ if (ccPosition !== false) {
+ clearTimeout(dblTapTimer);
+ taps++;
+
+ if (taps === 2) {
+ completeCode();
+ fakeInput.value = exec.textContent;
+ removeSuggestion();
+ } else {
+ dblTapTimer = setTimeout(function () {
+ taps = 0;
+ console.log('click');
+ codeComplete({ which: 9 });
+ }, 200);
+ }
+ }
+ // return false;
+ }
+ });
+ fakeInput.___ontouchstart = function (event) {
+ window.scrollTo(0,0);
+ console.log('ok: ' + ccPosition);
+ if (ccPosition !== false) {
+ clearTimeout(dblTapTimer);
+ taps++;
+
+ if (taps === 2) {
+ completeCode();
+ fakeInput.value = exec.textContent;
+ removeSuggestion();
+ } else {
+ dblTapTimer = setTimeout(function () {
+ taps = 0;
+ console.log('click');
+ codeComplete({ which: 9 });
+ }, 200);
+ }
+ }
+ return false;
+ }
+}
+
function completeCode(focus) {
var tmp = exec.textContent, l = tmp.length;
removeSuggestion();
View
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html lang="en" manifest="jsconsole.appcache">
+<html lang="en"> <!-- manifest="jsconsole.appcache"> -->
<head>
<meta charset="utf-8" />
<title>JavaScript console - for debugging JavaScript and remote debugging mobile web apps</title>

0 comments on commit bc3260c

Please sign in to comment.