From 95b6eba2ad034d48c1b56576a2c665b4bb3abf72 Mon Sep 17 00:00:00 2001 From: Javierma87 Date: Mon, 4 Apr 2016 18:48:47 +0200 Subject: [PATCH] Changed message shown to user using sprintf and improved 'if' checks --- .../static/js/app/viewmodels/files.js | 53 +++++++++++-------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/src/octoprint/static/js/app/viewmodels/files.js b/src/octoprint/static/js/app/viewmodels/files.js index fed4f08f6..343af0137 100644 --- a/src/octoprint/static/js/app/viewmodels/files.js +++ b/src/octoprint/static/js/app/viewmodels/files.js @@ -454,35 +454,44 @@ $(function() { } if(warn) { - var warning = "

" + gettext("Revise file ")+ data["name"] + "

"; + var warning = "

" + _.sprintf(gettext("Revise file %s"), data["name"]) + "

"; var info=""; - if(volumeInfo.origin=="lowerleft" && printingArea["maxX"]>volumeInfo.width) + if(volumeInfo.origin=="lowerleft") { - info=info+"Profile's width: "+volumeInfo.width+"\n Object's width: "+ printingArea["maxX"]+"\n"; + if(printingArea["maxX"]>volumeInfo.width) + { + info=info+_.sprintf(gettext("Profile's max. X: %s\n Object's max. X: %s\n"),volumeInfo.width,printingArea["maxX"]); + } + if(printingArea["maxY"]>volumeInfo.depth) + { + info=info+_.sprintf(gettext("Profile's max. Y: %s\n Object's max. Y: %s\n"),volumeInfo.depth, printingArea["maxY"]); + } } - if(volumeInfo.origin=="lowerleft" && printingArea["maxY"]>volumeInfo.depth) + else { - info=info+"Profile's depth: "+volumeInfo.depth+"\n Object's depth: "+ printingArea["maxY"]+"\n"; - } - if(volumeInfo.origin=="center" && printingArea["maxX"]>(volumeInfo.width/2)) - { - info=info+"Profile's width (center origin): "+(volumeInfo.width/2)+"\n Object's width: "+ printingArea["maxX"]+"\n"; - } - if(volumeInfo.origin=="center" && Math.abs(printingArea["minX"])>(volumeInfo.width/2)) - { - info=info+"Profile's width (center origin): "+(volumeInfo.width/2)+"\n Object's width: "+ printingArea["minX"]+"\n"; - } - if(volumeInfo.origin=="center" && printingArea["maxY"]>(volumeInfo.depth/2)) - { - info=info+"Profile's depth (center origin): "+(volumeInfo.depth/2)+"\n Object's depth: "+ printingArea["maxY"]+"\n"; - } - if(volumeInfo.origin=="center" && Math.abs(printingArea["minY"])>(volumeInfo.depth/2)) - { - info=info+"Profile's depth (center origin): "+(volumeInfo.depth/2)+"\n Object's depth: "+ printingArea["minY"]+"\n"; + if(volumeInfo.origin=="center") + { + if(Math.abs(printingArea["minX"])>(volumeInfo.width/2)) + { + info=info+_.sprintf(gettext("Profile's min. X: %s\n Object's min. X: %s\n"),-(volumeInfo.width/2),printingArea["minX"]); + } + if(printingArea["maxX"]>(volumeInfo.width/2)) + { + info=info+_.sprintf(gettext("Profile's max. X: %s\n Object's max. X: %s\n"),(volumeInfo.width/2),printingArea["maxX"]); + } + if(Math.abs(printingArea["minY"])>(volumeInfo.depth/2)) + { + info=info+_.sprintf(gettext("Profile's min. Y: %s\n Object's min. Y: %s\n"),-(volumeInfo.depth/2),printingArea["minY"]); + } + if(printingArea["maxY"]>(volumeInfo.depth/2)) + { + info=info+_.sprintf(gettext("Profile's max. Y: %s\n Object's max. Y: %s)\n"),(volumeInfo.depth/2),printingArea["maxY"]); + } + } } if(printingArea["maxZ"]>volumeInfo.height) { - info=info+"Profile's height: "+volumeInfo.height+"\n Object's height: "+ printingArea["maxZ"]+"\n"; + info=info+_.sprintf(gettext("Profile's max. Z: %s\n Object's max. Z: %s"),volumeInfo.height,printingArea["maxZ"]); } warning += pnotifyAdditionalInfo("
"+info+"
"); new PNotify({