Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
BP1: Javascript Code Generator
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/../common/cb.Global.php');
function generateInjectLocalizationScript($inForm) {
global $fields, $busobject;
echo "<script>";
echo "$(document).ready(function() {";
echo "var locfields = {";
foreach ($fields as $key => $value) {
echo '"label_' . $value["name"] . '": "' . $busobject . "." . $value["name"] . '",';
if ($inForm && $value["note"]) {
echo '"note_' . $value["name"] . '": "' . $busobject . ".note." . $value["name"] . '",';
}
}
echo "};";
echo "injectLocalization(locfields);";
echo "});";
echo "</script>";
}
function generateInjectContentDetailEditors() {
global $fields;
echo "<script>";
echo 'function injectContentDetailEditors(id) {';
foreach ($fields as $key => $value) {
$str = '$("#'. $value["name"] . '").eip("/"+getBusinessObjectFromURLPath()+"/fetch.php?action=update&id="+id,{ select_text: true';
if (!IsNullOrEmptyString($value["editfield_class"])) {
$str = $str . ',editfield_class : "' . $value["editfield_class"] . '"';
}
$str= $str . '});';
echo $str;
$str = "";
}
echo "}";
echo "</script>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment