nextcloud /
notes
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | import AppGlobal from './mixins/AppGlobal' |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 2 | import store from './store' |
||
|
0 ignored issues
–
show
'import' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: Loading history...
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 3 | import axios from 'nextcloud-axios' |
||
|
0 ignored issues
–
show
'import' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: Loading history...
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 4 | |||
| 5 | export default { |
||
|
0 ignored issues
–
show
'export' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: Loading history...
|
|||
| 6 | |||
| 7 | tn: AppGlobal.methods.tn, |
||
| 8 | |||
| 9 | url(url) { |
||
|
0 ignored issues
–
show
|
|||
| 10 | url = `/apps/notes${url}` |
||
|
0 ignored issues
–
show
'template literal syntax' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: Loading history...
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 11 | return OC.generateUrl(url) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 12 | }, |
||
| 13 | |||
| 14 | setSettings(settings) { |
||
|
0 ignored issues
–
show
|
|||
| 15 | return axios |
||
| 16 | .put(this.url('/settings'), settings) |
||
| 17 | .then(response => { |
||
|
0 ignored issues
–
show
'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: Loading history...
|
|||
| 18 | let settings = response.data |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 19 | store.commit('setSettings', settings) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 20 | return settings |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 21 | }) |
||
| 22 | .catch(err => { |
||
|
0 ignored issues
–
show
'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: Loading history...
|
|||
| 23 | console.error(err) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 24 | // TODO error handling |
||
| 25 | }) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 26 | }, |
||
| 27 | |||
| 28 | fetchNotes() { |
||
|
0 ignored issues
–
show
|
|||
| 29 | return axios |
||
| 30 | .get(this.url('/notes')) |
||
| 31 | .then(response => { |
||
|
0 ignored issues
–
show
'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: Loading history...
|
|||
| 32 | store.commit('setSettings', response.data.settings) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 33 | store.dispatch('addAll', response.data.notes) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 34 | if (response.data.errorMessage) { |
||
| 35 | OC.Notification.showTemporary(response.data.errorMessage) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 36 | } |
||
| 37 | return response.data |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 38 | }) |
||
| 39 | .catch(err => { |
||
|
0 ignored issues
–
show
'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: Loading history...
|
|||
| 40 | console.error(err) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 41 | // TODO error handling |
||
| 42 | }) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 43 | }, |
||
| 44 | |||
| 45 | fetchNote(noteId) { |
||
|
0 ignored issues
–
show
|
|||
| 46 | return axios |
||
| 47 | .get(this.url('/notes/' + noteId)) |
||
| 48 | .then(response => { |
||
|
0 ignored issues
–
show
'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: Loading history...
|
|||
| 49 | store.commit('add', response.data) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 50 | return response.data |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 51 | }) |
||
| 52 | .catch(err => { |
||
|
0 ignored issues
–
show
'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: Loading history...
|
|||
| 53 | console.error(err) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 54 | // TODO error handling |
||
| 55 | }) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 56 | }, |
||
| 57 | |||
| 58 | noteExists(noteId) { |
||
|
0 ignored issues
–
show
|
|||
| 59 | return store.getters.noteExists(noteId) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 60 | }, |
||
| 61 | |||
| 62 | createNote(category) { |
||
|
0 ignored issues
–
show
|
|||
| 63 | return axios |
||
| 64 | .post(this.url('/notes'), { category: category }) |
||
| 65 | .then(response => { |
||
|
0 ignored issues
–
show
'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: Loading history...
|
|||
| 66 | store.commit('add', response.data) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 67 | return response.data |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 68 | }) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 69 | }, |
||
| 70 | |||
| 71 | updateNote(note) { |
||
|
0 ignored issues
–
show
|
|||
| 72 | return axios |
||
| 73 | .put(this.url('/notes/' + note.id), { content: note.content }) |
||
| 74 | .then(response => { |
||
|
0 ignored issues
–
show
'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: Loading history...
|
|||
| 75 | let updated = response.data |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 76 | note.error = false |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 77 | note.title = updated.title |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 78 | note.modified = updated.modified |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
There were too many errors found in this file; checking aborted after 45%.
If JSHint finds too many errors in a file, it aborts checking altogether because it suspects a configuration issue. Further Reading: Loading history...
|
|||
| 79 | if (updated.content === note.content) { |
||
| 80 | note.unsaved = false |
||
| 81 | } |
||
| 82 | store.commit('add', note) |
||
| 83 | return note |
||
| 84 | }) |
||
| 85 | .catch(err => { |
||
| 86 | console.error(err) |
||
| 87 | note.error = true |
||
| 88 | // TODO error handling |
||
| 89 | }) |
||
| 90 | }, |
||
| 91 | |||
| 92 | deleteNote(noteId) { |
||
| 93 | return axios |
||
| 94 | .delete(this.url('/notes/' + noteId)) |
||
| 95 | .then(() => { |
||
| 96 | store.commit('remove', noteId) |
||
| 97 | }) |
||
| 98 | }, |
||
| 99 | |||
| 100 | setFavorite(noteId, favorite) { |
||
| 101 | return axios |
||
| 102 | .put(this.url('/notes/' + noteId + '/favorite'), { favorite: favorite }) |
||
| 103 | .then(response => { |
||
| 104 | store.commit('setNoteAttribute', { noteId: noteId, attribute: 'favorite', value: response.data }) |
||
| 105 | }) |
||
| 106 | .catch(err => { |
||
| 107 | console.error(err) |
||
| 108 | // TODO error handling |
||
| 109 | }) |
||
| 110 | }, |
||
| 111 | |||
| 112 | setCategory(noteId, category) { |
||
| 113 | return axios |
||
| 114 | .put(this.url('/notes/' + noteId + '/category'), { category: category }) |
||
| 115 | .then(response => { |
||
| 116 | let realCategory = response.data |
||
| 117 | if (category !== realCategory) { |
||
| 118 | OC.Notification.showTemporary( |
||
| 119 | this.tn('Updating the note\'s category has failed. Is the target directory writable?') |
||
| 120 | ) |
||
| 121 | } |
||
| 122 | store.commit('setNoteAttribute', { noteId: noteId, attribute: 'category', value: realCategory }) |
||
| 123 | }) |
||
| 124 | .catch(err => { |
||
| 125 | console.error(err) |
||
| 126 | // TODO error handling |
||
| 127 | }) |
||
| 128 | }, |
||
| 129 | |||
| 130 | saveNote(noteId, manualSave = false) { |
||
| 131 | store.commit('addUnsaved', noteId) |
||
| 132 | if (manualSave) { |
||
| 133 | store.commit('setManualSave', true) |
||
| 134 | } |
||
| 135 | this._saveNotes() |
||
| 136 | }, |
||
| 137 | _saveNotes() { |
||
| 138 | let unsaved = store.state.unsaved |
||
| 139 | let keys = Object.keys(unsaved) |
||
| 140 | if (store.state.isSaving || keys.length === 0) { |
||
| 141 | return |
||
| 142 | } |
||
| 143 | store.commit('setSaving', true) |
||
| 144 | let promises = [] |
||
| 145 | for (let i = 0; i < keys.length; i++) { |
||
| 146 | let note = unsaved[keys[i]] |
||
| 147 | promises.push(this.updateNote(note)) |
||
| 148 | } |
||
| 149 | store.commit('clearUnsaved') |
||
| 150 | Promise.all(promises).finally(() => { |
||
| 151 | store.commit('setSaving', false) |
||
| 152 | store.commit('setManualSave', false) |
||
| 153 | this._saveNotes() |
||
| 154 | }) |
||
| 155 | }, |
||
| 156 | |||
| 157 | saveNoteManually(noteId) { |
||
| 158 | store.commit('setNoteAttribute', { noteId: noteId, attribute: 'error', value: false }) |
||
| 159 | this.saveNote(noteId, true) |
||
| 160 | }, |
||
| 161 | |||
| 162 | getCategories(maxLevel, details) { |
||
| 163 | return store.getters.getCategories(maxLevel, details) |
||
| 164 | }, |
||
| 165 | |||
| 166 | categoryLabel(category) { |
||
| 167 | return category === '' ? this.tn('Uncategorized') : category.replace(/\//g, ' / ') |
||
| 168 | }, |
||
| 169 | } |
||
| 170 |
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code.
Further Reading: