Skip to content

Instantly share code, notes, and snippets.

@Camusensei
Forked from anonymous/example.js.coffee
Last active August 29, 2015 13:56
Show Gist options
  • Save Camusensei/9344741 to your computer and use it in GitHub Desktop.
Save Camusensei/9344741 to your computer and use it in GitHub Desktop.
findIndex = (array, callback) ->
_i = 0
while _i < array.length
return _i if callback(array[_i])
_i++
-1
$scope.saveCurrentHtmlTemplate = () ->
$scope.isEdited = true
$('#highlighter').empty()
currentHtmlTemplatePositionInArray = findIndex $scope.currentEditedHtmlFiles, (element) ->
return element.file_name == $scope.currentHtmlTemplate.file_name
if currentHtmlTemplatePositionInArray == -1
currentHtmlTemplatePositionInArray = $scope.currentEditedHtmlFiles.length
$scope.currentEditedHtmlFiles[currentHtmlTemplatePositionInArray] = $scope.currentHtmlTemplate
$scope.saveTemplate([$scope.currentHtmlTemplate])
getControllerScope "BBCtrl", (scope) ->
scope.current_page
scope.showPage scope.current_page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment