diff --git a/frappe/public/js/frappe/utils/common.js b/frappe/public/js/frappe/utils/common.js
index b50a226545..c2caeebb7e 100644
--- a/frappe/public/js/frappe/utils/common.js
+++ b/frappe/public/js/frappe/utils/common.js
@@ -1,6 +1,6 @@
// common file between desk and website
-frappe.avatar = function (user, css_class, title, image_url=null, remove_avatar=false) {
+frappe.avatar = function (user, css_class, title, image_url = null, remove_avatar = false) {
let user_info;
if (user) {
// desk
@@ -47,7 +47,7 @@ frappe.avatar = function (user, css_class, title, image_url=null, remove_avatar=
}
};
-frappe.avatar_group = function(users, limit=4, options={}) {
+frappe.avatar_group = function (users, limit = 4, options = {}) {
let icon_html = '';
const display_users = users.slice(0, limit);
const extra_users = users.slice(limit);
@@ -76,7 +76,7 @@ frappe.avatar_group = function(users, limit=4, options={}) {
}
const $avatar_group =
- $(`
+ $(`
${icon_html}
${html}
`);
@@ -85,7 +85,7 @@ frappe.avatar_group = function(users, limit=4, options={}) {
return $avatar_group;
};
-frappe.ui.scroll = function(element, animate, additional_offset) {
+frappe.ui.scroll = function (element, animate, additional_offset) {
var header_offset = $(".navbar").height() + $(".page-head").height();
var top = $(element).offset().top - header_offset - cint(additional_offset);
if (animate) {
@@ -131,9 +131,9 @@ frappe.get_abbr = function (txt, max_length) {
}
frappe.gravatars = {};
-frappe.get_gravatar = function(email_id, size = 0) {
+frappe.get_gravatar = function (email_id, size = 0) {
var param = size ? ('s=' + size) : 'd=retro';
- if(!frappe.gravatars[email_id]) {
+ if (!frappe.gravatars[email_id]) {
// TODO: check if gravatar exists
frappe.gravatars[email_id] = "https://secure.gravatar.com/avatar/" + md5(email_id) + "?" + param;
}
@@ -142,47 +142,47 @@ frappe.get_gravatar = function(email_id, size = 0) {
// string commons
-window.repl =function repl(s, dict) {
- if(s==null)return '';
- for(var key in dict) {
- s = s.split("%("+key+")s").join(dict[key]);
+window.repl = function repl(s, dict) {
+ if (s == null) return '';
+ for (var key in dict) {
+ s = s.split("%(" + key + ")s").join(dict[key]);
}
return s;
}
-window.replace_all = function(s, t1, t2) {
+window.replace_all = function (s, t1, t2) {
return s.split(t1).join(t2);
}
-window.strip_html = function(txt) {
+window.strip_html = function (txt) {
return txt.replace(/<[^>]*>/g, "");
}
-window.strip = function(s, chars) {
+window.strip = function (s, chars) {
if (s) {
- var s= lstrip(s, chars)
+ var s = lstrip(s, chars)
s = rstrip(s, chars);
return s;
}
}
window.lstrip = function lstrip(s, chars) {
- if(!chars) chars = ['\n', '\t', ' '];
+ if (!chars) chars = ['\n', '\t', ' '];
// strip left
- var first_char = s.substr(0,1);
- while(in_list(chars, first_char)) {
+ var first_char = s.substr(0, 1);
+ while (in_list(chars, first_char)) {
var s = s.substr(1);
- first_char = s.substr(0,1);
+ first_char = s.substr(0, 1);
}
return s;
}
-window.rstrip = function(s, chars) {
- if(!chars) chars = ['\n', '\t', ' '];
- var last_char = s.substr(s.length-1);
- while(in_list(chars, last_char)) {
- var s = s.substr(0, s.length-1);
- last_char = s.substr(s.length-1);
+window.rstrip = function (s, chars) {
+ if (!chars) chars = ['\n', '\t', ' '];
+ var last_char = s.substr(s.length - 1);
+ while (in_list(chars, last_char)) {
+ var s = s.substr(0, s.length - 1);
+ last_char = s.substr(s.length - 1);
}
return s;
}
@@ -198,28 +198,28 @@ frappe.get_cookies = function getCookies() {
v = 1;
}
if (v === 0) {
- c.split(/[,;]/).map(function(cookie) {
+ c.split(/[,;]/).map(function (cookie) {
var parts = cookie.split(/=/, 2),
name = decodeURIComponent(parts[0].trimLeft()),
value = parts.length > 1 ? decodeURIComponent(parts[1].trimRight()) : null;
- if(value && value.charAt(0)==='"') {
- value = value.substr(1, value.length-2);
+ if (value && value.charAt(0) === '"') {
+ value = value.substr(1, value.length - 2);
}
cookies[name] = value;
});
} else {
- c.match(/(?:^|\s+)([!#$%&'*+\-.0-9A-Z^`a-z|~]+)=([!#$%&'*+\-.0-9A-Z^`a-z|~]*|"(?:[\x20-\x7E\x80\xFF]|\\[\x00-\x7F])*")(?=\s*[,;]|$)/g).map(function($0, $1) {
+ c.match(/(?:^|\s+)([!#$%&'*+\-.0-9A-Z^`a-z|~]+)=([!#$%&'*+\-.0-9A-Z^`a-z|~]*|"(?:[\x20-\x7E\x80\xFF]|\\[\x00-\x7F])*")(?=\s*[,;]|$)/g).map(function ($0, $1) {
var name = $0,
value = $1.charAt(0) === '"'
- ? $1.substr(1, -1).replace(/\\(.)/g, "$1")
- : $1;
+ ? $1.substr(1, -1).replace(/\\(.)/g, "$1")
+ : $1;
cookies[name] = value;
});
}
return cookies;
}
-frappe.is_mobile = function() {
+frappe.is_mobile = function () {
return $(document).width() < 768;
}
@@ -236,11 +236,11 @@ frappe.utils.xss_sanitise = function (string, options) {
"'": ''',
'/': '/'
};
- const REGEX_SCRIPT = /