(data)
| 636 | |
| 637 | |
| 638 | function selectTreeNodeString (data) { |
| 639 | renderEjs('templates/editString.ejs', data, $('#body'), function() { |
| 640 | var isJsonParsed = false; |
| 641 | try { |
| 642 | var jsonObject = data.value; |
| 643 | if (jsonObject.match(simpleObjRE)) { |
| 644 | jsonObject = losslessJSON.parse(data.value); |
| 645 | isJsonParsed = true; |
| 646 | } |
| 647 | $('#jqtree_string_div').jsonViewer(jsonObject, {withQuotes: true, withLinks: false, bigNumbers: true}); |
| 648 | if ((uiConfig.jsonViewAsDefault & uiConfig.const.jsonViewString) > 0) dataUIFuncs.onModeJsonButtonClick('#editStringForm') |
| 649 | } catch (ex) { |
| 650 | $('#isJson').prop('checked', false); |
| 651 | $('#jqtree_string_div').text('Text is no valid JSON: ' + ex.message); |
| 652 | } |
| 653 | |
| 654 | $('#stringValue').val(data.value); |
| 655 | // a this is json now assume it shall be json if it is object or array, but not for numbers |
| 656 | if (isJsonParsed && data.value.match(simpleObjRE)) { |
| 657 | $('#isJson').trigger('click'); |
| 658 | } |
| 659 | |
| 660 | if (!redisReadOnly) { |
| 661 | $('#editStringForm').off('submit').on('submit', function(event) { |
| 662 | console.log('saving'); |
| 663 | event.preventDefault(); |
| 664 | var editForm = $(event.target); |
| 665 | $('#saveKeyButton').attr('disabled', 'disabled').html('<i class="icon-refresh"></i> Saving'); |
| 666 | |
| 667 | $.post(editForm.attr('action'), editForm.serialize() |
| 668 | ).done(function(data2, status) { |
| 669 | console.log('saved', arguments); |
| 670 | refreshTree(); |
| 671 | getKeyTree().select_node(0); |
| 672 | }) |
| 673 | .fail(function(err) { |
| 674 | console.log('save error', arguments); |
| 675 | alert('Could not save "' + err.statusText + '"'); |
| 676 | }) |
| 677 | .always(function() { |
| 678 | setTimeout(function() { |
| 679 | $('#saveKeyButton').prop('disabled', false).html('Save'); |
| 680 | }, 500); |
| 681 | }); |
| 682 | }); |
| 683 | } |
| 684 | }); |
| 685 | } |
| 686 | |
| 687 | function selectTreeNodeBinary (data) { |
| 688 | // switch image from 'string' to 'binary', do not know this before really querying the value... |
no test coverage detected