Your IP : 216.73.216.182


Current Path : /var/www/html/components/com_jdownloads/assets/js/
Upload File :
Current File : /var/www/html/components/com_jdownloads/assets/js/jdownloads.js

/**
* Toggles the check state of a group of boxes
*
* Checkboxes must have an id attribute in the form cb0, cb1...
* @param The number of box to 'check'
* @param An alternative field name
*
*/

function checkAlle( n, formid, fldName, toggle_el) {
  if (!fldName) {
     fldName = 'cb';
  }
   if (!toggle_el && typeof event !== 'undefined') {
      toggle_el = event.target || event.srcElement;
   }

   var formname = 'down' + formid;
   var f = document.forms[formname];
   if (!f && toggle_el && toggle_el.form) {
      f = toggle_el.form;
   }

   var toggle = f ? f.elements['toggle'] : null;
   var c = false;
   if (toggle_el && typeof toggle_el.checked !== 'undefined') {
      c = toggle_el.checked;
   } else {
      c = toggle ? toggle.checked : false;
   }

   var n2 = 0;
   var boxes = [];
   var i;
   var cb;

   if (!f) {
      return;
   }

   // Current layouts render the file checkboxes as cb_arr[] while older code
   // still looks for legacy cb0/cb1 form properties.
   if (f.querySelectorAll) {
      boxes = f.querySelectorAll('input[name="cb_arr[]"]');
   }

   if (boxes.length) {
      for (i = 0; i < boxes.length; i++) {
         boxes[i].checked = c;
         n2++;
      }
   } else {
	    for (i = 0; i < n; i++) {
		    cb = f.elements[fldName + i] || document.getElementById(fldName + i);
		    if (cb) {
			    cb.checked = c;
			    n2++;
		    }
	    }
   }

	if (f.boxchecked) {
		f.boxchecked.value = c ? n2 : 0;
	}
}

window.checkAlle = checkAlle;

function istChecked(isitchecked,formid){
    var formname = 'down'+ formid;
   var form = document.forms[formname];

   if (!form || !form.boxchecked) {
      return;
   }

   if (isitchecked == true){
		form.boxchecked.value = parseInt(form.boxchecked.value || 0, 10) + 1;
	}
	else {
		form.boxchecked.value = Math.max(parseInt(form.boxchecked.value || 0, 10) - 1, 0);
	}
}

window.istChecked = istChecked;

function pruefen(formid,text){
   var formname = 'down'+ formid;
   var f = document.forms[formname];
   if (f && ((f.filter_order && f.filter_order.value) || (f.filter_order_Dir && f.filter_order_Dir.value))) {
      return true;
   }
   if (f.boxchecked.value < 1) {
      alert(text);
      return false;
   }
   return true;
}

window.pruefen = pruefen;

function gocat(root_url, allfiles_url, topfiles_url, newfiles_url, url){
     var id = document.getElementById("cat_list").value;
     var url_list = url.split(",");
	 var link = '';
     
	 if (id > 1) {
        link = url_list[id-1];
     } else {
		switch (id){
			case '-1': 
				link = allfiles_url;
				break;
			case '-2': 
				link = newfiles_url;
				break;
			case '-3': 
				link = topfiles_url;
				break;
			default:
				link = root_url;			
		}	
     }
     top.location.href=link;
} 

function gosubcat(root_url, url){
     var id = document.getElementById("sub_cat_list").value;
     var url_list = url.split(",");
	 var link = '';
     
	 if (id > 1) {
        link = url_list[id-1];
     } else {
		switch (id){
			default:
				link = root_url;			
		}	
     }
     top.location.href=link;
}

function CheckSearch(error_msg_to_short, error_msg_no_option){
  var search        = document.jdsearch.jdsearchtext.value;
  var searchintitle = document.jdsearch.jdsearchintitle.checked;
  var searchindesc  = document.jdsearch.jdsearchindesc.checked;  
      if (!searchintitle && !searchindesc){
          alert(error_msg_no_option);
          document.jdsearch.jdsearchintitle.focus();
          return false;
      } else if (search == '' || search.length < 3){
                 alert(error_msg_to_short);
                 document.jdsearch.jdsearchtext.focus();
                 return false;
      } else {
        return true;
      }
}

function checkUploadFieldExtern(extern_file){
    if (extern_file.value != ''){
		document.uploadForm.file_upload.value = '';
		document.uploadForm.file_upload.disabled = 'disabled';
	}
	else {
		document.uploadForm.file_upload.removeAttribute("disabled", 0);
	}
}
function checkUploadFieldFile(file_upload){
    if (file_upload.value != ''){
		document.uploadForm.extern_file.value = '';
		document.uploadForm.extern_file.disabled = 'disabled';
	}
	else {
		document.uploadForm.extern_file.removeAttribute("disabled", 0);
	}
}

function CheckForm(error_msg, allowed_file_types, error_msg_ext){
  var name = document.uploadForm.name.value;
  var mail = document.uploadForm.mail.value;
  var title = document.uploadForm.filetitle.value;
  var catlist = document.uploadForm.catlist.value;
  var allowed_types = allowed_file_types.split(",");  
  
  if (document.uploadForm.file_upload ) var file_upload = document.uploadForm.file_upload.value.toLowerCase();
  if (document.uploadForm.extern_file ) var extern_file = document.uploadForm.extern_file.value;
  if (document.uploadForm.description) var description = document.uploadForm.description.value;
  if (document.uploadForm.description) var description2 = tinyMCE.activeEditor.getContent({format : 'raw'});

  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.+?]+@([\w-]+\.)+[\w-]{2,4}$/;
  var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);

  if(name == "") {
    alert(error_msg);
    document.uploadForm.name.focus();
    return false;
  }
  if(!mail.match(emailRegex)){
    alert(error_msg);
    document.uploadForm.mail.focus();
    return false;
  }
  if(title == "") {
    alert(error_msg);
    document.uploadForm.filetitle.focus();
    return false;
  }
  if(catlist == "" || catlist == 0) {
    alert(error_msg);
    document.uploadForm.catlist.focus();
    return false;
  } 

  if ( typeof file_upload != "undefined"){
    if (document.uploadForm.extern_file){
        if (file_upload == '' && extern_file == ''){
            alert(error_msg);
            document.uploadForm.file_upload.focus();
            return false;
        }
    } else {
        if (file_upload == ''){
            alert(error_msg);
            document.uploadForm.file_upload.focus();
            return false;
       } 
    }
  }

  if ( typeof description != "undefined"){
    if(description == "" || description == '<p><br mce_bogus="1"></p>') {
        if (description2 == '' || description2 == '<p><br mce_bogus="1"></p>'){ 
            alert(error_msg);
            document.uploadForm.description.focus();
            return false;
        }
    }
  }    

  if ( typeof file_upload != "undefined"){
    if (file_upload != ''){
        // code to get File Extension..
        var arr1 = new Array;
        arr1 = file_upload.split("\\");
        var len = arr1.length;
        var img1 = arr1[len-1];
        var filext = img1.substring(img1.lastIndexOf(".")+1);
        if (!is_in_array(allowed_types, filext)){
            alert(error_msg_ext);
            document.uploadForm.file_upload.focus();
            return false;
        }
    }
  }
  return true;
} 

function is_in_array(arr,str) {
    for(x in arr) {if (arr[x] == str) return true;}
    return false;
}

function enableDownloadButton(elem) { 
    var obj = document.getElementById('jd_license_submit'); 
    obj.disabled = !elem.checked; 
}


function sprintf()
{
   if (!arguments || arguments.length < 1 || !RegExp)
   {
      return;
   }
   var str = arguments[0];
   var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;
   var a = b = [], numSubstitutions = 0, numMatches = 0;
   while (a = re.exec(str))
   {
      var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
      var pPrecision = a[5], pType = a[6], rightPart = a[7];

      numMatches++;
      if (pType == '%')
      {
         subst = '%';
      }
      else
      {
         numSubstitutions++;
         if (numSubstitutions >= arguments.length)
         {
            alert('Error! Not enough function arguments (' + (arguments.length - 1)
               + ', excluding the string)\n'
               + 'for the number of substitution parameters in string ('
               + numSubstitutions + ' so far).');
         }
         var param = arguments[numSubstitutions];
         var pad = '';
                if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1);
           else if (pPad) pad = pPad;
         var justifyRight = true;
                if (pJustify && pJustify === "-") justifyRight = false;
         var minLength = -1;
                if (pMinLength) minLength = parseInt(pMinLength);
         var precision = -1;
                if (pPrecision && pType == 'f')
                   precision = parseInt(pPrecision.substring(1));
         var subst = param;
         switch (pType)
         {
         case 'b':
            subst = parseInt(param).toString(2);
            break;
         case 'c':
            subst = String.fromCharCode(parseInt(param));
            break;
         case 'd':
            subst = parseInt(param) ? parseInt(param) : 0;
            break;
         case 'u':
            subst = Math.abs(param);
            break;
         case 'f':
            subst = (precision > -1)
             ? Math.round(parseFloat(param) * Math.pow(10, precision))
              / Math.pow(10, precision)
             : parseFloat(param);
            break;
         case 'o':
            subst = parseInt(param).toString(8);
            break;
         case 's':
            subst = param;
            break;
         case 'x':
            subst = ('' + parseInt(param).toString(16)).toLowerCase();
            break;
         case 'X':
            subst = ('' + parseInt(param).toString(16)).toUpperCase();
            break;
         }
         var padLeft = minLength - subst.toString().length;
         if (padLeft > 0)
         {
            var arrTmp = new Array(padLeft+1);
            var padding = arrTmp.join(pad?pad:" ");
         }
         else
         {
            var padding = "";
         }
      }
      str = leftpart + padding + subst + rightPart;
   }
   return str;
}

// JS Calendar
var calendar = null; // remember the calendar object so that we reuse
// it and avoid creating another

// This function gets called when an end-user clicks on some date
function selected(cal, date) {
	cal.sel.value = date; // just update the value of the input field
}

// And this gets called when the end-user clicks on the _selected_ date,
// or clicks the "Close" (X) button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) {
	cal.hide();			// hide the calendar

	// don't check mousedown on document anymore (used to be able to hide the
	// calendar when someone clicks outside it, see the showCalendar function).
	Calendar.removeEvent(document, "mousedown", checkCalendar);
}

// This gets called when the user presses a mouse button anywhere in the
// document, if the calendar is shown.  If the click was outside the open
// calendar this function closes it.
function checkCalendar(ev) {
	var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
	for (; el != null; el = el.parentNode)
	// FIXME: allow end-user to click some link without closing the
	// calendar.  Good to see real-time stylesheet change :)
	if (el == calendar.element || el.tagName == "A") break;
	if (el == null) {
		// calls closeHandler which should hide the calendar.
		calendar.callCloseHandler(); Calendar.stopEvent(ev);
	}
}

// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.
function showCalendar(id, dateFormat) {
	var el = document.getElementById(id);
	if (calendar != null) {
		// we already have one created, so just update it.
		calendar.hide();		// hide the existing calendar
		calendar.parseDate(el.value); // set it to a new date
	} else {
		// first-time call, create the calendar
		var cal = new Calendar(true, null, selected, closeHandler);
		calendar = cal;		// remember the calendar in the global
		cal.setRange(1900, 2070);	// min/max year allowed

		if ( dateFormat )	// optional date format
		{
			cal.setDateFormat(dateFormat);
		}

		calendar.create();		// create a popup calendar
		calendar.parseDate(el.value); // set it to a new date
	}
	calendar.sel = el;		// inform it about the input field in use
	calendar.showAtElement(el);	// show the calendar next to the input field

	// catch mousedown on the document
	Calendar.addEvent(document, "mousedown", checkCalendar);
	return false;
}

//
// Used for frontend sort order bar
//
dataOrdering = function(order, dir, task, form) {
	if (typeof(form) === 'undefined') {
		form = document.getElementById('adminForm');

		if(!form){
			form = document.adminForm;
		}
	}
	
	form.filter_order.value = order;
	form.filter_order_Dir.value = dir;
	Joomla.submitform(task, form);
}

function array_search (needle, haystack, argStrict) {
  // http://kevin.vanzonneveld.net
  // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  // + input by: Brett Zamir (http://brett-zamir.me)
  // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  // * example 1: array_search('zonneveld', {firstname: 'kevin', middle: 'van', surname: 'zonneveld'});
  // * returns 1: 'surname'
  // * example 2: ini_set('phpjs.return_phpjs_arrays', 'on');
  // * example 2: var ordered_arr = array({3:'value'}, {2:'value'}, {'a':'value'}, {'b':'value'});
  // * example 2: var key = array_search(/val/g, ordered_arr); // or var key = ordered_arr.search(/val/g);
  // * returns 2: '3'

  var strict = !!argStrict,
    key = '';

  if (haystack && typeof haystack === 'object' && haystack.change_key_case) { // Duck-type check for our own array()-created PHPJS_Array
    return haystack.search(needle, argStrict);
  }
  if (typeof needle === 'object' && needle.exec) { // Duck-type for RegExp
    if (!strict) { // Let's consider case sensitive searches as strict
      var flags = 'i' + (needle.global ? 'g' : '') +
            (needle.multiline ? 'm' : '') +
            (needle.sticky ? 'y' : ''); // sticky is FF only
      needle = new RegExp(needle.source, flags);
    }
    for (key in haystack) {
      if (needle.test(haystack[key])) {
        return key;
      }
    }
    return false;
  }

  for (key in haystack) {
    if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
      return key;
    }
  }

  return false;
}