mirror of
https://github.com/JanGross/quicknotes.git
synced 2025-12-01 07:37:18 +01:00
Save note colors on HEX with upper case
This commit is contained in:
16
js/script.js
16
js/script.js
@@ -202,6 +202,20 @@ View.prototype = {
|
|||||||
modaltitle.html("");
|
modaltitle.html("");
|
||||||
modalcontent.html("");
|
modalcontent.html("");
|
||||||
},
|
},
|
||||||
|
colorToHex: function(color) {
|
||||||
|
if (color.substr(0, 1) === '#') {
|
||||||
|
return color.toUpperCase();;
|
||||||
|
}
|
||||||
|
var digits = /(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec(color);
|
||||||
|
|
||||||
|
var red = parseInt(digits[2]);
|
||||||
|
var green = parseInt(digits[3]);
|
||||||
|
var blue = parseInt(digits[4]);
|
||||||
|
|
||||||
|
var rgb = blue | (green << 8) | (red << 16);
|
||||||
|
|
||||||
|
return digits[1] + '#' + rgb.toString(16).toUpperCase();
|
||||||
|
},
|
||||||
renderContent: function () {
|
renderContent: function () {
|
||||||
var source = $('#content-tpl').html();
|
var source = $('#content-tpl').html();
|
||||||
var template = Handlebars.compile(source);
|
var template = Handlebars.compile(source);
|
||||||
@@ -301,7 +315,7 @@ View.prototype = {
|
|||||||
var id = modalnote.data('id');
|
var id = modalnote.data('id');
|
||||||
var title = modaltitle.html();
|
var title = modaltitle.html();
|
||||||
var content = modalcontent.html();
|
var content = modalcontent.html();
|
||||||
var color = modalnote.css("background-color");
|
var color = self.colorToHex(modalnote.css("background-color"));
|
||||||
|
|
||||||
self._notes.updateId(id, title, content, color).done(function () {
|
self._notes.updateId(id, title, content, color).done(function () {
|
||||||
self._notes.unsetActive();
|
self._notes.unsetActive();
|
||||||
|
|||||||
Reference in New Issue
Block a user