Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ( function() {
- var handler = 'file_system.php';
- serverFileSystem = {
- read: function(filename, cb) {
- ajax.get( handler + '?action=read&filename=' + encodeURIComponent(filename), {
- responseType: 'json',
- done: function(r) {
- cb(r.error, r.data);
- },
- fail: function(text) {
- console.log('Ошибка:' + text);
- }
- } );
- },
- /**
- * Записывает данные в файл на сервере.
- *
- * @param flags список флагов, доступны: append, lock
- */
- write: function(filename, data, cb, flags) {
- flags = flags || [];
- var q = '?action=write&filename=' + encodeURIComponent(filename);
- flags.map( function(v) {
- q += '&' + v.toLowerCase() + '=1';
- } );
- ajax.put( handler + q, data, {
- responseType: 'json',
- done: function(r) {
- cb(r.error, r.data);
- },
- fail: function(text) {
- console.log('Ошибка:' + text);
- }
- } );
- }
- };
- } )();
Advertisement
Add Comment
Please, Sign In to add comment