123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- var $saveCode = $('#save-code');
- var $place = $('.container');
- var $pre = $('#pre-code');
- var $buttonPlace = $('#buttons');
- var $addPlace = $('#add-place');
- var $form = $('#form');
- function crateTextArea() {
- var $panel = $('<div>').addClass('panel panel-primary').appendTo($place);
- var $panelHead = $('<div>').addClass('panel-heading').text('Code spase').appendTo($panel);
- var $panelBody = $('<div>').addClass('panel-body').appendTo($panel);
- var $formGroup = $('<div>').addClass('form-group').attr('id', 'form').appendTo($panelBody);
- var $label = $('<label>').attr('for', 'code').text('Enter your code:').appendTo($formGroup);
- var $textarea = $('<textarea>').addClass('form-control').attr({'id': 'code','rows': 5}).appendTo($formGroup);
- var $pre = $('<pre>').attr('id', 'pre-code').appendTo($formGroup).hide();
- var $buttonSave = $('<button>').attr('id', 'save-code').addClass('btn btn-info').text('Save').appendTo($panelBody)
- .one('click', function(event){
- $panel.find('.btn-info').remove();
- var $code = $textarea.val();
- $textarea.remove();
- $pre.text($code).fadeIn();
- $label.text('This code will be executed');
- $buttonStart = $('<button>')
- .addClass('btn btn-success')
- .text('Start')
- .appendTo($panelBody)
- .one('click', function(event) {
- $('<script>')
- .text($code)
- .appendTo($place);
- });
- });
- var $buttonDelete = $('<button>').attr('id', 'delete-code').addClass('btn btn-danger pull-right').text('Delete').appendTo($panelBody)
- .one('click', function(event){
- $panel.remove();
- });
- }
- $saveCode.on('click', function(event){
- $buttonPlace.find('.btn-info').remove();
- var $code = $('#code').val();
- $pre.text($code).fadeIn();
- $form.find('.form-control').remove();
- $('label').text('This code will be executed');
- $buttonStart = $('<button>')
- .addClass('btn btn-success')
- .text('Start')
- .appendTo($buttonPlace)
- .one('click', function(event) {
- $('<script>')
- .text($code)
- .appendTo($place);
- })
- })
- $addPlace.on('click', function(event){
- crateTextArea();
- })
|