Permalink
Browse files

Apply pep8 to js

  • Loading branch information...
1 parent 6c78e9b commit fa9e48f066be48030162e7cde8a713b838e9c6cb @Carreau committed Dec 1, 2011
Showing with 36 additions and 36 deletions.
  1. +36 −36 IPython/frontend/html/notebook/static/js/codecell.js
@@ -216,7 +216,7 @@ var IPython = (function (IPython) {
tooltip.append(expandlink);
tooltip.append(morelink);
if(defstring){
- defstring_html= $('<pre/>').html(utils.fixConsole(defstring));
+ defstring_html = $('<pre/>').html(utils.fixConsole(defstring));
tooltip.append(defstring_html);
}
tooltip.append(pre);
@@ -251,9 +251,9 @@ var IPython = (function (IPython) {
},
dismissAndAppend : function (code)
{
- chararr=['(',')','[',']','+','-','/','\\','.'];
- codearr=chararr.map(function(x){return x.charCodeAt(0)});
- return jQuery.inArray(code, codearr)!=-1;
+ chararr = ['(',')','[',']','+','-','/','\\','.'];
+ codearr = chararr.map(function(x){return x.charCodeAt(0)});
+ return jQuery.inArray(code, codearr) != -1;
}
}
@@ -264,25 +264,25 @@ var IPython = (function (IPython) {
{
kwargs = new Array();
other = new Array();
- for(var i=0;i<matches.length; ++i){
+ for(var i = 0 ; i<matches.length ; ++i){
if(matches[i].substr(-1) === '='){
kwargs.push(matches[i]);
}else{other.push(matches[i]);}
}
newm = kwargs.concat(other);
- matches=newm;
+ matches = newm;
}
// end sort kwargs
// give common prefix of a array of string
function sharedStart(A){
if(A.length > 1 ){
- var tem1, tem2, s, A= A.slice(0).sort();
- tem1= A[0];
- s= tem1.length;
- tem2= A.pop();
- while(s && tem2.indexOf(tem1)== -1){
- tem1= tem1.substring(0, --s);
+ var tem1, tem2, s, A = A.slice(0).sort();
+ tem1 = A[0];
+ s = tem1.length;
+ tem2 = A.pop();
+ while(s && tem2.indexOf(tem1) == -1){
+ tem1 = tem1.substring(0, --s);
}
return tem1;
}
@@ -292,8 +292,8 @@ var IPython = (function (IPython) {
//try to check if the user is typing tab at least twice after a word
// and completion is "done"
- fallback_on_tooltip_after=2
- if(matches.length==1 && matched_text === matches[0])
+ fallback_on_tooltip_after = 2
+ if(matches.length == 1 && matched_text === matches[0])
{
if(this.npressed >fallback_on_tooltip_after && this.prevmatch==matched_text)
{
@@ -303,13 +303,13 @@ var IPython = (function (IPython) {
this.request_tooltip_after_time(matched_text+'(',0,this);
return;
}
- this.prevmatch=matched_text
- this.npressed=this.npressed+1;
+ this.prevmatch = matched_text
+ this.npressed = this.npressed+1;
}
else
{
- this.prevmatch="";
- this.npressed=0;
+ this.prevmatch = "";
+ this.npressed = 0;
}
// end fallback on tooltip
//==================================
@@ -322,7 +322,7 @@ var IPython = (function (IPython) {
var close = function () {
if (done) return;
done = true;
- if (complete!=undefined)
+ if (complete != undefined)
{complete.remove();}
that.is_completing = false;
that.completion_cursor = null;
@@ -359,22 +359,22 @@ var IPython = (function (IPython) {
// Used to 'pick' when pressing tab
if (matches.length < 1) {
insert(typed_text,event);
- if(event !=null){
+ if(event != null){
event.stopPropagation();
event.preventDefault();
}
- } else if (autopick && matches.length==1) {
+ } else if (autopick && matches.length == 1) {
insert(matches[0],event);
- if(event !=null){
+ if(event != null){
event.stopPropagation();
event.preventDefault();
}
}
//clear the previous completion if any
complete.children().children().remove();
$('#asyoutype').text(typed_text);
- select=$('#asyoutypeselect');
- for (var i=0; i<matches.length; ++i) {
+ select = $('#asyoutypeselect');
+ for (var i = 0; i<matches.length; ++i) {
select.append($('<option/>').html(matches[i]));
}
select.children().first().attr('selected','true');
@@ -401,26 +401,26 @@ var IPython = (function (IPython) {
// So a first actual completion. see if all the completion start wit
// the same letter and complete if necessary
fastForward = sharedStart(matches)
- typed_characters= fastForward.substr(matched_text.length);
+ typed_characters = fastForward.substr(matched_text.length);
complete_with(matches,matched_text+typed_characters,true,null);
- filterd=matches;
+ filterd = matches;
// Give focus to select, and make it filter the match as the user type
// by filtering the previous matches. Called by .keypress and .keydown
var downandpress = function (event,press_or_down) {
var code = event.which;
var autopick = false; // auto 'pick' if only one match
if (press_or_down === 0){
- press=true; down=false; //Are we called from keypress or keydown
+ press = true; down = false; //Are we called from keypress or keydown
} else if (press_or_down == 1){
- press=false; down=true;
+ press = false; down = true;
}
if (code === key.shift) {
// nothing on Shift
return;
}
if (key.dismissAndAppend(code) && press) {
var newchar = String.fromCharCode(code);
- typed_characters=typed_characters+newchar;
+ typed_characters = typed_characters+newchar;
insert(matched_text+typed_characters,event);
return
}
@@ -433,16 +433,16 @@ var IPython = (function (IPython) {
// We don't want the document keydown handler to handle UP/DOWN,
// but we want the default action.
event.stopPropagation();
- } else if ( (code==key.backspace)||(code==key.tab && down) || press || key.isCompSymbol(code)){
+ } else if ( (code == key.backspace)||(code == key.tab && down) || press || key.isCompSymbol(code)){
if( key.isCompSymbol(code) && press)
{
var newchar = String.fromCharCode(code);
- typed_characters=typed_characters+newchar;
+ typed_characters = typed_characters+newchar;
} else if (code == key.tab) {
fastForward = sharedStart(filterd)
ffsub = fastForward.substr(matched_text.length+typed_characters.length);
- typed_characters=typed_characters+ffsub;
- autopick=true;
+ typed_characters = typed_characters+ffsub;
+ autopick = true;
event.stopPropagation();
event.preventDefault();
} else if (code == key.backspace && down) {
@@ -453,17 +453,17 @@ var IPython = (function (IPython) {
insert(matched_text,event)
return
}
- typed_characters=typed_characters.substr(0,typed_characters.length-1);
+ typed_characters = typed_characters.substr(0,typed_characters.length-1);
} else if (press && code != key.backspace && code != key.tab && code != 0){
insert(matched_text+typed_characters,event);
return
} else {
- return
+ return
}
re = new RegExp("^"+"\%?"+matched_text+typed_characters,"");
filterd = matches.filter(function(x){return re.test(x)});
complete_with(filterd,matched_text+typed_characters,autopick,event);
- } else if( press || code==key.esc){ // abort only on .keypress or esc
+ } else if( press || code == key.esc){ // abort only on .keypress or esc
// abort with what the user have pressed until now
console.log('aborting with keycode : '+code+' is down :'+down);
insert(matched_text+typed_characters,event);

0 comments on commit fa9e48f

Please sign in to comment.