break; case 'saveCategories': $document = Document::fromDatabase($_POST['documentID']); $document->changeCategories(json_decode(stripslashes($_POST['categories']), true)); break; case 'getSnapshots': $document = Document::fromDatabase($_POST['documentID']); echo json_encode(Snapshot::getList($document)); break; case 'saveSnapshot': $document = Document::fromDatabase($_POST['documentID']); Snapshot::create($document, json_decode(stripslashes($_POST['documentData']), true), $_POST['timestamp']); break; case 'loadSnapshot': $document = Document::fromDatabase($_POST['documentID']); echo json_encode(Snapshot::getData($document, $_POST['snapshotID'])); break; case 'deleteDocument': $document = Document::fromDatabase($_POST['id']); $document->delete(); break; case 'loadDocuments': echo json_encode(Document::getList(Document::FORMAT_JSON)); break; case 'createDocument': $document = Document::create($_POST['name']); echo $document->getId(); break; case 'renameDocument': $document = Document::fromDatabase($_POST['id']); $document->rename($_POST['newname']);