⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin_functions.js

📁 CMS系统
💻 JS
字号:
// frm is the form object
// elm is the checkbox which initiated the click
// val is the unique group name
function select_deselectAll (formname, elm, group)
{
	var frm = document.forms[formname];
	
    // Loop through all elements
    for (i=0; i<frm.length; i++)
    {
        // Look for our Header Template's Checkbox
        if (elm.attributes['checkall'] != null && elm.attributes['checkall'].value == group)
        {
            if (frm.elements[i].attributes['checkme'] != null && frm.elements[i].attributes['checkme'].value == group)
              frm.elements[i].checked = elm.checked;
        }
        // Work here with the Item Template's multiple checkboxes
        else if (frm.elements[i].attributes['checkme'] != null && frm.elements[i].attributes['checkme'].value == group)
        {
            // Check if any of the checkboxes are not checked, and then uncheck top select all checkbox
            if(frm.elements[i].checked == false)
            {
                frm.elements[1].checked = false; //Uncheck main select all checkbox
            }
        }
    }
}

function initCheckboxGroup(formname, group)
{
	var frm = document.forms[formname];
	var checkAllIndex = -1;
	var unchecked = false;
	
  // Loop through all elements
    for (i=0; i<frm.length; i++)
    {
        // Look for our Header Template's Checkbox
        if (frm.elements[i].attributes['checkall'] != null && frm.elements[i].attributes['checkall'].value == group)
        {
            checkAllIndex = i
        }
        // Work here with the Item Template's multiple checkboxes
        else if (frm.elements[i].attributes['checkme'] != null && frm.elements[i].attributes['checkme'].value == group)
        {
            // Check if any of the checkboxes are not checked, and then uncheck top select all checkbox
            if(frm.elements[i].checked == false)
            {
            	unchecked = true;
                break;
            }
        }
    }	
    
    // If all the boxes in this group are checked, check the checkall 
    if(checkAllIndex != -1 && unchecked == false)
      frm.elements[checkAllIndex].checked = true;
}

//
//
// AJAX VOODOO!
//
// Uses some code from http://www.modernmethod.com/sajax/

function CreateAJAXObject()
{
  return window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
}

function AjaxDebug(text)
{
  //alert("RSD: " + text)
}

function CreateAJAXRequest(uri, func_name, args)
{
  var AJAXhttp = CreateAJAXObject();

  if (uri.indexOf("?") == -1) 
    uri = uri + "?rs=" + escape(func_name);
  else
    uri = uri + "&rs=" + escape(func_name);
	
  for (i = 0; i < args.length-1; i++) 
    uri = uri + "&rsargs[]=" + escape(args[i]);
  uri = uri + "&rsrnd=" + new Date().getTime();  

  AjaxDebug(uri);
  AJAXhttp.open('get', uri, true);

  AJAXhttp.onreadystatechange = function() 
  {
    if (AJAXhttp.readyState != 4) 
	  return;
      
	AjaxDebug("received " + AJAXhttp.responseText);
    AjaxDebug("Status " + AJAXhttp.status);
				
	var status;
	var data;
	status = AJAXhttp.responseText.charAt(0);
	data = AJAXhttp.responseText.substring(2);
	
    if (status == "-") 
	  alert("Error: " + data);
    else if(AJAXhttp.status != 200)
    {
      args[args.length-1]("Error contacting server: " + AJAXhttp.status);
    }
	else
	  args[args.length-1](data);
  }
  AJAXhttp.send(null); 
  delete AJAXhttp;
}

function ArrayFind(haystack, needle)
{
  var j = 0;
  
  for(j = 0; j < haystack.length; j++)
  {
    if(haystack[j] == needle)
      return j;
  }
  
  return -1;
}

// Splits a string into array of version numbers
function getVersionArray(version)
{
	// initialize variables
	var versionBits, i;

	// split the main version by periods
	versionBits = version.split(".");

	// if the main version number does not have 4 components, create the missing ones as zeroes
	if (versionBits.length < 4)
	{
		for (i = versionBits.length; i < 4; i++)
		{
			versionBits[i] = 0;
		}
	}

	// ensure that each element of the versionBits array is an integer
	for (i = 0; i < 4; i++)
	{
		if (!(versionBits[i] = parseInt(versionBits[i])))
		{
			versionBits[i] = 0;
		}
	}

	// return the completed array
	return versionBits;
}

// compares the array of integers from two version numbers to see if one is newer than the other
function isNewerVersion(thisVersion, latestVersion)
{
	// initialize variables
	var curVersion, newVersion, i;

	// are the version numbers different?
	if (thisVersion != latestVersion)
	{
		// get arrays from the version numbers
		curVersion = getVersionArray(thisVersion);
		newVersion = getVersionArray(latestVersion);

		// check each element of the arrays against each other
		for (i = 0; i < 4; i++)
		{
			// is the 'new' value the same as the 'current' value?
			if (newVersion[i] != curVersion[i])
			{
				// values are not the same - return true if greater, false if lesser
				return (newVersion[i] > curVersion[i]);
			}
		}
	}

	return false;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -