Skip to content
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ nbproject

# Generated from .drone.star
.drone.yml
js/package-lock.json
js/public/app.min.js
js/public/app.min.js.map
12 changes: 12 additions & 0 deletions css/notes.css
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@
z-index: -1;
border-top: 1px solid rgba(120, 120, 120, 0.5);
}
.mdedit .code-block {
background: rgba(120, 120, 120, 0.1);
padding: 0 0.5em;
margin: 0.5em 0;
display: block;
}


/* hanging punctuation */
Expand All @@ -167,3 +173,9 @@
padding-left: 90px;
}
}

#searchnotes {
width: 100%;
border-left: 0px;
padding-left: 12px;
}
19 changes: 19 additions & 0 deletions img/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "Notes",
"start_url": "../../../apps/notes/#/",
"icons": [
{
"src": "./favicon-touch.png",
"type": "image/png",
"sizes": "128x128"
},
{
"src": "./favicon-touch.svg",
"type": "image/svg+xml",
"sizes": "any"
}
],
"display": "standalone",
"theme_color": "#041e42",
"background_color": "#ffffff"
}
35 changes: 34 additions & 1 deletion js/app/controllers/notescontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,37 @@ app.controller('NotesController', function($routeParams, $scope, $location,
});
};

});
var searchbox = $('#searchnotes');

initSearch();

function initSearch() {
$scope.queryString = searchbox.val().trim();

/** Conduct the search when there is a pause in typing in text */
var checkQueryChange = _.debounce(function() {
if ($scope.queryString != searchbox.val().trim()) {
onEnterSearchString();
}
}, 250);
searchbox.bind('propertychange change keyup input paste', checkQueryChange);

/** Run search when enter pressed within the searchbox */
searchbox.bind('keydown', function (event) {
if (event.which === 13) {
onEnterSearchString();
}
});
}

function onEnterSearchString() {
setQueryString(searchbox.val().trim());
}

function setQueryString(query) {
$scope.$apply(() => {
$scope.queryString = query;
});
}

});
10 changes: 10 additions & 0 deletions js/app/filters/noteFilter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
app.filter('noteFilter', function() {
'use strict';
return function (items, searchString) {
if (!searchString || searchString.length == 0)
return items;

var regex = new RegExp(searchString, 'i');
return items.filter(x => x.title.match(regex) || x.content.match(regex));
};
});
11 changes: 9 additions & 2 deletions js/config/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,16 @@ config(function($provide, $routeProvider, RestangularProvider, $httpProvider,
Restangular.one('notes', noteId).get().then(function (note) {
is.loading = false;
deferred.resolve(note);
}, function () {
}, function (response) {
is.loading = false;
deferred.reject();

// Token expired
if (response.status == 412) {
OC.reload();
}
else {
deferred.reject();
}
});

return deferred.promise;
Expand Down
6 changes: 5 additions & 1 deletion templates/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@
oc-click-focus="{ selector: '#app-content textarea' }">
<a href='#'>+ <span><?php p($l->t('New note')); ?></span></a>
</li>
<!-- search notes button -->
<li>
<input id="searchnotes" type="search" name="searchnotes" value="" autocomplete="off" placeholder="Search in notes" />
</li>
<!-- notes list -->
<li ng-repeat="note in notes|orderBy:['-favorite','-modified']"
<li ng-repeat="note in notes|orderBy:['-favorite','-modified']|noteFilter:queryString"
ng-class="{ active: note.id == route.noteId }">
<a href="#/notes/{{ note.id }}">
{{ note.title | noteTitle }}
Expand Down
2 changes: 0 additions & 2 deletions templates/note.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
<div id="app-navigation-toggle" class="icon-menu" style="display:none;"></div>
<pre editor notes-timeout-change="save()" notes-autofocus class="editor" ng-class="{saving: isSaving()}">{{note.content}}</pre>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change fixes #369. I'm very interested to see it merged @DeepDiver1975 @jnweiger

<div class="note-meta">{{note.content | wordCount}}</div>
</div>