Advertisement
Aichan

commands.js

Jan 6th, 2013
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     var editor = ace.edit("editor");
  2.     editor.setTheme("ace/theme/ambiance");
  3.     editor.getSession().setMode("ace/mode/lua");
  4.    
  5.     // Save to local command
  6.     editor.commands.addCommand({
  7.     name: 'save',
  8.     bindKey: {win: 'Ctrl-M',  mac: 'Command-M'},
  9.     exec: function(editor) {
  10.         var parts = window.location.search.substr(1).split("&");
  11.         var $_GET = {};
  12.         for (var i = 0; i < parts.length; i++) {
  13.             var temp = parts[i].split("=");
  14.             $_GET[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]);
  15.         }
  16.         var filename = typeof $_GET['name'] == 'undefined' ? prompt("Enter name of file","aichan") : $_GET['name'];
  17.         var fileid = typeof $_GET['id'] == 'undefined' ? prompt("Enter ID of turtle","") : $_GET['id'];
  18.         var filepass = typeof $_GET['pass'] == 'undefined' ? prompt("Enter password of turtle","") : $_GET['pass'];
  19.         $.ajax({
  20.           type: "POST",
  21.           url: "edit.php",
  22.           data: { source: editor.getValue(), id: fileid, name: filename, pass: filepass}
  23.         }).done(function( msg ) {
  24.           alert( "Response: " + msg );
  25.         });
  26.     },
  27.     readOnly: true
  28.     });
  29.    
  30.     // Save to pastebin command
  31.     editor.commands.addCommand({
  32.     name: 'pastebin',
  33.     bindKey: {win: 'Ctrl-P',  mac: 'Command-P'},
  34.     exec: function(editor) {
  35.         var parts = window.location.search.substr(1).split("&");
  36.         var $_GET = {};
  37.         for (var i = 0; i < parts.length; i++) {
  38.             var temp = parts[i].split("=");
  39.             $_GET[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]);
  40.         }      
  41.         var pastename = typeof $_GET['name'] == 'undefined' ? prompt("Enter name of paste","CC lua script") : $_GET['name'];
  42.         $.ajax({
  43.           type: "POST",
  44.           url: "pastebin.php",
  45.           data: { source: editor.getValue(), name: pastename}
  46.         }).done(function( msg ) {
  47.           prompt( "URL: ", msg );
  48.         });
  49.     },
  50.     readOnly: true
  51.     });
  52.    
  53.     // Login to pastebin command
  54.     editor.commands.addCommand({
  55.     name: 'login',
  56.     bindKey: {win: 'Ctrl-I',  mac: 'Command-I'},
  57.     exec: function(editor) {
  58.        
  59.         var login = prompt("Pastebin login","");
  60.         var pass = prompt("Pastebin password","");
  61.        
  62.         $.ajax({
  63.           type: "POST",
  64.           url: "paste_login.php",
  65.           data: { user: login, password: pass}
  66.         }).done(function( msg ) {
  67.           alert( "Response: " + msg );
  68.         });
  69.     },
  70.     readOnly: true
  71.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement