Skip to content

Commit

Permalink
showing explanation with context
Browse files Browse the repository at this point in the history
  • Loading branch information
chensivan committed Mar 12, 2017
1 parent d1ad8c7 commit 49cdf07
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 11 deletions.
9 changes: 7 additions & 2 deletions lib/response/controllers/helper_response.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var Quill = require('quill')
var trix = require('angular-trix')
var trixx = require('trix')
require('qtip')
var _ = require('underscore')
module.exports = function(app) {

app.filter('showButtonOnce', function() {
Expand Down Expand Up @@ -61,7 +62,7 @@ module.exports = function(app) {
};
});

app.controller("HelperResponse", ['$scope', '$rootScope', 'QuestionManager', 'Slider', 'RequestReplayer', 'ResponseManager', function($scope, $rootScope, QuestionManager, Slider, RequestReplayer) {
app.controller("HelperResponse", ['$scope', '$rootScope', 'QuestionManager', 'Slider', 'RequestReplayer', 'ResponseManager', function($scope, $rootScope, QuestionManager, Slider, RequestReplayer,ResponseManager) {
$scope.hasReplay = false;
$scope.show = false;
debugger;
Expand Down Expand Up @@ -96,13 +97,17 @@ module.exports = function(app) {
if (range) {
if (range.length == 0) {
console.log('User cursor is on', range.index);
// ResponseManager.showContextInExplanation(obj.markdownAnswers);
ResponseManager.showContextInExplanation(obj.markdownAnswers,range.index);

}
}
})
}
}
})
// this is to remove the new class that automatically added
$('.ql-clipboard').removeAttr('contenteditable')
// document.getElementsByClassName("ql-clipboard").setAttribute('contenteditable', 'false')

atom.workspace.onDidStopChangingActivePaneItem(function() {
$scope.$evalAsync();
Expand Down
2 changes: 1 addition & 1 deletion lib/response/controllers/request.controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var TooltipView = require('../../utils/requestbutton-view.js');

var _ = require('underscore')


module.exports = function(app) {
Expand Down
42 changes: 39 additions & 3 deletions lib/response/services/response_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ module.exports = function(app) {
tooltipMarkers.push(marker.marker);
}

//need to fix this function
function removeMarker(markers){
for(i=0;i<markers.length;i++){
markers.forEach(function(mk){
Expand Down Expand Up @@ -463,14 +462,51 @@ module.exports = function(app) {
}
}
},
showContextInExplanation: function(codeContext){
showContextInExplanation: function(codeContext, curose_location){
debugger
//remove all decoration
destroyAllMarkers();

//check if the window is splitted
if(atom.workspace.getPanes().length>1){

//go to the splitted tab
if(atom.workspace.getActivePane() != atom.workspace.getPanes()[0]){
if(atom.workspace.getActivePane() == atom.workspace.getPanes()[0]){
atom.workspace.activatePreviousPane();
}

var len = codeContext.code.selectedrange.length
for (var i = 0; i < len; i++) {
// var range_start_row = $scope.markdownAnswers.text.selectedrange[i].start.row
var range_start_col = codeContext.text.selectedrange[i].start.column
// var range_end_row = $scope.markdownAnswers.text.selectedrange[i].end.row
var range_end_col = codeContext.text.selectedrange[i].end.column

if (curose_location >= range_start_col && curose_location <= range_end_col) {

var editor = atom.workspace.getActiveTextEditor()
var highlights = new Range();
highlights.start.row = codeContext.code.selectedrange[i].start.row
highlights.start.column = codeContext.code.selectedrange[i].start.column
highlights.end.row = codeContext.code.selectedrange[i].end.row
highlights.end.column = codeContext.code.selectedrange[i].end.column

var explanationCodeContext = editor.markBufferRange(highlights, {
invalidate: 'inside',
});
// Decorate the lineMarker.
debugger
editor.decorateMarker(explanationCodeContext, {
class: 'test-pkg-highlight',
type: 'highlight'
});


// session.addMarker(highlights, "ace_context", "text")
break;
}
}

//
}else{
//do nothing if there is no splitted window
Expand Down
2 changes: 1 addition & 1 deletion lib/response/views/response_panel.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ <h4> Answer
<!-- <div ng-repeat='answer in helper_response.answers track by $index'> -->
<!-- Show explanation content -->
<div class='response-content'>
<div id="editor-container">
<div id="editor-container" class='inset-panel panel-bottom run-command native-key-bindings' tabindex= '-1' readonly>
</div>
</div>
<!-- </div> -->
Expand Down
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
"dependencies": {
"angular": "1.5.5",
"angular-aria": "1.5.0",
"angular-material": "^1.1.3",
"angular-moment": "1.5.5",
"angular-route": "1.5.5",
"angular-socket-io": "1.5.5",
"angular-trix": "^1.0.2",
"angular-ui-bootstrap": "1.3.3",
"angular-xeditable": "0.1.12",
Expand Down

0 comments on commit 49cdf07

Please sign in to comment.