diff --git a/public/js/website_utils.js b/public/js/website_utils.js index 48124df29ef..65f7a691537 100644 --- a/public/js/website_utils.js +++ b/public/js/website_utils.js @@ -1,35 +1,67 @@ var erpnext = {}; +var wn = {}; // Add / update a new Lead / Communication // subject, sender, description erpnext.send_message = function(opts) { + wn.call({ + type: "POST", + method: "website.helpers.contact.send_message", + args: opts, + callback: opts.callback + }) +} + +wn.call = function(opts) { if(opts.btn) { + var $spinner = $('').appendTo($(opts.btn).parent()) $(opts.btn).attr("disabled", "disabled"); } - + + if(opts.msg) { + $(opts.msg).toggle(false); + } + + // get or post? + if(!opts.args._type) { + opts.args._type = opts.type || "GET"; + } + + // method + if(opts.method) { + opts.args.cmd = opts.method; + } + + // stringify + $.each(opts.args, function(key, val) { + if(typeof val != "string") { + opts.args[key] = JSON.stringify(val); + } + }); + $.ajax({ type: "POST", url: "server.py", - data: { - cmd: "website.helpers.contact.send_message", - subject: opts.subject, - sender: opts.sender, - status: opts.status, - _type: "POST", - message: typeof opts.message == "string" - ? opts.message - : JSON.stringify(opts.message) - }, + data: opts.args, dataType: "json", success: function(data) { if(opts.btn) { $(opts.btn).attr("disabled", false); + $spinner.remove(); } - if(opts.callback) + if(data.exc) { + console.log(data.exc); + } + if(opts.msg && data.message) { + $(opts.msg).html(data.message).toggle(true); + } + if(opts.callback) opts.callback(data); } }); + + return false; } // Setup the user tools @@ -37,11 +69,8 @@ erpnext.send_message = function(opts) { $(document).ready(function() { // update login var full_name = getCookie("full_name"); - if(full_name && full_name.substr(0,1)=='"') { - full_name = full_name.substr(1, full_name.length-2); - } if(full_name) { - $("#user-tools").html(repl('%(full_name)s | \ + $("#user-tools").html(repl('%(full_name)s | \ (%(count)s) | \ ', { full_name: full_name, @@ -79,49 +108,52 @@ function repl(s, dict) { } function getCookie(name) { - return getCookies()[name]; + return getCookies()[name]; } function getCookies() { - var c = document.cookie, v = 0, cookies = {}; - if (document.cookie.match(/^\s*\$Version=(?:"1"|1);\s*(.*)/)) { - c = RegExp.$1; - v = 1; - } - if (v === 0) { - c.split(/[,;]/).map(function(cookie) { - var parts = cookie.split(/=/, 2), - name = decodeURIComponent(parts[0].trimLeft()), - value = parts.length > 1 ? decodeURIComponent(parts[1].trimRight()) : null; - 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) { - var name = $0, - value = $1.charAt(0) === '"' - ? $1.substr(1, -1).replace(/\\(.)/g, "$1") - : $1; - cookies[name] = value; - }); - } - return cookies; + var c = document.cookie, v = 0, cookies = {}; + if (document.cookie.match(/^\s*\$Version=(?:"1"|1);\s*(.*)/)) { + c = RegExp.$1; + v = 1; + } + if (v === 0) { + 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.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) { + var name = $0, + value = $1.charAt(0) === '"' + ? $1.substr(1, -1).replace(/\\(.)/g, "$1") + : $1; + cookies[name] = value; + }); + } + return cookies; } if (typeof String.prototype.trimLeft !== "function") { - String.prototype.trimLeft = function() { - return this.replace(/^\s+/, ""); - }; + String.prototype.trimLeft = function() { + return this.replace(/^\s+/, ""); + }; } if (typeof String.prototype.trimRight !== "function") { - String.prototype.trimRight = function() { - return this.replace(/\s+$/, ""); - }; + String.prototype.trimRight = function() { + return this.replace(/\s+$/, ""); + }; } if (typeof Array.prototype.map !== "function") { - Array.prototype.map = function(callback, thisArg) { - for (var i=0, n=this.length, a=[]; i +

Change my name, password

+

My Orders

+
+
+
+
+
+
+

My Tickets

+
+
+
+
+
+ + +{% endblock %} \ No newline at end of file diff --git a/website/templates/pages/profile.html b/website/templates/pages/profile.html new file mode 100644 index 00000000000..d0d4059ae19 --- /dev/null +++ b/website/templates/pages/profile.html @@ -0,0 +1,51 @@ +{% extends "html/page.html" %} + +{% set title="My Profile" %} + +{% block content %} +
+

My Profile

+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+ +{% endblock %}