2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Affero General Public License version 3 as published by the
8 * Free Software Foundation with the addition of the following permission added
9 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
18 * You should have received a copy of the GNU Affero General Public License along with
19 * this program; if not, see http://www.gnu.org/licenses or write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26 * The interactive user interfaces in modified source and object code versions
27 * of this program must display Appropriate Legal Notices, as required under
28 * Section 5 of the GNU Affero General Public License version 3.
30 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31 * these Appropriate Legal Notices must retain the display of the "Powered by
32 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33 * technical reasons, the Appropriate Legal Notices must display the words
34 * "Powered by SugarCRM".
35 ********************************************************************************/
39 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
42 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
44 <title>SUGAR Arithmetic Engine (JS)</title>
48 <script type="text/javascript" src="../../cache/include/javascript/sugar_grp1_yui.js"></script>
49 <script type="text/javascript" src="../../cache/include/javascript/sugar_grp1.js"></script>
52 <!-- sugar expressions js -->
53 <!-- <script language="javascript" src="./javascript/ExpressionJS.php"></script> -->
55 <script language="javascript" src="../../include/Expressions/javascript/expressions.js"></script>
56 <script language="javascript" src="../../cache/Expressions/functions_cache.js"></script>
59 <script language="javascript">
60 YAHOO.util.Event.onDOMReady( function() {
61 var container = new YAHOO.widget.Overlay("container", {fixedcenter:true, visible:true, width:"400px"});
65 function checkEnter(e) {
66 var characterCode; // literal character code will be stored in this variable
68 characterCode = e.keyCode;
70 if ( characterCode == 13 ) {
72 document.getElementById('expression').select();
81 function print_r(o, d) {
84 if (typeof(o) == "object") {
86 for (var j = 0; j < d; j++) {
91 for (var j = 0; j <= d; j++) {
94 ret += "[" + i + "] => " + print_r(o[i], d + 2) + "\n";
96 for (var j = 0; j < d; j++) {
100 } else if (typeof(o != "undefined")){
107 function evalExpression() {
108 var parser = new SUGAR.expressions.ExpressionParser();
109 var output = document.getElementById('results');
110 var expression = document.getElementById('expression').value;
112 if ( expression == 'clear' ) {
119 out += '<div class="expression">' + expression + ':</div>';
122 var result = parser.evaluate(expression);
123 result = result.evaluate();
124 out += '<div class="result" id="js_result_' + resultCount + '">' + print_r(result, 0) + "</div>";
128 out += '<div class="result" id="js_result_' + resultCount + '">' + e + "</div>";
131 out += "<div class='clearer'></div>";
135 output.innerHTML = "<div class='casing" + x + "'>" + out + "</div>" + output.innerHTML;
136 ajaxEvalExpression(expression);
139 function ajaxEvalExpression(expr) {
140 YAHOO.util.Connect.asyncRequest('POST', 'expression_engine_eval.php',
142 success: function(o){
143 var output = document.getElementById('results');
144 output.innerHTML = "<div class='ajax result' id='php_result_" + resultCount + "'>" + o.responseText + "</div>" + output.innerHTML;
147 }, "expression=" + expr);
154 document.getElementById('results').innerHTML = "";
158 window.onload = init;
163 <style type="text/css">
167 font-family: Trebuchet MS;
191 font-family: Verdana;
205 border: 1px solid #cccccc;
218 border: 1px solid #000;
229 #input INPUT[type=text] {
230 font-family: Courier New;
239 <!-- div id="overlay" style="width: 100%; height: 100%;position: absolute; left: 0px; top: 0px; background: #BFBFBF; z-index: -10;"></div -->
248 <input type="text" id="expression" style="width: 288px" onkeypress="checkEnter(event)">
249 <input type="button" id="evaluate_button" value="Evaluate" onclick="evalExpression()">
250 <input type="button" id="clear_button" value="Clear" onclick="init()">