diff --git a/components/collaborative/controler.php b/components/collaborative/controler.php index fa7adbe..356b882 100644 --- a/components/collaborative/controler.php +++ b/components/collaborative/controler.php @@ -21,6 +21,13 @@ /*if(!empty($_GET['action'])){ $action = $_GET['action']; } else{ exit('{"status":"error","data":{"error":"No Action Specified"}}'); }*/ + if (isset($_POST["action"]) && !empty($_POST["action"])) { + $data = json_decode($_POST["action"]); + /*touch(BASE_PATH . "/data/pipi"); + touch(BASE_PATH . "/data/" . $data['filename'] . '_' . $_SESSION['user']);*/ + echo json_encode($data); + } + if (isset($_POST["change"]) && !empty($_POST["change"])) { $data = json_decode($_POST["change"]); echo json_encode($data); diff --git a/components/collaborative/init.js b/components/collaborative/init.js index efc701f..89d5c96 100644 --- a/components/collaborative/init.js +++ b/components/collaborative/init.js @@ -30,7 +30,22 @@ this.$onCursorChange = this.onCursorChange.bind(this); }, + registerAsCollaboratorOfActiveFile: function () { + var post = { action: 'register', filename: 'toto' }; + $.ajax({ + type: 'POST', + url: this.controller, + // data: post, + data: { action: 'register', filename: codiad.active.getPath() }, + complete: function (data) { + console.log('complete registering'); + console.log(data); + } + }); + }, + addListeners: function () { + this.registerAsCollaboratorOfActiveFile(); this.addListenerToOnDocumentChange(); this.addListenerToOnCursorChange(); },