diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index aeb9aaa70..c81921a9a 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -179,28 +179,42 @@ Danbooru.Note = { var w = $note_body.width(); var h = $note_body.height(); var golden_ratio = 1.6180339887; + var last = 0; + var x = 0; + + if ((w / h) < golden_ratio) { + var lo = 140; + var hi = 400; + do { + last = w; + x = (lo + hi) / 2; + $note_body.css("min-width", x); + w = $note_body.width(); + h = $note_body.height(); - while (w / h < golden_ratio) { - w = w * 1.025; - h = h / 1.025; - } - - while (w / h > golden_ratio) { - w = w / 1.025; - h = h * 1.025; - } - - if ($note_body.html().length < 20) { - while (h > 20) { - h = h / 1.025; - w = w * 1.025; + if ((w / h) < golden_ratio) { + lo = x; + } else { + hi = x; + } + } while ((lo < hi) && (w > last)); + } else if ($note_body[0].scrollWidth <= $note_body.width()) { + var lo = 20; + var hi = w; + + do { + x = (lo + hi) / 2; + $note_body.css("min-width", x); + if ($note_body.height() > h) { + lo = x + } else { + hi = x; + } + } while ((hi - lo) > 4) + if ($note_body.height() > h) { + $note_body.css("minWidth", hi); } } - - $note_body.css({ - width: w, - height: "auto" - }); }, set_text: function($note_body, text) { diff --git a/app/assets/stylesheets/specific/notes.css.scss b/app/assets/stylesheets/specific/notes.css.scss index b6bd09e93..8a1225652 100644 --- a/app/assets/stylesheets/specific/notes.css.scss +++ b/app/assets/stylesheets/specific/notes.css.scss @@ -6,7 +6,7 @@ div#note-container { position: absolute; border: 1px solid black; background: #FFE; - min-width: 10px; + min-width: 140px; min-height: 1em; line-height: normal; cursor: pointer; diff --git a/app/logical/upload_error_checker.rb b/app/logical/upload_error_checker.rb index 4fe1a5ebb..9ee480560 100644 --- a/app/logical/upload_error_checker.rb +++ b/app/logical/upload_error_checker.rb @@ -4,13 +4,13 @@ require 'mail' class UploadErrorChecker def check! - count = Upload.where("status like 'error%' and created_at >= ?", 1.hour.ago).count - if count > 5 + uploads = Upload.where("status like 'error%' and created_at >= ?", 1.hour.ago).all + if uploads.size > 5 mail = Mail.new do from "webmaster@danbooru.donmai.us" to "r888888888@gmail.com" - subject "[danbooru] Upload error count at #{count}" - body "nt" + subject "[danbooru] Upload error count at #{uploads.size}" + body uploads.map {|x| x.status}.join("\n") end mail.delivery_method :sendmail mail.deliver