Skip to content

Commit

Permalink
clean up some codes
Browse files Browse the repository at this point in the history
  • Loading branch information
sprklinginfo committed Dec 15, 2015
1 parent 1ae6706 commit 4959896
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
18 changes: 7 additions & 11 deletions js/annotationApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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' },
Expand All @@ -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
);
});
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
18 changes: 7 additions & 11 deletions js/source/annotationApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className="annotationBox">
Expand All @@ -91,7 +91,7 @@
);
}
}
else if(JSON.parse(permissions['view'])) {
else if(JSON.parse(permissions.view)) {
return (
<div className="annotationBox">
<AnnotationList data={this.state.annotations} />
Expand All @@ -114,7 +114,7 @@
//console.dir(this.props.data);
var annotationItems = this.props.data.map(function(item, index) {
return (
<Annotation author={item.author} key={index} start={item.mediaFragmentStart} end={item.mediaFragmentEnd}>
<Annotation index={index} author={item.author} key={index} start={item.mediaFragmentStart} end={item.mediaFragmentEnd}>
{item.content}
</Annotation>
);
Expand Down Expand Up @@ -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 (
<li className="annotationItem" data-begin={this.props.start} data-end={this.props.end} >
<li className="annotationItem" id={this.props.index} data-begin={this.props.start} data-end={this.props.end} >
<span>
<button
className="btn btn-default btn-xs">{this.props.start}<span className="glyphicon glyphicon-play"></span></button>
Expand All @@ -227,7 +223,7 @@
);
} else {
return (
<li className="annotationItem" data-begin={this.props.start} data-end={this.props.end} >
<li className="annotationItem" id={this.props.index} data-begin={this.props.start} data-end={this.props.end} >
<span>
<button
className="btn btn-default btn-xs">{this.props.start}<span className="glyphicon glyphicon-play"></span></button>
Expand All @@ -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 (
<li className="annotationItem" data-begin={this.props.start} data-end={this.props.end} >
<li className="annotationItem" id={this.props.index} data-begin={this.props.start} data-end={this.props.end} >
<span>
<button
className="btn btn-default btn-xs">{this.props.start}<span className="glyphicon glyphicon-play"></span></button>
Expand All @@ -256,7 +252,7 @@
);
} else {
return (
<li className="annotationItem" data-begin={this.props.start} data-end={this.props.end} >
<li className="annotationItem" id={this.props.index} data-begin={this.props.start} data-end={this.props.end} >
<span>
<button
className="btn btn-default btn-xs">{this.props.start}<span className="glyphicon glyphicon-play"></span></button>
Expand Down

0 comments on commit 4959896

Please sign in to comment.