From 49598967c5ab13672f7e3aa2fdddb0c0a89ba2bc Mon Sep 17 00:00:00 2001 From: Lingling Jiang Date: Tue, 15 Dec 2015 16:22:07 -0500 Subject: [PATCH] clean up some codes --- js/annotationApp.js | 18 +++++++----------- js/source/annotationApp.js | 18 +++++++----------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/js/annotationApp.js b/js/annotationApp.js index 8b351af..cf43c58 100644 --- a/js/annotationApp.js +++ b/js/annotationApp.js @@ -67,7 +67,7 @@ }, renderDisplay: function () { //console.dir(this.state.data, 'data from annotationbox'); - if (JSON.parse(permissions['create'])) { + if (JSON.parse(permissions.create)) { if (!this.state.adding) { return React.createElement( 'div', @@ -104,7 +104,7 @@ React.createElement(AnnotationList, { data: this.state.annotations }) ); } - } else if (JSON.parse(permissions['view'])) { + } else if (JSON.parse(permissions.view)) { return React.createElement( 'div', { className: 'annotationBox' }, @@ -130,7 +130,7 @@ var annotationItems = this.props.data.map(function (item, index) { return React.createElement( Annotation, - { author: item.author, key: index, start: item.mediaFragmentStart, end: item.mediaFragmentEnd }, + { index: index, author: item.author, key: index, start: item.mediaFragmentStart, end: item.mediaFragmentEnd }, item.content ); }); @@ -261,15 +261,11 @@ displayName: 'Annotation', render: function () { - //console.log(this.state); - //var annoUser = this.props.author; - console.log(this.props.author.uid); - console.log(permissions.edit_any); if (JSON.parse(permissions.edit_any)) { if (JSON.parse(permissions.delete_any) || JSON.parse(permissions.delete_own) && user.uid == this.props.author.uid) { return React.createElement( 'li', - { className: 'annotationItem', 'data-begin': this.props.start, 'data-end': this.props.end }, + { className: 'annotationItem', id: this.props.index, 'data-begin': this.props.start, 'data-end': this.props.end }, React.createElement( 'span', null, @@ -296,7 +292,7 @@ } else { return React.createElement( 'li', - { className: 'annotationItem', 'data-begin': this.props.start, 'data-end': this.props.end }, + { className: 'annotationItem', id: this.props.index, 'data-begin': this.props.start, 'data-end': this.props.end }, React.createElement( 'span', null, @@ -324,7 +320,7 @@ if (JSON.parse(permissions.delete_any || JSON.parse(permissions.delete_own) && user.uid == this.props.author.uid)) { return React.createElement( 'li', - { className: 'annotationItem', 'data-begin': this.props.start, 'data-end': this.props.end }, + { className: 'annotationItem', id: this.props.index, 'data-begin': this.props.start, 'data-end': this.props.end }, React.createElement( 'span', null, @@ -351,7 +347,7 @@ } else { return React.createElement( 'li', - { className: 'annotationItem', 'data-begin': this.props.start, 'data-end': this.props.end }, + { className: 'annotationItem', id: this.props.index, 'data-begin': this.props.start, 'data-end': this.props.end }, React.createElement( 'span', null, diff --git a/js/source/annotationApp.js b/js/source/annotationApp.js index cc8337e..87c636c 100644 --- a/js/source/annotationApp.js +++ b/js/source/annotationApp.js @@ -67,7 +67,7 @@ }, renderDisplay: function() { //console.dir(this.state.data, 'data from annotationbox'); - if (JSON.parse(permissions['create'])) { + if (JSON.parse(permissions.create)) { if (!this.state.adding) { return (
@@ -91,7 +91,7 @@ ); } } - else if(JSON.parse(permissions['view'])) { + else if(JSON.parse(permissions.view)) { return (
@@ -114,7 +114,7 @@ //console.dir(this.props.data); var annotationItems = this.props.data.map(function(item, index) { return ( - + {item.content} ); @@ -206,14 +206,10 @@ }); var Annotation = React.createClass({ render: function() { - //console.log(this.state); - //var annoUser = this.props.author; - console.log(this.props.author.uid); - console.log(permissions.edit_any); if (JSON.parse(permissions.edit_any)) { if (JSON.parse(permissions.delete_any) || (JSON.parse(permissions.delete_own) && user.uid == this.props.author.uid)) { return ( -
  • +
  • @@ -227,7 +223,7 @@ ); } else { return ( -
  • +
  • @@ -242,7 +238,7 @@ } else if (JSON.parse(permissions.edit_own) && user.uid == this.props.author.uid){ if (JSON.parse(permissions.delete_any || (JSON.parse(permissions.delete_own) && user.uid == this.props.author.uid))) { return ( -
  • +
  • @@ -256,7 +252,7 @@ ); } else { return ( -
  • +