Skip to content

Commit

Permalink
#352 Templating 2
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed Mar 17, 2023
1 parent 3fc6242 commit 4793799
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
20 changes: 13 additions & 7 deletions config/js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,10 +623,7 @@ function initialize() {
) {
$("#tab_look #look_fullscreen").prop("checked", true);
}
if (
cData.look &&
(cData.look.info == true)
) {
if (cData.look && cData.look.info == true) {
$("#tab_look #look_info").prop("checked", true);
}
$("#tab_look #look_infourl").val(
Expand Down Expand Up @@ -2204,9 +2201,18 @@ function save(returnJSON) {
);
return;
}
toolsjson["variables"] = JSON.parse(
editors[tData[i].name].getValue()
);
try {
toolsjson["variables"] = JSON.parse(
editors[tData[i].name].getValue()
);
} catch (err) {
toast(
"error",
`Error: ${tData[i].name} tool json is badly formed.`,
5000
);
return;
}
}
}
json.tools.push(toolsjson);
Expand Down
19 changes: 19 additions & 0 deletions src/essence/Basics/Formulae_/Formulae_.js
Original file line number Diff line number Diff line change
Expand Up @@ -2292,6 +2292,25 @@ var Formulae_ = {
]
: [arr]
},
/**
* From https://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable-string
*/
humanFileSize(bytes, si) {
if (bytes == null) return null
var thresh = si ? 1000 : 1024
if (Math.abs(bytes) < thresh) {
return bytes + ' B'
}
var units = si
? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
var u = -1
do {
bytes /= thresh
++u
} while (Math.abs(bytes) >= thresh && u < units.length - 1)
return bytes.toFixed(1) + ' ' + units[u]
},
getBrowser() {
//Check if browser is IE
if (navigator.userAgent.search('MSIE') >= 0) {
Expand Down

0 comments on commit 4793799

Please sign in to comment.