| 429 | if (key == '') key = ''.random(8); |
| 430 | var count = 0; |
| 431 | function post_save(side, text) { |
| 432 | $.ajax({ |
| 433 | type: 'POST', async: true, dataType: 'text', |
| 434 | url: '/ajax/handle_file.php', |
| 435 | data: { 'key': key, 'name': side, 'content': text }, |
| 436 | success: function (nkey) { |
| 437 | ++count; |
| 438 | if (count == 2) { |
| 439 | var url = '/ajax/handle_save.php?key=' + key; |
| 440 | if (fork) url += '&nkey=' + ''.random(8); |
| 441 | $.ajax({ |
| 442 | type: 'GET', async: false, dataType: 'text', |
| 443 | url: url, |
| 444 | success: function (nkey) { |
| 445 | // redirect |
| 446 | if (nkey.length) window.location.href = '/' + $.trim(nkey) + '/'; |
| 447 | }, |
| 448 | error: function(xhr, ajaxOptions, thrownError){ |
| 449 | } |
| 450 | }); |
| 451 | } |
| 452 | }, |
| 453 | error: function(xhr, ajaxOptions, thrownError){ |
| 454 | alert(thrownError); |
| 455 | } |
| 456 | }); |
| 457 | } |
| 458 | function save_files() { |
| 459 | var lhs = ed.mergely('get', 'lhs'); |
| 460 | var rhs = ed.mergely('get', 'rhs'); |