2015-04-12 08:42:47 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-05-26 16:41:06 +02:00
|
|
|
var MARKDOWN = "markdown";
|
|
|
|
var PLAINTEXT = "plaintext";
|
|
|
|
|
2015-04-12 08:42:47 +02:00
|
|
|
angular.module('markdownFormatWdiffApp')
|
2015-05-26 16:41:06 +02:00
|
|
|
.controller('CompareShowCtrl', function ($scope, $routeParams, $http, $location) {
|
|
|
|
$scope.wdiff = '';
|
|
|
|
$scope.before = '';
|
|
|
|
$scope.after = '';
|
2015-04-12 08:42:47 +02:00
|
|
|
$scope.isShowWdiff = true;
|
2015-05-26 16:41:06 +02:00
|
|
|
$scope.isMarkdownFormat = true;
|
|
|
|
|
2015-04-12 08:42:47 +02:00
|
|
|
|
2015-05-26 16:41:06 +02:00
|
|
|
var paramFormat = $location.hash();
|
|
|
|
if (paramFormat == "plain" || paramFormat == "plaintext")
|
|
|
|
$scope.isMarkdownFormat = false;
|
2015-04-12 08:42:47 +02:00
|
|
|
|
|
|
|
// if routeParams specifies a user, restrict the query to that user
|
|
|
|
var path = '/api/compare/wdiff/' + $routeParams.id;
|
|
|
|
$http.get(path).success(function(comparison) {
|
|
|
|
$scope.wdiff = comparison.wdiff;
|
2015-05-26 16:41:06 +02:00
|
|
|
|
2015-04-12 08:42:47 +02:00
|
|
|
$scope.before = comparison.a;
|
|
|
|
$scope.after = comparison.b;
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.showBefore = function() {
|
|
|
|
$scope.isShowBefore = true;
|
|
|
|
$scope.isShowAfter = false;
|
|
|
|
$scope.isShowWdiff = false;
|
|
|
|
}
|
|
|
|
$scope.showAfter = function() {
|
|
|
|
$scope.isShowBefore = false;
|
|
|
|
$scope.isShowAfter = true;
|
|
|
|
$scope.isShowWdiff = false;
|
|
|
|
}
|
|
|
|
$scope.showWdiff = function() {
|
|
|
|
$scope.isShowBefore = false;
|
|
|
|
$scope.isShowAfter = false;
|
|
|
|
$scope.isShowWdiff = true;
|
|
|
|
}
|
|
|
|
|
2015-05-26 16:41:06 +02:00
|
|
|
$scope.toggleMarkdownFormat = function() {
|
|
|
|
if ($scope.isMarkdownFormat) {
|
|
|
|
$scope.isMarkdownFormat = false;
|
|
|
|
$location.hash('plaintext');
|
|
|
|
$location.replace();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$scope.isMarkdownFormat = true;
|
|
|
|
$location.hash('markdown');
|
|
|
|
$location.replace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-12 08:42:47 +02:00
|
|
|
})
|