1 /* 2 * ***** BEGIN LICENSE BLOCK ***** 3 * Zimbra Collaboration Suite Web Client 4 * Copyright (C) 2007, 2009, 2010, 2013, 2014, 2016 Synacor, Inc. 5 * 6 * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at: https://www.zimbra.com/license 9 * The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 10 * have been added to cover use of software over a computer network and provide for limited attribution 11 * for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B. 12 * 13 * Software distributed under the License is distributed on an "AS IS" basis, 14 * WITHOUT WARRANTY OF ANY KIND, either express or implied. 15 * See the License for the specific language governing rights and limitations under the License. 16 * The Original Code is Zimbra Open Source Web Client. 17 * The Initial Developer of the Original Code is Zimbra, Inc. All rights to the Original Code were 18 * transferred by Zimbra, Inc. to Synacor, Inc. on September 14, 2015. 19 * 20 * All portions of the code are Copyright (C) 2007, 2009, 2010, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved. 21 * ***** END LICENSE BLOCK ***** 22 */ 23 24 25 /** 26 * 27 * @private 28 */ 29 AjxDlgUtil = { 30 31 cache : {}, 32 33 getDialogLayout : function(name, url, msg) { 34 var time = new Date().getTime(); 35 36 var txt, cache = AjxDlgUtil.cache; 37 if (cache[name]) { 38 txt = cache[name]; 39 } else { 40 // WARNING: synchronous request! 41 // Also we don't treat errors at this point >-) so you better 42 // know what you're doing. 43 var res = AjxRpc.invoke(null, url + "?v=" + time, null, null, true, 5000); 44 cache[name] = txt = res.text; 45 } 46 47 var ids = {}; 48 49 // get rid of the comments 50 txt = txt.replace(/<!--.*?-->/, ""); 51 52 // replace $msg and $id fields 53 txt = txt.replace(/\$([a-zA-Z0-9_.]+)/g, function(str, p1) { 54 if (/^([^.]+)\.(.*)$/.test(p1)) { 55 var prefix = RegExp.$1; 56 var name = RegExp.$2; 57 switch (prefix) { 58 case "id": 59 var id = ids[name]; 60 if (!id) 61 id = ids[name] = Dwt.getNextId(); 62 return id; 63 case "msg": 64 return msg[name]; 65 } 66 } 67 return str; 68 }); 69 70 return { ids: ids, html: txt }; 71 } 72 73 }; 74