stuppid_bot

Untitled

May 9th, 2013
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ( function() {
  2.     var handler = 'file_system.php';
  3.    
  4.     serverFileSystem = {
  5.         read: function(filename, cb) {
  6.             ajax.get( handler + '?action=read&filename=' + encodeURIComponent(filename), {
  7.                 responseType: 'json',
  8.                
  9.                 done: function(r) {
  10.                     cb(r.error, r.data);
  11.                 },
  12.                
  13.                 fail: function(text) {
  14.                     console.log('Ошибка:' + text);
  15.                 }
  16.             } );
  17.         },
  18.        
  19.         /**
  20.          * Записывает данные в файл на сервере.
  21.          *
  22.          * @param flags список флагов, доступны: append, lock
  23.          */
  24.         write: function(filename, data, cb, flags) {
  25.             flags = flags || [];
  26.             var q = '?action=write&filename=' + encodeURIComponent(filename);
  27.            
  28.             flags.map( function(v) {
  29.                 q += '&' + v.toLowerCase() + '=1';
  30.             } );
  31.            
  32.             ajax.put( handler + q, data, {
  33.                 responseType: 'json',
  34.                
  35.                 done: function(r) {
  36.                     cb(r.error, r.data);
  37.                 },
  38.                
  39.                 fail: function(text) {
  40.                     console.log('Ошибка:' + text);
  41.                 }
  42.             } );
  43.         }
  44.     };
  45. } )();
Advertisement
Add Comment
Please, Sign In to add comment