2014-10-01 01:02:36 +08:00
|
|
|
# --------------------------------------------------------------------------------------------
|
|
|
|
# Private methods on server
|
|
|
|
# --------------------------------------------------------------------------------------------
|
|
|
|
@addShapeToCollection = (meetingId, whiteboardId, shapeObject) ->
|
2015-01-09 04:49:29 +08:00
|
|
|
if shapeObject?.shape_type is "text"
|
|
|
|
Meteor.log.info "we are dealing with a text shape and the event is:#{shapeObject.status}"
|
2014-08-20 00:53:16 +08:00
|
|
|
|
2014-10-01 01:02:36 +08:00
|
|
|
entry =
|
|
|
|
meetingId: meetingId
|
|
|
|
whiteboardId: whiteboardId
|
|
|
|
shape:
|
|
|
|
type: shapeObject.shape.type
|
|
|
|
textBoxHeight: shapeObject.shape.textBoxHeight
|
|
|
|
backgroundColor: shapeObject.shape.backgroundColor
|
|
|
|
fontColor: shapeObject.shape.fontColor
|
|
|
|
status: shapeObject.shape.status
|
|
|
|
dataPoints: shapeObject.shape.dataPoints
|
|
|
|
x: shapeObject.shape.x
|
|
|
|
textBoxWidth: shapeObject.shape.textBoxWidth
|
|
|
|
whiteboardId: shapeObject.shape.whiteboardId
|
|
|
|
fontSize: shapeObject.shape.fontSize
|
|
|
|
id: shapeObject.shape.id
|
|
|
|
y: shapeObject.shape.y
|
|
|
|
calcedFontSize: shapeObject.shape.calcedFontSize
|
|
|
|
text: shapeObject.shape.text
|
|
|
|
background: shapeObject.shape.background
|
|
|
|
|
2015-01-09 05:00:13 +08:00
|
|
|
if shapeObject.status is "textEdited" or shapeObject.status is "textPublished"
|
|
|
|
# only keep the final version of the text shape
|
|
|
|
removeTempTextShape = (callback) ->
|
|
|
|
Meteor.Shapes.remove({'shape.id':shapeObject.shape.id})
|
|
|
|
# for s in Meteor.Shapes.find({'shape.id':shapeObject.shape.id}).fetch()
|
|
|
|
# Meteor.log.info "there is this shape: #{s.shape.text}"
|
|
|
|
callback()
|
2015-01-09 04:49:29 +08:00
|
|
|
|
2015-01-09 05:00:13 +08:00
|
|
|
removeTempTextShape( ->
|
|
|
|
# display as the prestenter is typing
|
|
|
|
id = Meteor.Shapes.insert(entry)
|
|
|
|
Meteor.log.info "#{shapeObject.status} substituting the temp shapes with the newer one"
|
|
|
|
)
|
2014-10-01 01:02:36 +08:00
|
|
|
|
|
|
|
else
|
|
|
|
# the mouse button was released - the drawing is complete
|
|
|
|
# TODO: pencil messages currently don't send draw_end and are labeled all as DRAW_START
|
|
|
|
if shapeObject?.status is "DRAW_END" or (shapeObject?.status is "DRAW_START" and shapeObject?.shape_type is "pencil")
|
2014-08-13 05:56:45 +08:00
|
|
|
entry =
|
|
|
|
meetingId: meetingId
|
|
|
|
whiteboardId: whiteboardId
|
2014-07-10 03:09:10 +08:00
|
|
|
shape:
|
2014-10-01 01:02:36 +08:00
|
|
|
wb_id: shapeObject.wb_id
|
|
|
|
shape_type: shapeObject.shape_type
|
|
|
|
status: shapeObject.status
|
|
|
|
id: shapeObject.id
|
|
|
|
shape:
|
|
|
|
type: shapeObject.shape.type
|
|
|
|
status: shapeObject.shape.status
|
|
|
|
points: shapeObject.shape.points
|
|
|
|
whiteboardId: shapeObject.shape.whiteboardId
|
|
|
|
id: shapeObject.shape.id
|
|
|
|
square: shapeObject.shape.square
|
|
|
|
transparency: shapeObject.shape.transparency
|
|
|
|
thickness: shapeObject.shape.thickness
|
|
|
|
color: shapeObject.shape.color
|
2014-07-10 03:09:10 +08:00
|
|
|
|
2014-08-13 05:56:45 +08:00
|
|
|
id = Meteor.Shapes.insert(entry)
|
2014-08-15 23:04:35 +08:00
|
|
|
|
2014-10-01 01:02:36 +08:00
|
|
|
@removeAllShapesFromSlide = (meetingId, whiteboardId) ->
|
2014-10-25 02:02:01 +08:00
|
|
|
Meteor.log.info "removeAllShapesFromSlide__" + whiteboardId
|
2014-10-01 01:02:36 +08:00
|
|
|
if meetingId? and whiteboardId? and Meteor.Shapes.find({meetingId: meetingId, whiteboardId: whiteboardId})?
|
2015-03-07 03:47:07 +08:00
|
|
|
Meteor.Shapes.remove {meetingId: meetingId, whiteboardId: whiteboardId}, ->
|
|
|
|
Meteor.log.info "clearing all shapes from slide"
|
|
|
|
|
|
|
|
# After shapes are cleared, wait 1 second and set cleaning off
|
|
|
|
Meteor.setTimeout ->
|
|
|
|
Meteor.WhiteboardCleanStatus.update({meetingId: meetingId}, {$set: {in_progress: false}})
|
|
|
|
, 1000
|
2014-08-15 23:04:35 +08:00
|
|
|
|
2014-10-01 01:02:36 +08:00
|
|
|
@removeShapeFromSlide = (meetingId, whiteboardId, shapeId) ->
|
|
|
|
shapeToRemove = Meteor.Shapes.findOne({meetingId: meetingId, whiteboardId: whiteboardId, "shape.id": shapeId})
|
|
|
|
if meetingId? and whiteboardId? and shapeId? and shapeToRemove?
|
|
|
|
Meteor.Shapes.remove(shapeToRemove._id)
|
2014-10-25 02:02:01 +08:00
|
|
|
Meteor.log.info "----removed shape[" + shapeId + "] from " + whiteboardId
|
|
|
|
Meteor.log.info "remaining shapes on the slide:" + Meteor.Shapes.find({meetingId: meetingId, whiteboardId: whiteboardId}).count()
|
2014-12-23 03:43:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
# called on server start and meeting end
|
|
|
|
@clearShapesCollection = (meetingId) ->
|
|
|
|
if meetingId?
|
2015-03-07 03:47:07 +08:00
|
|
|
Meteor.Shapes.remove {}, ->
|
|
|
|
Meteor.log.info "cleared Shapes Collection (meetingId: #{meetingId}!"
|
|
|
|
Meteor.WhiteboardCleanStatus.update({meetingId: meetingId}, {$set: {in_progress: false}})
|
2014-12-23 03:43:27 +08:00
|
|
|
else
|
2015-03-07 03:47:07 +08:00
|
|
|
Meteor.Shapes.remove {}, ->
|
|
|
|
Meteor.log.info "cleared Shapes Collection (all meetings)!"
|
|
|
|
Meteor.WhiteboardCleanStatus.update({meetingId: meetingId}, {$set: {in_progress: false}})
|
2014-12-23 03:43:27 +08:00
|
|
|
|
2014-10-01 01:02:36 +08:00
|
|
|
# --------------------------------------------------------------------------------------------
|
|
|
|
# end Private methods on server
|
|
|
|
# --------------------------------------------------------------------------------------------
|