Skip to content

Commit 468d8ca

Browse files
author
Philip Guo
committed
use jQuery function instead of indexOf
1 parent 06a23da commit 468d8ca

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

‎edu-python.js‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,6 @@ function assert(cond) {
6262
}
6363
}
6464

65-
// OMG WTF Internet Explorer, I HATE YOU!!!
66-
// Thanks to: http://soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/
67-
if (!Array.indexOf) {
68-
Array.prototype.indexOf = function(obj){
69-
for(var i=0; i<this.length; i++){
70-
if(this[i]==obj){
71-
return i;
72-
}
73-
}
74-
return -1;
75-
}
76-
}
77-
7865
// taken from http://www.toao.net/32-my-htmlspecialchars-function-for-javascript
7966
function htmlspecialchars(str) {
8067
if (typeof(str) == "string") {
@@ -583,8 +570,8 @@ function renderDataStructuresVersion2(curEntry, vizDiv) {
583570
var tbl = $(vizDiv + " #" + tableID);
584571

585572
// put return value at the VERY END (if it exists)
586-
var retvalIdx = orderedVarnames.indexOf('__return__');
587-
if (retvalIdx >= 0) {
573+
var retvalIdx = $.inArray('__return__', orderedVarnames); // more robust than indexOf()
574+
if (retvalIdx > -1) {
588575
orderedVarnames.splice(retvalIdx, 1);
589576
orderedVarnames.push('__return__');
590577
}

0 commit comments

Comments
 (0)