From b612710c4e7b48c67f0eb7b18c46882632900dc6 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sun, 15 Jan 2012 23:44:56 +0100 Subject: [PATCH] Updated the update controller for setting the title of draggables --- plemp.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/plemp.js b/plemp.js index bab3382..f889f50 100644 --- a/plemp.js +++ b/plemp.js @@ -141,13 +141,22 @@ app.get('/draggables/:id', function(req, res) { // page for committing position changes of the draggables to the database, // i.e. the global state. app.post('/draggables/:id', function(req, res) { - console.log("Position update for draggable " + req.params.id + ";" + - " left: " + req.body.left + - " top: " + req.body.top); - // Set the position for the file with the given ID. - var new_pos = draggables[req.params.id]; - new_pos.top = req.body.top; - new_pos.left = req.body.left; + var drag = draggables[req.params.id]; + if (req.body.title) { + // It's a title update! + console.log("Title update for draggable " + req.params.id + ": " + + req.body.title); + drag.title = req.body.title; + res.send(req.body.title); + } + else { + // Set the position for the file with the given ID. + console.log("Position update for draggable " + req.params.id + ";" + + " left: " + req.body.left + + " top: " + req.body.top); + drag.top = req.body.top; + drag.left = req.body.left; + } }); // Draggable removal controller: removes the specific draggable from the