Skip to content

Commit

Permalink
Added highlighting of document contents.
Browse files Browse the repository at this point in the history
  • Loading branch information
hrishikeshs committed Jun 8, 2014
1 parent fdf08e0 commit a92ceb0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Mongoman.DocumentsController = Ember.ArrayController.extend({
var keys = str.match(/[a-zA-Z0-9_\"\s\']+:\s+/g);
if (keys) {
for (var i = 0, j = keys.length; i < j; i++) {
str = str.replace(keys[i],'"' + keys[i].split(':')[0] + '":' );
str = str.replace(keys[i],'"' + keys[i].split(':')[0].trim() + '":' );
}
}
else {
Expand Down
17 changes: 15 additions & 2 deletions Mongoman/app/assets/javascripts/helpers/parse_json_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@ Ember.Handlebars.registerBoundHelper('parseJSONString', function (json) {

switch(type) {

case 'string' : return '"' + Handlebars.Utils.escapeExpression(json) + '"';
case 'string' :
if(json.match(/^ObjectId*/)) {
return '<span class="special-form" style="display:none;">"</span>' + '<span style="color: #dd1144;"> ' +
Handlebars.Utils.escapeExpression(json) + '</span>' + '<span class="special-form" style="display:none;">"</span>'
}
else if(json.match(/^ISODate*/)) {
return '<span class="special-form" style="display:none;">"</span>' + '<span style="color: rgb(176, 96, 214);"> ' +
Handlebars.Utils.escapeExpression(json) + '</span>' + '<span class="special-form" style="display:none;">"</span>'
}

return '<span style="color: rgb(11, 168, 36);">"' +
Handlebars.Utils.escapeExpression(json) + '"</span>';


case 'number' :
case 'undefined' :
case 'boolean' :
Expand All @@ -25,7 +38,7 @@ Ember.Handlebars.registerBoundHelper('parseJSONString', function (json) {
var htmlArray = [];
for(var i = 0, len = keys.length; i < len; i++) {
var k = keys[i];
var html = "<br /><div class='showhide'><strong>" + k + '</strong>' + ': ' + "<span style='overflow:auto;'>" + prettyPrint(json[k]) + "</span></div>";
var html = "<br /><div class='showhide'><strong style='color: rgb(51, 15, 241);'>" + k + '</strong>' + ': ' + "<span style='overflow:auto;padding-left:10px;'>" + prettyPrint(json[k]) + "</span></div>";
htmlArray.push(html);
}
return '{' + "<div class='collapsible'>" + htmlArray.join() + '<br />' + '</div>}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
</button>
<button class='edit-save-button' {{action 'editOrSaveDocument' target='view'}} title='syntax is key:[space]value-in-double-quotes'>
Edit</button>
<div contenteditable='false' class='document-content'>
<div contenteditable='false' class='document-content' spellcheck="false">
{{parseJSONString view.content}}
</div>
2 changes: 1 addition & 1 deletion Mongoman/app/assets/javascripts/views/document_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Mongoman.DocumentView = Ember.View.extend({
}
else {
this.$('.document-content')[0].contentEditable = false
var updated_document = this.$('.document-content').text()
var updated_document = this.$('.document-content').text();
var jsonified = this.get('controller.jsonifyText')(updated_document.trim())
var url = '/documents/id?'
Mongoman.PostRequest.post(url , {database_name : this.get('controller.database_name'), collection_name: this.get('controller.collection_name')}, 'PUT', jsonified)
Expand Down
2 changes: 1 addition & 1 deletion Mongoman/app/assets/stylesheets/_pages/common_classes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
.flex {
display: flex;
align-items: center;
}
}

0 comments on commit a92ceb0

Please sign in to comment.