@@ -230,7 +230,7 @@ function refreshOpenOrders() {
230230 typedesc = 'Sell ' ;
231231 }
232232 msg = typedesc + value . amount . toString ( ) + ' at ' + value . price . toString ( ) ;
233- $ ( '#user_openorders' ) . append ( '<option>' + msg + '</option>' ) ;
233+ $ ( '#user_openorders' ) . append ( '<option value="' + value . id + '" >' + msg + '</option>' ) ;
234234 } ) ;
235235
236236 // Exception for empty transaction list
@@ -247,18 +247,25 @@ function refreshOpenOrders() {
247247}
248248
249249function cancelOrders ( ) {
250- $ ( '#user_openorders option:selected' ) . each ( function ( ) {
251- if ( int ( this . value ) ) {
252- console . log ( 'Canceling order with id ' + this . value . toString ( ) ) ;
250+ console . log ( 'calling cancelOrders' ) ;
251+ $ ( '#user_openorders option:selected' ) . each ( function ( index , option ) {
252+ console . log ( option . value ) ;
253+ if ( parseInt ( option . value ) > 0 ) {
254+ console . log ( 'Canceling order with id ' + option . value . toString ( ) ) ;
253255 params = bitstamp . submitRequest ( bitstamp . methods . cancelorder , function ( response ) {
254256 if ( 'data' in response ) {
255- // TODO reorder or just fetch new?
256- //$("#user_openorders option[value='" + + "']").remove();
257- refreshOpenOrders ( ) ;
257+ // TODO refresh balances
258+ // refreshOpenOrders();
259+ if ( response [ 'data' ] == true ) {
260+ //$("#user_openorders option[value='" + + "']").remove();
261+ alert ( 'Order cancelled' ) ;
262+ }
263+ else
264+ alert ( 'Order not cancelled' ) ;
258265 } else {
259266 alert ( response . error || 'Unknown error' ) ;
260267 }
261- } , { id : this . value } ) ;
268+ } , { id : option . value } ) ;
262269 }
263270 } ) ;
264271}
0 commit comments