Skip to content

Commit

Permalink
Replace dotted property accessor with method calls
Browse files Browse the repository at this point in the history
  • Loading branch information
larry committed Jul 11, 2014
1 parent af66810 commit 2ef95af
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
6 changes: 3 additions & 3 deletions app/js/rtpg.collaborators.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ rtpg.collaborators.updateUi = function() {
$(rtpg.collaborators.COLLABORATORS_SELECTOR).empty();
for (var i = 0; i < collaboratorsList.length; i = i + 1) {
var collaborator = collaboratorsList[i];
var imgSrc = collaborator.photoUrl == null ? 'images/anon.jpeg' : collaborator.photoUrl;
var img = $('<img>').attr('src', imgSrc).attr('alt', collaborator.displayName).attr('title', collaborator.displayName + (collaborator.isMe ? " (Me)" : ""));
img.css('background-color', collaborator.color);
var imgSrc = collaborator.photoUrl() == null ? 'images/anon.jpeg' : collaborator.photoUrl();
var img = $('<img>').attr('src', imgSrc).attr('alt', collaborator.displayName()).attr('title', collaborator.displayName() + (collaborator.isMe() ? " (Me)" : ""));
img.css('background-color', collaborator.color());
$(rtpg.collaborators.COLLABORATORS_SELECTOR).append(img);
}
};
Expand Down
8 changes: 4 additions & 4 deletions app/js/rtpg.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ rtpg.onFileLoaded = function(doc) {

// Add event handler for UndoRedoStateChanged events.
var onUndoRedoStateChanged = function(e) {
$('#undoButton').prop('disabled', !e.canUndo);
$('#redoButton').prop('disabled', !e.canRedo);
$('#undoButton').prop('disabled', !e.canUndo());
$('#redoButton').prop('disabled', !e.canRedo());
};
model.onUndoRedoStateChanged(onUndoRedoStateChanged);

Expand Down Expand Up @@ -241,7 +241,7 @@ rtpg.realTimeOptions = {
rtpg.getCollaborator = function(sessionId) {
var collaborators = rtpg.realtimeDoc.getCollaborators();
for (var i = 0; i < collaborators.length; i = i+1) {
if(collaborators[i].sessionId == sessionId) {
if(collaborators[i].sessionId() == sessionId) {
return collaborators[i];
}
}
Expand All @@ -252,7 +252,7 @@ rtpg.getCollaborator = function(sessionId) {
rtpg.getMe = function() {
var collaborators = rtpg.realtimeDoc.getCollaborators();
for (var i = 0; i < collaborators.length; i = i+1) {
if(collaborators[i].isMe) {
if(collaborators[i].isMe()) {
return collaborators[i];
}
}
Expand Down
18 changes: 9 additions & 9 deletions app/js/rtpg.list.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ rtpg.list.onListItemClick = function (evt) {
rtpg.list.field.registeredReference = rtpg.list.field.registerReference(index, true);
rtpg.list.field.registeredReference.onReferenceShifted(rtpg.list.onRealtimeReferenceShifted);
if(rtpg.list.cursors){
rtpg.list.cursors.set(rtpg.getMe().sessionId, rtpg.list.field.registeredReference);
rtpg.list.cursors.set(rtpg.getMe().sessionId(), rtpg.list.field.registeredReference);
}
}

rtpg.list.field.registeredReference.index = index;
rtpg.list.field.registeredReference.setIndex(index);

// Set text for move button and set field
$(rtpg.list.SET_CONTENT_SELECTOR).val($(evt.target).text());
Expand All @@ -130,18 +130,18 @@ rtpg.list.updateListItems = function () {

if(rtpg.list.field.registeredReference) {
listItems.removeClass('active');
$(listItems[rtpg.list.field.registeredReference.index])
.addClass('active').css('background-color', me.color);
$(listItems[rtpg.list.field.registeredReference.index()])
.addClass('active').css('background-color', me.color());
}

if(rtpg.list.cursors){
keys = rtpg.list.cursors.keys();
for(var i = 0, len = keys.length; i < len; i++){
if(keys[i] != me.sessionId){
var index = rtpg.list.cursors.get(keys[i]).index;
if(keys[i] != me.sessionId()){
var index = rtpg.list.cursors.get(keys[i]).index();
var collaborator = rtpg.getCollaborator(keys[i]);
$(listItems[index]).addClass('muted');
$(listItems[index]).css('background-color', collaborator.color);
$(listItems[index]).css('background-color', collaborator.color());
}
}
}
Expand Down Expand Up @@ -207,14 +207,14 @@ rtpg.list.connectUi = function() {
};

rtpg.list.onRealtimeReferenceShifted = function (evt) {
var log = rtpg.getCollaborator(evt.sessionId).displayName + ' moved cursor from ' + evt.oldIndex +' to ' + evt.newIndex;
var log = rtpg.getCollaborator(evt.sessionId()).displayName() + ' moved cursor from ' + evt.oldIndex() +' to ' + evt.newIndex();
rtpg.log.logEvent(evt, log);
rtpg.list.updateUi();
};

rtpg.list.onRealtimeCursorChange = function (evt) {
console.log('Cursor Change Event');
evt.newValue.onReferenceShifted(rtpg.list.onRealtimeReferenceShifted);
evt.newValue().onReferenceShifted(rtpg.list.onRealtimeReferenceShifted);
rtpg.list.updateUi();
};

Expand Down
36 changes: 18 additions & 18 deletions app/js/rtpg.log.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,38 @@ rtpg.log.createLogEntryElement = function(msg) {


rtpg.log.logEvent = function(evt, eventType) {
var collaborator = rtpg.getCollaborator(evt.sessionId);
var collaborator = evt.sessionId ? rtpg.getCollaborator(evt.sessionId()) : null;

var eventDetails;
// Collab String events
if (evt.type == realtime.store.EventType.TEXT_INSERTED || evt.type == realtime.store.EventType.TEXT_DELETED) {
eventDetails = '"' + evt.text.replace(/ /g, '\xa0') + '" at index ' + evt.index;
if (evt.type() == realtime.store.EventType.TEXT_INSERTED || evt.type() == realtime.store.EventType.TEXT_DELETED) {
eventDetails = '"' + evt.text().replace(/ /g, '\xa0') + '" at index ' + evt.index();
// Collab Map/Custom Objects property changed events
} else if (evt.type == realtime.store.EventType.VALUE_CHANGED) {
eventDetails = 'Property "' + evt.property + '" changed from "' + evt.oldValue + '" to "' + evt.newValue + '"';
} else if (evt.type() == realtime.store.EventType.VALUE_CHANGED) {
eventDetails = 'Property "' + evt.property() + '" changed from "' + evt.oldValue() + '" to "' + evt.newValue() + '"';
// Collab List Added and Deleted events
} else if (evt.type == realtime.store.EventType.VALUES_ADDED || evt.type == realtime.store.EventType.VALUES_REMOVED) {
eventDetails = '"' + evt.values.join(', ') + '" at index ' + evt.index;
} else if (evt.type() == realtime.store.EventType.VALUES_ADDED || evt.type() == realtime.store.EventType.VALUES_REMOVED) {
eventDetails = '"' + evt.values().join(', ') + '" at index ' + evt.index();
// Collab List Added events
} else if (evt.type == realtime.store.EventType.VALUES_SET) {
eventDetails = 'From "' + evt.oldValues.join(', ') + '" to "' + evt.newValues.join(', ') + '" at index ' + evt.index;
} else if (evt.type() == realtime.store.EventType.VALUES_SET) {
eventDetails = 'From "' + evt.oldValues().join(', ') + '" to "' + evt.newValues().join(', ') + '" at index ' + evt.index();
// Reference Shifted events
} else if (evt.type == realtime.store.EventType.REFERENCE_SHIFTED) {
eventDetails = 'From ' + evt.oldIndex + ' to ' + evt.newIndex;
} else if (evt.type() == realtime.store.EventType.REFERENCE_SHIFTED) {
eventDetails = 'From ' + evt.oldIndex() + ' to ' + evt.newIndex();
// Collaborators list events
} else if (evt.type == realtime.store.EventType.COLLABORATOR_JOINED || evt.type == realtime.store.EventType.COLLABORATOR_LEFT) {
eventDetails = evt.collaborator.displayName;
collaborator = evt.collaborator;
} else if (evt.type() == realtime.store.EventType.COLLABORATOR_JOINED || evt.type() == realtime.store.EventType.COLLABORATOR_LEFT) {
eventDetails = evt.collaborator().displayName();
collaborator = evt.collaborator();
}

var logMessage = {
eventType: eventType + ': ',
picUrl: collaborator.photoUrl == null ? "images/anon.jpeg" : collaborator.photoUrl,
userName: collaborator.displayName,
color: collaborator.color,
picUrl: collaborator.photoUrl() == null ? "images/anon.jpeg" : collaborator.photoUrl(),
userName: collaborator.displayName(),
color: collaborator.color(),
time: new Date().getTime(),
eventDetails: eventDetails,
isLocal: evt.isLocal
isLocal: evt.isLocal ? evt.isLocal() : false
};

rtpg.log.onLogAdded(logMessage);
Expand Down

0 comments on commit 2ef95af

Please sign in to comment.