@@ -1950,7 +1950,7 @@ var ICEcoder = {
1950
1950
1951
1951
if ( "/[NEW]" !== shortURL ) {
1952
1952
fileLink = fileLink . replace ( / \/ / g, "|" ) ;
1953
- this . serverQueue ( "add" , iceLoc + "/lib/file-control.php?action=load&file=" + encodeURIComponent ( fileLink ) + "&csrf=" + this . csrf + "&lineNumber=" + line ) ;
1953
+ this . serverQueue ( "add" , iceLoc + "/lib/file-control.php?action=load&file=" + encodeURIComponent ( fileLink ) + "&csrf=" + this . csrf + "&lineNumber=" + line , encodeURIComponent ( fileLink ) ) ;
1954
1954
this . serverMessage ( '<b>' + t [ 'Opening File' ] + '</b> ' + shortURL . substr ( shortURL . lastIndexOf ( "/" ) + 1 ) ) ;
1955
1955
} else {
1956
1956
this . createNewTab ( true , shortURL ) ;
@@ -2348,7 +2348,7 @@ var ICEcoder = {
2348
2348
console . log ( "ICEcoder error info for your request..." ) ;
2349
2349
console . log ( statusObj ) ;
2350
2350
ICEcoder . serverMessage ( ) ;
2351
- ICEcoder . serverQueue ( 'del' , 0 ) ;
2351
+ ICEcoder . serverQueue ( 'del' ) ;
2352
2352
} else {
2353
2353
eval ( statusObj . action . doNext ) ;
2354
2354
}
@@ -2358,7 +2358,7 @@ var ICEcoder = {
2358
2358
console . log ( "ICEcoder error info for your request..." ) ;
2359
2359
console . log ( statusObj ) ;
2360
2360
ICEcoder . serverMessage ( ) ;
2361
- ICEcoder . serverQueue ( 'del' , 0 ) ;
2361
+ ICEcoder . serverQueue ( 'del' ) ;
2362
2362
}
2363
2363
}
2364
2364
} ;
@@ -3352,24 +3352,28 @@ var ICEcoder = {
3352
3352
var cM , nextSaveID , txtArea , topSaveID , element , xhr , statusObj , timeStart ;
3353
3353
// If we have this exact item URL, it's almost certain we've got a repetitive save
3354
3354
// situation and so clear the message and server queue item to avoid save jamming
3355
- if ( this . serverQueueItems . indexOf ( item ) !== - 1 ) {
3355
+ if ( action == "add" && this . serverQueueItems . length > 0 && item . indexOf ( 'action=save' ) > 0 && this . serverQueueItems [ 0 ] . file === file ) {
3356
3356
this . serverMessage ( ) ;
3357
- this . serverQueue ( "del" , 0 ) ;
3357
+ this . serverQueue ( "del" ) ;
3358
3358
return ;
3359
3359
}
3360
-
3361
3360
cM = this . getcMInstance ( ) ;
3362
3361
// Firstly, work out how many saves we have to carry out
3363
3362
nextSaveID = 0 ;
3364
3363
for ( var i = 0 ; i < this . serverQueueItems . length ; i ++ ) {
3365
- if ( this . serverQueueItems [ i ] . indexOf ( 'action=save' ) > 0 ) {
3364
+ if ( this . serverQueueItems [ i ] . item . indexOf ( 'action=save' ) > 0 ) {
3366
3365
nextSaveID ++ ;
3367
3366
}
3368
3367
}
3369
3368
nextSaveID ++ ;
3370
3369
// Add to end of array or remove from beginning on demand, plus add or remove if necessary
3371
3370
if ( action == "add" ) {
3372
- this . serverQueueItems . push ( item ) ;
3371
+ this . serverQueueItems . push (
3372
+ {
3373
+ "item" : item ,
3374
+ "file" : file ,
3375
+ "changes" : changes
3376
+ } ) ;
3373
3377
if ( item . indexOf ( 'action=save' ) > 0 ) {
3374
3378
txtArea = document . createElement ( 'textarea' ) ;
3375
3379
txtArea . setAttribute ( 'id' , 'saveTemp' + nextSaveID ) ;
@@ -3379,12 +3383,11 @@ var ICEcoder = {
3379
3383
get ( 'saveTemp' + nextSaveID ) . value = cM . getValue ( ) ;
3380
3384
// Else we can save the JSON version of the changes to implement
3381
3385
} else {
3382
- get ( 'saveTemp' + nextSaveID ) . value = changes ;
3386
+ get ( 'saveTemp' + nextSaveID ) . value = this . serverQueueItems [ 0 ] . changes ;
3383
3387
}
3384
3388
}
3385
3389
} else if ( action == "del" ) {
3386
- // console.log(this);
3387
- if ( this . serverQueueItems [ 0 ] && this . serverQueueItems [ 0 ] . indexOf ( 'action=save' ) > 0 ) {
3390
+ if ( this . serverQueueItems [ 0 ] && this . serverQueueItems [ 0 ] . item . indexOf ( 'action=save' ) > 0 ) {
3388
3391
topSaveID = nextSaveID - 1 ;
3389
3392
for ( var i = 1 ; i < topSaveID ; i ++ ) {
3390
3393
get ( 'saveTemp' + i ) . value = get ( 'saveTemp' + ( i + 1 ) ) . value ;
@@ -3394,12 +3397,11 @@ var ICEcoder = {
3394
3397
}
3395
3398
this . serverQueueItems . splice ( 0 , 1 ) ;
3396
3399
}
3397
-
3398
3400
// If we've just removed from the array and there's another action queued up, or we're triggering for the first time
3399
3401
// then do the next requested process, stored at array pos 0
3400
3402
if ( action == "del" && this . serverQueueItems . length >= 1 || this . serverQueueItems . length == 1 ) {
3401
3403
// If we have an item, we're not saving previous file refs and not loading
3402
- if ( item && ( item . indexOf ( 'saveFiles=' ) == - 1 && item . indexOf ( 'action=load' ) == - 1 ) ) {
3404
+ if ( this . serverQueueItems [ 0 ] . item && ( this . serverQueueItems [ 0 ] . item . indexOf ( 'saveFiles=' ) == - 1 && this . serverQueueItems [ 0 ] . item . indexOf ( 'action=load' ) == - 1 ) ) {
3403
3405
xhr = this . xhrObj ( ) ;
3404
3406
xhr . onreadystatechange = function ( ) {
3405
3407
if ( xhr . readyState == 4 ) {
@@ -3426,7 +3428,7 @@ var ICEcoder = {
3426
3428
console . log ( "ICEcoder error info for your request..." ) ;
3427
3429
console . log ( statusObj ) ;
3428
3430
ICEcoder . serverMessage ( ) ;
3429
- ICEcoder . serverQueue ( 'del' , 0 ) ;
3431
+ ICEcoder . serverQueue ( 'del' ) ;
3430
3432
} else {
3431
3433
eval ( statusObj . action . doNext ) ;
3432
3434
}
@@ -3436,29 +3438,28 @@ var ICEcoder = {
3436
3438
console . log ( "ICEcoder error info for your request..." ) ;
3437
3439
console . log ( statusObj ) ;
3438
3440
ICEcoder . serverMessage ( ) ;
3439
- ICEcoder . serverQueue ( 'del' , 0 ) ;
3441
+ ICEcoder . serverQueue ( 'del' ) ;
3440
3442
}
3441
3443
}
3442
3444
} ;
3443
- xhr . open ( "POST" , this . serverQueueItems [ 0 ] , true ) ;
3445
+ xhr . open ( "POST" , this . serverQueueItems [ 0 ] . item , true ) ;
3444
3446
xhr . setRequestHeader ( 'Content-type' , 'application/x-www-form-urlencoded' ) ;
3445
3447
timeStart = new Date ( ) . getTime ( ) ;
3446
3448
3447
3449
// Save as events need to send all contents
3448
- if ( item . indexOf ( 'action=saveAs' ) > 0 ) {
3449
- xhr . send ( 'timeStart=' + timeStart + '&file=' + file + '&contents=' + encodeURIComponent ( document . getElementById ( 'saveTemp1' ) . value ) ) ;
3450
+ if ( this . serverQueueItems [ 0 ] . item . indexOf ( 'action=saveAs' ) > 0 ) {
3451
+ xhr . send ( 'timeStart=' + timeStart + '&file=' + this . serverQueueItems [ 0 ] . file + '&contents=' + encodeURIComponent ( document . getElementById ( 'saveTemp1' ) . value ) ) ;
3450
3452
// Save evens can just sent the changes
3451
- } else if ( item . indexOf ( 'action=save' ) > 0 ) {
3452
- xhr . send ( 'timeStart=' + timeStart + '&file=' + file + '&changes=' + encodeURIComponent ( document . getElementById ( 'saveTemp1' ) . value ) ) ;
3453
+ } else if ( this . serverQueueItems [ 0 ] . item . indexOf ( 'action=save' ) > 0 ) {
3454
+ xhr . send ( 'timeStart=' + timeStart + '&file=' + this . serverQueueItems [ 0 ] . file + '&changes=' + encodeURIComponent ( document . getElementById ( 'saveTemp1' ) . value ) ) ;
3453
3455
// Another type of event
3454
3456
} else {
3455
- xhr . send ( 'timeStart=' + timeStart + '&file=' + file ) ;
3457
+ xhr . send ( 'timeStart=' + timeStart + '&file=' + this . serverQueueItems [ 0 ] . file ) ;
3456
3458
}
3457
3459
} else {
3458
-
3459
3460
setTimeout ( function ( ic ) {
3460
3461
if ( "undefined" != typeof ic . serverQueueItems [ 0 ] ) {
3461
- ic . filesFrame . contentWindow . frames [ 'fileControl' ] . location . href = ic . serverQueueItems [ 0 ] ;
3462
+ ic . filesFrame . contentWindow . frames [ 'fileControl' ] . location . href = ic . serverQueueItems [ 0 ] . item ;
3462
3463
}
3463
3464
} , 1 , this ) ;
3464
3465
@@ -3485,7 +3486,7 @@ var ICEcoder = {
3485
3486
previousFiles = this . openFiles . join ( ',' ) . replace ( / \/ / g, "|" ) . replace ( / ( \| \[ N E W \] ) | ( , \| \[ N E W \] ) / g, "" ) . replace ( / ( ^ , ) | ( , $ ) / g, "" ) ;
3486
3487
if ( previousFiles == "" ) { previousFiles = "CLEAR" } ;
3487
3488
// Then send through to the settings page to update setting
3488
- this . serverQueue ( "add" , iceLoc + "/lib/settings.php?saveFiles=" + encodeURIComponent ( previousFiles ) + "&csrf=" + this . csrf ) ;
3489
+ this . serverQueue ( "add" , iceLoc + "/lib/settings.php?saveFiles=" + encodeURIComponent ( previousFiles ) + "&csrf=" + this . csrf , encodeURIComponent ( previousFiles ) ) ;
3489
3490
this . updateLast10List ( previousFiles ) ;
3490
3491
} ,
3491
3492
@@ -4404,9 +4405,11 @@ var ICEcoder = {
4404
4405
if ( i != this . dragTabNo ) {
4405
4406
get ( 'tab' + i ) . style . zIndex = 1 ;
4406
4407
} else {
4407
- setTimeout ( function ( num ) {
4408
- get ( 'tab' + num ) . style . zIndex = 1 ;
4409
- } , 150 , swapWith ) ;
4408
+ if ( "undefined" !== typeof swapWith ) {
4409
+ setTimeout ( function ( num ) {
4410
+ get ( 'tab' + num ) . style . zIndex = 1 ;
4411
+ } , 150 , swapWith ) ;
4412
+ }
4410
4413
}
4411
4414
}
4412
4415
if ( this . thisLeft && this . thisLeft !== false ) {
0 commit comments