Topic: Something missing in ui_view.inc

Some { or } missing from the functions below and I am not sure which functions belong to which functions (if they are nested functions)?
The code starts around line 830.

function get_js_date_picker()
{
    global $go_debug;
    $fpath = company_path().'/js_cache/'.'date_picker.js';

    if (!file_exists($fpath) || $go_debug) {

    global $dateseps, $date_system, $tmonths;

    $how = user_date_format();                // 0 = us/ca, 1 = eu, au, nz, 2 = jp, sw
    $sep = $dateseps[user_date_sep()];        // date separator
    $wstart = (($date_system == 1 || $date_system == 2 || $date_system == 3) ? 6 : ($how == 0 || $how == 3 ? 0 : 1));    // weekstart (sun = 0, mon = 1)
    $months = array(_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),_("August"),_("September"),_("October"),_("November"),_("December"));
    $wdays = array(_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa"));
    $wno = _("W"); // week no
    $back = _("Back");
    if ($date_system == 1)
        list($cyear, $cmon, $cday) = gregorian_to_jalali(date("Y"), date("n"), date("j"));
    else if ($date_system == 2)
        list($cyear, $cmon, $cday) = gregorian_to_islamic(date("Y"), date("n"), date("j"));


    $js = "               
function positionInfo(object) {
  var p_elm = object;
  this.getElementLeft = getElementLeft;
  function getElementLeft() {
    var x = 0;
    var elm;
    if(typeof(p_elm) == 'object'){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    while (elm != null) {
      x+= elm.offsetLeft;
      elm = elm.offsetParent;
    }
    return parseInt(x);
  }
  this.getElementWidth = getElementWidth;

Re: Something missing in ui_view.inc

If you want to look at the js file created from this PHP function, then please look into file /company/0/js_cache/date_picker.js.

Here you can see that everything is ok. It is quite normal to have function inside another function in Javascript.

/Joe

Re: Something missing in ui_view.inc

I know, but the opening and closing {} does not match.
Also the line:
    $js = "

does not mean anything.

The way it is now, you don't know which function is inside the other.

Re: Something missing in ui_view.inc

Please don't mess with php and js, and do what I told you.

There is no problem here.

Joe

Re: Something missing in ui_view.inc

Ok, Haakon0603, I think I understand what you mean.

The 'else if' sentences should be 'elseif'.

In this specific case this doesn't matter. However for better readness of the code, I will change it.

/Joe