diff --git a/static/js/app/gophish.js b/static/js/app/gophish.js index caa1dc83..28cc5762 100644 --- a/static/js/app/gophish.js +++ b/static/js/app/gophish.js @@ -1,11 +1,5 @@ var app = angular.module('gophish', ['ngTable', 'ngResource', 'ui.bootstrap']); -app.filter('unsafe', function($sce) { - return function(val) { - return $sce.trustAsHtml(val); - }; -}); - app.factory('CampaignService', function($resource) { return $resource('/api/campaigns/:id?api_key=' + API_KEY, { id: "@id" @@ -296,4 +290,37 @@ app.controller('TemplateCtrl', function($scope, TemplateService, ngTableParams) $scope.mainTableParams.reload(); }); } -}) \ No newline at end of file +}) + +// Example provided by http://docs.angularjs.org/api/ng/type/ngModel.NgModelController +app.directive('contenteditable', function() { + return { + restrict: 'A', // only activate on element attribute + require: '?ngModel', // get a hold of NgModelController + link: function(scope, element, attrs, ngModel) { + if(!ngModel) return; // do nothing if no ng-model + + // Specify how UI should be updated + ngModel.$render = function() { + element.html(ngModel.$viewValue || ''); + }; + + // Listen for change events to enable binding + element.on('blur keyup change', function() { + scope.$apply(read); + }); + read(); // initialize + + // Write data to the model + function read() { + var html = element.html(); + // When we clear the content editable the browser leaves a
behind + // If strip-br attribute is provided then we strip this out + if( attrs.stripBr && html == '
' ) { + html = ''; + } + ngModel.$setViewValue(html); + } + } + }; + }); \ No newline at end of file diff --git a/templates/templates.html b/templates/templates.html index 614513f5..cb063ebb 100644 --- a/templates/templates.html +++ b/templates/templates.html @@ -83,7 +83,7 @@
-
+