[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

/admin/jscripts/ -> mycode_sandbox.js (source)

   1  function MyCodeSandbox(url, button, regex_textbox, replacement_textbox, test_textbox, html_textbox, actual_div)
   2  {
   3      if(button && regex_textbox && replacement_textbox && test_textbox && html_textbox && actual_div)
   4      {
   5          this.url = url;
   6          this.button = button;
   7          this.regex_textbox = regex_textbox;
   8          this.replacement_textbox = replacement_textbox;
   9          this.test_textbox = test_textbox;
  10          this.html_textbox = html_textbox;
  11          this.actual_div = actual_div;
  12  
  13          $(button).on('click', function(e) {
  14              e.preventDefault();
  15              this.update();
  16          }.bind(this));
  17      }
  18  }
  19  
  20  MyCodeSandbox.prototype.update = function(e)
  21  {
  22      postData = "regex="+encodeURIComponent($(this.regex_textbox).val())+"&replacement="+encodeURIComponent($(this.replacement_textbox).val())+"&test_value="+encodeURIComponent($(this.test_textbox).val())+"&my_post_key="+encodeURIComponent(my_post_key);
  23  
  24      $.ajax(
  25      {
  26          url: this.url,
  27          async: true,
  28          method: 'post',
  29          data: postData,
  30          complete: function (request)
  31          {
  32              this.onComplete(request);
  33          }.bind(this)
  34      });
  35  };
  36  
  37  MyCodeSandbox.prototype.onComplete = function(request)
  38  {
  39      if(request.responseText.match(/<error>(.*)<\/error>/))
  40      {
  41          message = request.responseText.match(/<error>(.*)<\/error>/);
  42  
  43          if(!message[1])
  44          {
  45              message[1] = lang.unknown_error;
  46          }
  47  
  48          alert(lang.mycode_sandbox_test_error + '\n\n' + message[1]);
  49      }
  50      else if(request.responseText)
  51      {
  52          $(this.actual_div).html(request.responseText);
  53          $(this.html_textbox).val(request.responseText);
  54      }
  55  
  56      return true;
  57  };


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref