started migration to bootstrap

* migrated /index and most widgets on it
* migrated /system.php using new form-layout
* removed /themes and /javascript; html will change too much
This commit is contained in:
Sjon Hortensius 2014-12-29 20:13:49 +01:00
parent 16d2c13aa6
commit 1180e4f011
2180 changed files with 2660 additions and 67266 deletions

12
README.md Normal file
View File

@ -0,0 +1,12 @@
pfSense on bootstrap
====================
We are migrating pfSense to Bootstrap. You can help! Please respect these code-guidelines:
* use tabs (tabstop=4) for indenting (except the license-header which contains 2 lines that are indented with '\t ')
* limited echoing of HTML from php, please use proper templating syntax instead (eg. foreach/endforeach)
* limited attributes on elements; *no style attributes*
* no inline javascript
* html attributes should be using double-quoted attribute-values. This means your php-code should use mostly single-quoted strings
If you feel adventurous you can sometimes rewrite some PHP & javascript code as well; but try to keep this to a minimum.

View File

@ -51,7 +51,7 @@ if(!$do_not_include_config_gui_inc)
// Will be changed to false if security checks fail
$security_passed = true;
/* If this function doesn't exist, we're being called from Captive Portal or
/* If this function doesn't exist, we're being called from Captive Portal or
another internal subsystem which does not include authgui.inc */
if (function_exists("display_error_form") && !isset($config['system']['webgui']['nodnsrebindcheck'])) {
/* DNS ReBinding attack prevention. https://redmine.pfsense.org/issues/708 */
@ -117,8 +117,22 @@ if(function_exists("display_error_form") && !isset($config['system']['webgui']['
if($_SERVER['HTTP_REFERER'] == file_get_contents("{$g['tmp_path']}/setupwizard_lastreferrer")) {
unlink("{$g['tmp_path']}/setupwizard_lastreferrer");
header("Refresh: 1; url=index.php");
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html><head><title>" . gettext("Redirecting...") . "</title></head><body>" . gettext("Redirecting to the dashboard...") . "</body></html>";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="/bootstrap/css/pfSense.css" />
<title><?=gettext("Redirecting..."); ?></title>
</head>
<body id="error" class="no-menu">
<div id="jumbotron">
<div class="container">
<p><?=gettext("Redirecting to the dashboard...")?></p>
</div>
</div>
</body>
</html>
<?php
exit;
}
}
@ -389,7 +403,7 @@ function local_user_set(& $user) {
conf_mount_rw();
$home_base = "/home/";
$home_base = "/home/";
$user_uid = $user['uid'];
$user_name = $user['name'];
$user_home = "{$home_base}{$user_name}";
@ -397,7 +411,7 @@ function local_user_set(& $user) {
$user_group = "nobody";
// Ensure $home_base exists and is writable
if (!is_dir($home_base))
if (!is_dir($home_base))
mkdir($home_base, 0755);
$lock_account = false;
@ -448,7 +462,7 @@ function local_user_set(& $user) {
$user_op = "usermod";
}
$comment = str_replace(array(":", "!", "@"), " ", $user['descr']);
$comment = str_replace(array(":", "!", "@"), " ", $user['descr']);
/* add or mod pw db */
$cmd = "/usr/sbin/pw {$user_op} -q -u {$user_uid} -n {$user_name}".
" -g {$user_group} -s {$user_shell} -d {$user_home}".
@ -482,7 +496,7 @@ function local_user_set(& $user) {
$un = $lock_account ? "" : "un";
exec("/usr/sbin/pw {$un}lock {$user_name} -q");
conf_mount_ro();
}
@ -554,7 +568,7 @@ function local_user_get_groups($user, $all = false) {
sort($groups);
return $groups;
}
function local_user_set_groups($user, $new_groups = NULL ) {
@ -771,7 +785,7 @@ function ldap_test_bind($authcfg) {
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ldap, LDAP_OPT_DEREF, LDAP_DEREF_SEARCHING);
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, (int)$ldapver);
$ldapbindun = isset($authcfg['ldap_utf8']) ? utf8_encode($ldapbindun) : $ldapbindun;
$ldapbindpw = isset($authcfg['ldap_utf8']) ? utf8_encode($ldapbindpw) : $ldapbindpw;
if ($ldapanon == true) {
@ -889,23 +903,23 @@ function ldap_get_user_ous($show_complete_ou=true, $authcfg) {
function ldap_get_groups($username, $authcfg) {
global $debug, $config;
if(!function_exists("ldap_connect"))
return;
if(!$username)
if(!$username)
return false;
if(!isset($authcfg['ldap_nostrip_at']) && stristr($username, "@")) {
$username_split = explode("@", $username);
$username = $username_split[0];
$username = $username_split[0];
}
if(stristr($username, "\\")) {
$username_split = explode("\\", $username);
$username = $username_split[0];
}
$username = $username_split[0];
}
//log_error("Getting LDAP groups for {$username}.");
if ($authcfg) {
if (strstr($authcfg['ldap_urltype'], "Standard"))
@ -953,7 +967,7 @@ function ldap_get_groups($username, $authcfg) {
log_error(sprintf(gettext("ERROR! ldap_get_groups() Could not connect to server %s."), $ldapname));
return memberof;
}
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ldap, LDAP_OPT_DEREF, LDAP_DEREF_SEARCHING);
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, (int)$ldapver);
@ -985,8 +999,8 @@ function ldap_get_groups($username, $authcfg) {
$search = @$ldapfunc($ldap, $ldapdn, $ldapfilter, array($ldapgroupattribute));
$info = @ldap_get_entries($ldap, $search);
$countem = $info["count"];
$countem = $info["count"];
if(is_array($info[0][$ldapgroupattribute])) {
/* Iterate through the groups and throw them into an array */
foreach ($info[0][$ldapgroupattribute] as $member) {
@ -996,14 +1010,14 @@ function ldap_get_groups($username, $authcfg) {
}
}
}
/* Time to close LDAP connection */
@ldap_unbind($ldap);
$groups = print_r($memberof,true);
//log_error("Returning groups ".$groups." for user $username");
return $memberof;
}
@ -1013,8 +1027,8 @@ function ldap_format_host($host) {
function ldap_backed($username, $passwd, $authcfg) {
global $debug, $config;
if(!$username)
if(!$username)
return;
if(!function_exists("ldap_connect"))
@ -1022,11 +1036,11 @@ function ldap_backed($username, $passwd, $authcfg) {
if(!isset($authcfg['ldap_nostrip_at']) && stristr($username, "@")) {
$username_split = explode("@", $username);
$username = $username_split[0];
$username = $username_split[0];
}
if(stristr($username, "\\")) {
$username_split = explode("\\", $username);
$username = $username_split[0];
$username = $username_split[0];
}
if ($authcfg) {
@ -1056,9 +1070,9 @@ function ldap_backed($username, $passwd, $authcfg) {
}
else
{
$ldapfilter =
$ldapfilter =
"(&({$ldapnameattribute}={$username})({$ldapextendedquery}))";
}
}
$ldaptype = "";
$ldapver = $authcfg['ldap_protver'];
$ldapname = $authcfg['name'];
@ -1066,7 +1080,7 @@ function ldap_backed($username, $passwd, $authcfg) {
} else
return false;
/* first check if there is even an LDAP server populated */
/* first check if there is even an LDAP server populated */
if(!$ldapserver) {
if ($ldapfallback) {
log_error(gettext("ERROR! ldap_backed() called with no LDAP authentication server defined. Defaulting to local user database. Visit System -> User Manager."));
@ -1076,7 +1090,7 @@ function ldap_backed($username, $passwd, $authcfg) {
return false;
}
/* Setup CA environment if needed. */
ldap_setup_caenv($authcfg);
@ -1109,10 +1123,10 @@ function ldap_backed($username, $passwd, $authcfg) {
log_error(sprintf(gettext("ERROR! Could not bind to server %s."), $ldapname));
return false;
}
/* Get LDAP Authcontainers and split em up. */
$ldac_splits = explode(";", $ldapauthcont);
/* setup the usercount so we think we havn't found anyone yet */
$usercount = 0;
@ -1160,7 +1174,7 @@ function ldap_backed($username, $passwd, $authcfg) {
if ($usercount != 1){
@ldap_unbind($ldap);
log_error(gettext("ERROR! Either LDAP search failed, or multiple users were found."));
return false;
return false;
}
/* Now lets bind as the user we found */
@ -1241,7 +1255,7 @@ function radius_backed($username, $passwd, $authcfg, &$attributes = array()) {
function get_user_expiration_date($username) {
$user = getUserEntry($username);
if ($user['expires'])
if ($user['expires'])
return $user['expires'];
}
@ -1368,7 +1382,7 @@ function session_auth() {
/* Validate incoming login request */
if (isset($_POST['login']) && !empty($_POST['usernamefld']) && !empty($_POST['passwordfld'])) {
$authcfg = auth_get_authserver($config['system']['webgui']['authmode']);
if (authenticate_user($_POST['usernamefld'], $_POST['passwordfld'], $authcfg) ||
if (authenticate_user($_POST['usernamefld'], $_POST['passwordfld'], $authcfg) ||
authenticate_user($_POST['usernamefld'], $_POST['passwordfld'])) {
// Generate a new id to avoid session fixation
session_regenerate_id();
@ -1409,7 +1423,7 @@ function session_auth() {
$_GET['logout'] = true;
$_SESSION['Logout'] = true;
} else
$_SESSION['last_access'] = time();
$_SESSION['last_access'] = time();
} else if (intval($config['system']['webgui']['session_timeout']) == 0) {
/* only update if it wasn't ajax */
if (!isAjax())

View File

@ -75,7 +75,7 @@ if (!isAllowedPage($_SERVER['REQUEST_URI'])) {
display_error_form("201", gettext("No page assigned to this user! Click here to logout."));
exit;
}
} else
} else
$_SESSION['Post_Login'] = true;
/*
@ -89,7 +89,7 @@ if (!$_SESSION['Post_Login']) {
exit;
}
/*
/*
* Close session data to allow other scripts from same host to come in.
* A session can be reactivated from calling session_start again
*/
@ -107,49 +107,21 @@ function display_error_form($http_code, $desc) {
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<script type="text/javascript" src="/javascript/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="/javascript/jquery-migrate-1.2.1.min.js"></script>
<title><?=$http_code?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/themes/<?= $g['theme'] ?>/images/icons/favicon.ico" />
<?php if (file_exists("{$g['www_path']}/themes/{$g['theme']}/login.css")): ?>
<link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/login.css" media="all" />
<?php else: ?>
<link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/all.css" media="all" />
<?php endif; ?>
<script type="text/javascript">
//<![CDATA[
function page_load() {}
function clearError() {
if($('#inputerrors'))
$('#inputerrors').html('');
}
<?php
require("headjs.php");
echo getHeadJS();
?>
//]]>
</script>
<script type="text/javascript" src="/themes/<?= $g['theme'] ?>/javascript/niftyjsCode.js"></script>
</head>
<body onload="page_load();">
<div id="errordesc">
<h1>&nbsp</h1>
<a href="/index.php?logout">
<p id="errortext" style="vertical-align: middle; text-align: center;">
<span style="color: #000000; font-weight: bold;">
<?=$desc;?>
</span>
</p>
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="/bootstrap/css/pfSense.css" />
<title><?=gettext("Error: not allowed"); ?></title>
</head>
<body id="error" class="no-menu">
<div id="jumbotron">
<div class="container">
<!-- FIXME: We really need to POST the logout action -->
<div class="alert alert-danger" role="alert"><a href="index.php?logout"><?=$desc;?></a></div>
</div>
</body>
</div>
</body>
</html>
<?php
} // end function
@ -177,7 +149,7 @@ function display_login_form() {
exit;
}
/* Check against locally configured IP addresses, which will catch when someone
/* Check against locally configured IP addresses, which will catch when someone
port forwards WebGUI access from WAN to an internal IP on the router. */
global $FilterIflist, $nifty_background;
$local_ip = false;
@ -229,90 +201,50 @@ setcookie("cookie_test", time() + 3600);
$have_cookies = isset($_COOKIE["cookie_test"]);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<script type="text/javascript" src="/javascript/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="/javascript/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() { jQuery('#usernamefld').focus(); });
//]]>
</script>
<title><?=gettext("Login"); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/themes/<?= $g['theme'] ?>/images/icons/favicon.ico" />
<?php if (file_exists("{$g['www_path']}/themes/{$g['theme']}/login.css")): ?>
<link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/login.css" media="all" />
<?php else: ?>
<link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/all.css" media="all" />
<?php endif; ?>
<script type="text/javascript">
//<![CDATA[
function page_load() {}
function clearError() {
if($('#inputerrors'))
$('#inputerrors').html('');
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="/bootstrap/css/pfSense.css" />
<title><?=gettext("Login"); ?></title>
</head>
<body id="login" class="no-menu">
<div id="jumbotron">
<div class="container">
<?php
if(is_ipaddr($http_host) && !$local_ip && !isset($config['system']['webgui']['nohttpreferercheck'])) {
$nifty_background = "#999";
print_info_box(gettext("You are accessing this router by an IP address not configured locally, which may be forwarded by NAT or other means. <br /><br />If you did not setup this forwarding, you may be the target of a man-in-the-middle attack."));
}
<?php
require("headjs.php");
echo getHeadJS();
?>
//]]>
</script>
<script type="text/javascript" src="/themes/<?= $g['theme'] ?>/javascript/niftyjsCode.js"></script>
</head>
<body onload="page_load()">
<div id="login">
<?php
if(is_ipaddr($http_host) && !$local_ip && !isset($config['system']['webgui']['nohttpreferercheck'])) {
$nifty_background = "#999";
print_info_box(gettext("You are accessing this router by an IP address not configured locally, which may be forwarded by NAT or other means. <br /><br />If you did not setup this forwarding, you may be the target of a man-in-the-middle attack."));
}
$loginautocomplete = isset($config['system']['webgui']['loginautocomplete']) ? '' : 'autocomplete="off"';
?>
<form id="iform" name="iform" method="post" <?= $loginautocomplete ?> action="<?=$_SERVER['SCRIPT_NAME'];?>">
<h1>&nbsp;</h1>
<div id="inputerrors"><?=$_SESSION['Login_Error'];?></div>
<p>
<span style="text-align:left">
<?=gettext("Username:"); ?><br />
<input onclick="clearError();" onchange="clearError();" id="usernamefld" type="text" name="usernamefld" class="formfld user" tabindex="1" />
</span>
</p>
<p>
<br />
<span style="text-align:left">
<?=gettext("Password:"); ?> <br />
<input onclick="clearError();" onchange="clearError();" id="passwordfld" type="password" name="passwordfld" class="formfld pwd" tabindex="2" />
</span>
</p>
<p>
<br />
<span style="text-align:center; font-weight: normal ; font-style: italic">
<?=gettext("Enter username and password to login."); ?>
</span>
<?php if (!$have_cookies && isset($_POST['login'])): ?>
<br /><br />
<span style="text-align:center; font-weight: normal ; font-style: italic; color: #ff0000">
<?= gettext("Your browser must support cookies to login."); ?>
</span>
<?php endif; ?>
</p>
<p>
<span style="text-align:center">
<input type="submit" name="login" class="formbtn" value="<?=gettext("Login"); ?>" tabindex="3" />
</span>
</p>
</form>
$loginautocomplete = isset($config['system']['webgui']['loginautocomplete']) ? '' : 'autocomplete="off"';
?>
<form id="iform" name="iform" method="post" <?= $loginautocomplete ?> action="<?=$_SERVER['SCRIPT_NAME'];?>">
<?php if (!empty($_SESSION['Login_Error'])): ?>
<div class="alert alert-danger" role="alert"><?=$_SESSION['Login_Error'];?></div>
<?php endif ?>
<div class="form-group">
<label for="inputEmail">Username</label>
<input type="text" class="form-control" name="usernamefld" placeholder="Username">
</div>
<div class="form-group">
<label for="inputPassword">Password</label>
<input type="password" class="form-control" name="passwordfld" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary" name="login">Login</button>
<?php if (!$have_cookies && isset($_POST['login'])): ?>
<div class="alert alert-warning">
<?= gettext("Your browser must support cookies to login."); ?>
</div>
<?php endif; ?>
</form>
</div>
</body>
</div>
</body>
</html>
<?php
} // end function
?>
?>

View File

@ -57,7 +57,7 @@ if(!function_exists("pfSenseHeader")) {
$protocol = "https";
else
$protocol = "http";
$port = ":{$_SERVER['SERVER_PORT']}";
if ($_SERVER['SERVER_PORT'] == "80" && $protocol == "http")
$port = "";
@ -72,60 +72,6 @@ if(!function_exists("pfSenseHeader")) {
}
/* END compatibility goo with HEAD */
/*fetch menu notices function*/
if(!function_exists("get_menu_messages")) {
function get_menu_messages(){
global $g,$config;
if (are_notices_pending()) {
$notices = get_notices();
$requests=array();
## Get Query Arguments from URL ###
foreach ($_REQUEST as $key => $value) {
if ($key != "PHPSESSID")
$requests[] = $key.'='.$value;
}
if(is_array($requests))
$request_string = implode("&", $requests);
if(is_array($notices)) {
$notice_msgs = "<table colspan=\'6\' id=\'notice_table\'>";
$alert_style="style=\'color:#ffffff; filter:Glow(color=#ff0000, strength=12);\' ";
$notice = "<a href=\'#\' onclick=notice_action(\'acknowledge\',\'all\');domTT_close(this); {$alert_style}>".gettext("Acknowledge All Notices")."</a>";
$alert_link="title=\'".gettext("Click to Acknowledge")."\' {$alert_style}";
$domtt_width=500;
foreach ($notices as $key => $value) {
$date = date("m-d-y H:i:s", $key);
$noticemsg = ($value['notice'] != "" ? $value['notice'] : $value['id']);
$noticemsg = preg_replace("/(\"|\'|\n|<.?\w+>)/i","",$noticemsg);
if ((strlen($noticemsg)* 8) > $domtt_width)
$domtt_width=(strlen($noticemsg) *8);
if ((strlen($noticemsg)* 8) > 900)
$domtt_width= 900;
$alert_action ="onclick=notice_action(\'acknowledge\',\'{$key}\');domTT_close(this);jQuery(this).parent().parent().remove();";
$notice_msgs .= "<tr><td valign=\'top\' width=\'120\'><a href=\'#\' {$alert_link} {$alert_action}>{$date}</a></td><td valign=\'top\'><a href=\'#\' {$alert_link} {$alert_action}>[ ".htmlspecialchars($noticemsg)."]</a></td></tr>";
}
$notice_msgs .="</table>";
$domtt= "onclick=\"domTT_activate(this, event, 'caption', '{$notice}','content', '<br />{$notice_msgs}', 'trail', false, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle','width','{$domtt_width}','y',5,'type', 'sticky');\"";
$menu_messages="<div id='alerts'>\n";
if(count($notices)==1)
$msg= sprintf("%1$02d",count($notices))." ".gettext("unread notice");
else
$msg= sprintf("%1$02d",count($notices))." ".gettext("unread notices");
$menu_messages.="<div id='marquee-text' style='z-index:1001;'><a href='#' {$domtt}><b> .:. {$msg} .:. </b></a></div>\n";
$menu_messages.="</div>\n";
}
}
else {
$menu_messages='<div id="hostname">';
$menu_messages.=$config['system']['hostname'] . "." . $config['system']['domain'];
$menu_messages.='</div>';
}
return ($menu_messages);
}
}
if(!function_exists("dom_title")) {
function dom_title($title_msg,$width=NULL){
$width=preg_replace("/\D+/","",$width);

View File

@ -36,7 +36,7 @@
global $g;
$g = array(
"base_packages" => "siproxd",
"base_packages" => "siproxd",
"event_address" => "unix:///var/run/check_reload_status",
"factory_shipped_username" => "admin",
"factory_shipped_password" => "pfsense",
@ -62,7 +62,7 @@ $g = array(
"product_copyright_url" => "http://www.electricsheepfencing.com",
"product_copyright_years" => "2004 - ".date("Y"),
"product_website" => "www.pfsense.org",
"product_website_footer" => "https://www.pfsense.org/?gui22",
"product_website_footer" => "https://www.pfsense.org/?gui=bootstrap",
"product_email" => "coreteam@pfsense.org",
"hideplatform" => false,
"hidedownloadbackup" => false,
@ -77,7 +77,7 @@ $g = array(
"nopkg_platforms" => array("cdrom"),
"minimum_ram_warning" => "101",
"minimum_ram_warning_text" => "128 MB",
"wan_interface_name" => "wan",
"wan_interface_name" => "wan",
"nopccard_platforms" => array("wrap", "net48xx"),
"xmlrpcbaseurl" => "https://packages.pfsense.org",
"captiveportal_path" => "/usr/local/captiveportal",
@ -117,30 +117,30 @@ if(file_exists("/etc/platform")) {
}
/* Default sysctls */
$sysctls = array("net.inet.ip.portrange.first" => "1024",
"net.inet.tcp.blackhole" => "2",
"net.inet.udp.blackhole" => "1",
"net.inet.ip.random_id" => "1",
"net.inet.tcp.drop_synfin" => "1",
"net.inet.ip.redirect" => "1",
"net.inet6.ip6.redirect" => "1",
$sysctls = array("net.inet.ip.portrange.first" => "1024",
"net.inet.tcp.blackhole" => "2",
"net.inet.udp.blackhole" => "1",
"net.inet.ip.random_id" => "1",
"net.inet.tcp.drop_synfin" => "1",
"net.inet.ip.redirect" => "1",
"net.inet6.ip6.redirect" => "1",
"net.inet6.ip6.use_tempaddr" => "0",
"net.inet6.ip6.prefer_tempaddr" => "0",
"net.inet.tcp.syncookies" => "1",
"net.inet.tcp.recvspace" => "65228",
"net.inet.tcp.sendspace" => "65228",
"net.inet.ip.fastforwarding" => "0",
"net.inet.tcp.delayed_ack" => "0",
"net.inet.udp.maxdgram" => "57344",
"net.link.bridge.pfil_onlyip" => "0",
"net.link.bridge.pfil_member" => "1",
"net.link.bridge.pfil_bridge" => "0",
"net.link.tap.user_open" => "1",
"kern.randompid" => "347",
"net.inet.ip.intr_queue_maxlen" => "1000",
"hw.syscons.kbd_reboot" => "0",
"net.inet.tcp.log_debug" => "0",
"net.inet.tcp.tso" => "1",
"net.inet.tcp.syncookies" => "1",
"net.inet.tcp.recvspace" => "65228",
"net.inet.tcp.sendspace" => "65228",
"net.inet.ip.fastforwarding" => "0",
"net.inet.tcp.delayed_ack" => "0",
"net.inet.udp.maxdgram" => "57344",
"net.link.bridge.pfil_onlyip" => "0",
"net.link.bridge.pfil_member" => "1",
"net.link.bridge.pfil_bridge" => "0",
"net.link.tap.user_open" => "1",
"kern.randompid" => "347",
"net.inet.ip.intr_queue_maxlen" => "1000",
"hw.syscons.kbd_reboot" => "0",
"net.inet.tcp.log_debug" => "0",
"net.inet.tcp.tso" => "1",
"net.inet.icmp.icmplim" => "0",
"vfs.read_max" => "32",
"kern.ipc.maxsockbuf" => "4262144",

View File

@ -52,7 +52,7 @@ function gmirror_get_status() {
}
}
}
/* Return an hash of mirrors and components */
/* Return an hash of mirrors and components */
return $mirrors;
}
@ -69,22 +69,22 @@ function gmirror_html_status() {
$output = "";
if (count($mirrors) > 0) {
$output .= "<tr>\n";
$output .= "<td width=\"40%\" class=\"vncellt\">Name</td>\n";
$output .= "<td width=\"40%\" class=\"vncellt\">Status</td>\n";
$output .= "<td width=\"20%\" class=\"vncellt\">Component</td>\n";
$output .= "<th>Name</td>\n";
$output .= "<th>Status</td>\n";
$output .= "<th>Component</td>\n";
$output .= "</tr>\n";
foreach ($mirrors as $mirror => $name) {
$components = count($name["components"]);
$output .= "<tr>\n";
$output .= "<td width=\"40%\" rowspan=\"{$components}\" class=\"listr\">{$name['name']}</td>\n";
$output .= "<td width=\"40%\" rowspan=\"{$components}\" class=\"listr\">{$name['status']}</td>\n";
$output .= "<td width=\"20%\" class=\"listr\">{$name['components'][0]}</td>\n";
$output .= "<td rowspan=\"{$components}\">{$name['name']}</td>\n";
$output .= "<td rowspan=\"{$components}\" class=\"listr\">{$name['status']}</td>\n";
$output .= "<td>{$name['components'][0]}</td>\n";
$output .= "</tr>\n";
if (count($name["components"]) > 1) {
$morecomponents = array_slice($name["components"], 1);
foreach ($morecomponents as $component) {
$output .= "<tr>\n";
$output .= "<td width=\"20%\" class=\"listr\">{$component}</td>\n";
$output .= "<td>{$component}</td>\n";
$output .= "</tr>\n";
}
}

View File

@ -201,7 +201,8 @@ function dump_xml_notices() {
function print_notices($notices, $category = "all") {
foreach($notices as $notice) {
if($category != "all") {
if(in_array($notice['category'], $category)) $categories[] = $notice['category'];
if(in_array($notice['category'], $category))
$categories[] = $notice['category'];
} else {
$categories[] = $notice['category'];
}
@ -209,7 +210,7 @@ function print_notices($notices, $category = "all") {
$categories = array_unique($categories);
sort($categories);
foreach($categories as $category) {
$toreturn .= "<ul><li>{$category}<ul>";
$toreturn .= '<li><a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">'.$category.'<span class="caret"></span></a><ul class="dropdown-menu" role="menu">';
foreach($notices as $notice) {
if(strtolower($notice['category']) == strtolower($category)) {
if($notice['id'] != "") {
@ -221,9 +222,9 @@ function print_notices($notices, $category = "all") {
}
}
}
$toreturn .= "</ul></li></ul>";
$toreturn .= "</ul></li>";
}
return $toreturn;
return '<ul class="dropdown-menu" role="menu">'. $toreturn .'</ul>';
}
/****f* notices/print_notice_box
@ -314,12 +315,12 @@ function send_smtp_message($message, $subject = "(no subject)") {
$smtp->debug = 0;
$smtp->html_debug = 0;
$smtp->localhost=$config['system']['hostname'].".".$config['system']['domain'];
if($config['notifications']['smtp']['fromaddress'])
$from = $config['notifications']['smtp']['fromaddress'];
// Use SMTP Auth if fields are filled out
if($config['notifications']['smtp']['username'] &&
if($config['notifications']['smtp']['username'] &&
$config['notifications']['smtp']['password']) {
$smtp->authentication_mechanism = "PLAIN";
$smtp->user = $config['notifications']['smtp']['username'];
@ -369,7 +370,7 @@ function notify_via_growl($message, $force=false) {
$growl_password = $config['notifications']['growl']['password'];
$growl_name = $config['notifications']['growl']['name'];
$growl_notification = $config['notifications']['growl']['notification_name'];
if(!empty($growl_ip)) {
$growl = new Growl($growl_ip, $growl_password, $growl_name);
$growl->notify("{$growl_notification}", gettext(sprintf("%s (%s) - Notification", $g['product_name'], $hostname)), "{$message}");
@ -396,7 +397,7 @@ function register_via_growl() {
$growl_password = $config['notifications']['growl']['password'];
$growl_name = $config['notifications']['growl']['name'];
$growl_notification = $config['notifications']['growl']['notification_name'];
if($growl_ip) {
$growl = new Growl($growl_ip, $growl_password, $growl_name);
$growl->addNotification($growl_notification);

View File

@ -442,72 +442,36 @@ function get_service_status($service) {
return $running;
}
function get_service_status_icon($service, $withtext = true, $smallicon = false) {
global $g;
$output = "";
if(get_service_status($service)) {
$statustext = gettext("Running");
$output .= "<img style=\"vertical-align:middle\" title=\"" . sprintf(gettext("%s Service is"),$service["name"]) . " {$statustext}\" src=\"/themes/" . $g["theme"] . "/images/icons/";
$output .= ($smallicon) ? "icon_pass.gif" : "icon_service_running.gif";
$output .= "\" alt=\"status\" />&nbsp;";
if ($withtext)
$output .= "&nbsp;" . $statustext;
} else {
$service_enabled = is_service_enabled($service['name']);
$statustext = ($service_enabled) ? gettext("Stopped") : gettext("Disabled");
$output .= "<img style=\"vertical-align:middle\" title=\"" . sprintf(gettext("%s Service is"),$service["name"]) . " {$statustext}\" src=\"/themes/" . $g["theme"] . "/images/icons/";
$output .= ($smallicon) ? "icon_block.gif" : "icon_service_stopped.gif";
$output .= "\" alt=\"status\" />&nbsp;";
if ($withtext)
$output .= "&nbsp;<font color=\"white\">{$statustext}</font>";
}
return $output;
}
function get_service_control_links($service, $addname = false) {
global $g;
$output = "";
$stitle = ($addname) ? $service['name'] . " " : "";
switch ($service['name']) {
case "openvpn":
$link = '<a title="%s" href="status_services.php?mode=%s&amp;service='.$service['name'].'.&amp;vpnmode='.$service['mode'].'.&amp;id='.$service['vpnid'].'">';
break;
case "captiveportal":
$link = '<a title="%s" href="status_services.php?mode=%s&amp;service='.$service['name'].'.&amp;zone='.$service['zone'].'">';
break;
default:
$link = '<a title="%s" href="status_services.php?mode=%s&amp;service='.$service['name'].'">';
}
if(get_service_status($service)) {
switch ($service['name']) {
case "openvpn":
$output .= "<a href='status_services.php?mode=restartservice&amp;service={$service['name']}&amp;vpnmode={$service['mode']}&amp;id={$service['vpnid']}'>";
break;
case "captiveportal":
$output .= "<a href='status_services.php?mode=restartservice&amp;service={$service['name']}&amp;zone={$service['zone']}'>";
break;
default:
$output .= "<a href='status_services.php?mode=restartservice&amp;service={$service['name']}'>";
}
$output .= "<img style=\"vertical-align:middle\" title='" . sprintf(gettext("Restart %sService"),$stitle) . "' border='0' src='./themes/".$g['theme']."/images/icons/icon_service_restart.gif' alt='restart' /></a>\n";
switch ($service['name']) {
case "openvpn":
$output .= "<a href='status_services.php?mode=stopservice&amp;service={$service['name']}&amp;vpnmode={$service['mode']}&amp;id={$service['vpnid']}'>";
break;
case "captiveportal":
$output .= "<a href='status_services.php?mode=stopservice&amp;service={$service['name']}&amp;zone={$service['zone']}'>";
break;
default:
$output .= "<a href='status_services.php?mode=stopservice&amp;service={$service['name']}'>";
}
$output .= "<img style=\"vertical-align:middle\" title='" . sprintf(gettext("Stop %sService"),$stitle) . "' border='0' src='./themes/".$g['theme']."/images/icons/icon_service_stop.gif' alt='stop' />";
$output .= "</a>";
$output .= sprintf($link, sprintf(gettext("Restart %sService"), $stitle), 'restartservice');
$output .= '<i class="icon icon-retweet"></i></a> ';
$output .= sprintf($link, sprintf(gettext("Stop %sService"), $stitle), 'stopservice');
$output .= '<i class="icon icon-off"></i></a> ';
} else {
$service_enabled = is_service_enabled($service['name']);
switch ($service['name']) {
case "openvpn":
$output .= "<a href='status_services.php?mode=startservice&amp;service={$service['name']}&amp;vpnmode={$service['mode']}&amp;id={$service['vpnid']}'>";
break;
case "captiveportal":
$output .= "<a href='status_services.php?mode=startservice&amp;service={$service['name']}&amp;zone={$service['zone']}'>";
break;
default:
if ($service_enabled)
$output .= "<a href='status_services.php?mode=startservice&amp;service={$service['name']}'>";
if($service['name'] == 'openvpn' || $service['name'] == 'captiveportal' || $service_enabled) {
$output .= sprintf($link, sprintf(gettext("Start %sService"), $stitle), 'startservice');
$output .= '<i class="icon icon-play-circle"></i></a> ';
}
if ($service_enabled)
$output .= "<img style=\"vertical-align:middle\" title='" . sprintf(gettext("Start %sService"),$stitle) . "' border='0' src='./themes/".$g['theme']."/images/icons/icon_service_start.gif' alt='start' /></a>\n";
}
return $output;
}

View File

@ -2363,7 +2363,6 @@ function install_cron_job($command, $active=false, $minute="0", $hour="*", $mont
global $config, $g;
$is_installed = false;
$cron_changed = true;
if (!is_array($config['cron']))
$config['cron'] = array();
@ -2392,13 +2391,8 @@ function install_cron_job($command, $active=false, $minute="0", $hour="*", $mont
$config['cron']['item'][] = $cron_item;
write_config(sprintf(gettext("Installed cron job for %s"), $command));
} else {
if ($config['cron']['item'][$x] == $cron_item) {
$cron_changed = false;
log_error(sprintf(gettext("Checked cron job for %s, no change needed"), $command));
} else {
$config['cron']['item'][$x] = $cron_item;
write_config(sprintf(gettext("Updated cron job for %s"), $command));
}
$config['cron']['item'][$x] = $cron_item;
write_config(sprintf(gettext("Updated cron job for %s"), $command));
}
} else {
if($is_installed == true) {
@ -2406,9 +2400,7 @@ function install_cron_job($command, $active=false, $minute="0", $hour="*", $mont
write_config(sprintf(gettext("Removed cron job for %s"), $command));
}
}
if ($cron_changed)
configure_cron();
configure_cron();
}
?>

View File

@ -1 +0,0 @@
../../../etc/ssl/openssl.cnf

View File

@ -0,0 +1,309 @@
# $FreeBSD: src/crypto/openssl/apps/openssl.cnf,v 1.6 2004/03/17 17:44:38 nectar Exp $
#
# OpenSSL example configuration file.
# This is mostly being used for generation of certificate requests.
#
#
# This definition stops the following lines choking if HOME isn't
# defined.
HOME = .
RANDFILE = $ENV::HOME/.rnd
# default SAN value if $ENV::SAN is not defined
#
SAN =
# Extra OBJECT IDENTIFIER info:
#oid_file = $ENV::HOME/.oid
oid_section = new_oids
# To use this configuration file with the "-extfile" option of the
# "openssl x509" utility, name here the section containing the
# X.509v3 extensions to use:
# extensions =
# (Alternatively, use a configuration file that has only
# X.509v3 extensions in its main [= default] section.)
[ new_oids ]
# We can add new OIDs in here for use by 'ca' and 'req'.
# Add a simple OID like this:
# testoid1=1.2.3.4
# Or use config file substitution like this:
# testoid2=${testoid1}.5.6
####################################################################
[ ca ]
default_ca = CA_default # The default ca section
####################################################################
[ CA_default ]
dir = ./demoCA # Where everything is kept
certs = $dir/certs # Where the issued certs are kept
crl_dir = $dir/crl # Where the issued crl are kept
database = $dir/index.txt # database index file.
#unique_subject = no # Set to 'no' to allow creation of
# several ctificates with same subject.
new_certs_dir = $dir/newcerts # default place for new certs.
certificate = $dir/cacert.pem # The CA certificate
serial = $dir/serial # The current serial number
#crlnumber = $dir/crlnumber # the current crl number
# must be commented out to leave a V1 CRL
crl = $dir/crl.pem # The current CRL
private_key = $dir/private/cakey.pem# The private key
RANDFILE = $dir/private/.rand # private random number file
x509_extensions = usr_cert # The extentions to add to the cert
# Comment out the following two lines for the "traditional"
# (and highly broken) format.
name_opt = ca_default # Subject Name options
cert_opt = ca_default # Certificate field options
# Extension copying option: use with caution.
# copy_extensions = copy
# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
# so this is commented out by default to leave a V1 CRL.
# crlnumber must also be commented out to leave a V1 CRL.
# crl_extensions = crl_ext
default_days = 365 # how long to certify for
default_crl_days= 30 # how long before next CRL
default_md = md5 # which md to use.
preserve = no # keep passed DN ordering
# A few difference way of specifying how similar the request should look
# For type CA, the listed attributes must be the same, and the optional
# and supplied fields are just that :-)
policy = policy_match
# For the CA policy
[ policy_match ]
countryName = match
stateOrProvinceName = match
organizationName = match
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
# For the 'anything' policy
# At this point in time, you must list all acceptable 'object'
# types.
[ policy_anything ]
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
####################################################################
[ req ]
distinguished_name=req_distinguished_name
req_extensions = v3_req
prompt=no
default_bits = 2048
default_keyfile = privkey.pem
distinguished_name = req_distinguished_name
attributes = req_attributes
x509_extensions = v3_ca # The extentions to add to the self signed cert
# Passwords for private keys if not present they will be prompted for
#input_password=""
#output_password=""
# This sets a mask for permitted string types. There are several options.
# default: PrintableString, T61String, BMPString.
# pkix : PrintableString, BMPString.
# utf8only: only UTF8Strings.
# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings).
# MASK:XXXX a literal mask value.
# WARNING: current versions of Netscape crash on BMPStrings or UTF8Strings
# so use this option with caution!
string_mask = nombstr
# req_extensions = v3_req # The extensions to add to a certificate request
[ req_distinguished_name ]
countryName = US
#countryName_default = AU
#countryName_min = 2
#countryName_max = 2
stateOrProvinceName = Somewhere
#stateOrProvinceName_default = Somestate
localityName = Somecity
0.organizationName = CompanyName
#0.organizationName_default = SampleNameDefault
# we can do this but it is not needed normally :-)
#1.organizationName = Second Organization Name (eg, company)
#1.organizationName_default = World Wide Web Pty Ltd
organizationalUnitName = Organizational Unit Name (eg, section)
#organizationalUnitName_default =
commonName = Common Name (eg, YOUR name)
#commonName_max = 64
emailAddress = Email Address
#emailAddress_max = 64
# SET-ex3 = SET extension number 3
[ req_attributes ]
challengePassword = A challenge password
#challengePassword_min = 4
#challengePassword_max = 20
unstructuredName = An optional company name
[ usr_cert ]
# These extensions are added when 'ca' signs a request.
# This goes against PKIX guidelines but some CAs do it and some software
# requires this to avoid interpreting an end user certificate as a CA.
basicConstraints=CA:FALSE
# Here are some examples of the usage of nsCertType. If it is omitted
# the certificate can be used for anything *except* object signing.
# This is OK for an SSL server.
# nsCertType = server
# For an object signing certificate this would be used.
# nsCertType = objsign
# For normal client use this is typical
# nsCertType = client, email
# and for everything including object signing:
# nsCertType = client, email, objsign
# This is typical in keyUsage for a client certificate.
# keyUsage = nonRepudiation, digitalSignature, keyEncipherment
# This will be displayed in Netscape's comment listbox.
nsComment = "OpenSSL Generated User Certificate"
# PKIX recommendations harmless if included in all certificates.
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer:always
# This stuff is for subjectAltName and issuerAltname.
# Import the email address.
# subjectAltName=email:copy
# An alternative to produce certificates that aren't
# deprecated according to PKIX.
# subjectAltName=email:move
# Copy subject details
# issuerAltName=issuer:copy
#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem
#nsBaseUrl
#nsRevocationUrl
#nsRenewalUrl
#nsCaPolicyUrl
#nsSslServerName
[ usr_cert_san ]
# copy of [ usr_cert ] plus nonempty Subject Alternative Names
basicConstraints=CA:FALSE
nsComment = "OpenSSL Generated User Certificate"
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer:always
subjectAltName=$ENV::SAN
[ server ]
# Make a cert with nsCertType=server
basicConstraints=CA:FALSE
nsCertType = server
nsComment = "OpenSSL Generated Server Certificate"
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer:always
extendedKeyUsage=serverAuth
keyUsage = digitalSignature, keyEncipherment
[ server_san ]
# copy of [ server ] plus nonempty Subject Alternative Names
basicConstraints=CA:FALSE
nsCertType = server
nsComment = "OpenSSL Generated Server Certificate"
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer:always
extendedKeyUsage=serverAuth
keyUsage = digitalSignature, keyEncipherment
subjectAltName=$ENV::SAN
[ v3_req ]
# Extensions to add to a certificate request
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
[ v3_ca ]
# Extensions for a typical CA
# PKIX recommendation.
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer:always
# This is what PKIX recommends but some broken software chokes on critical
# extensions.
#basicConstraints = critical,CA:true
# So we do this instead.
basicConstraints = CA:true
# Key usage: this is typical for a CA certificate. However since it will
# prevent it being used as an test self-signed certificate it is best
# left out by default.
# keyUsage = cRLSign, keyCertSign
# Some might want this also
# nsCertType = sslCA, emailCA
# Include email address in subject alt name: another PKIX recommendation
# subjectAltName=email:copy
# Copy issuer details
# issuerAltName=issuer:copy
# DER hex encoding of an extension: beware experts only!
# obj=DER:02:03
# Where 'obj' is a standard or added object
# You can even override a supported extension:
# basicConstraints= critical, DER:30:03:01:01:FF
[ v3_ca_san ]
# copy of [ v3_ca ] plus nonempty Subject Alternative Names
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer:always
basicConstraints = CA:true
subjectAltName=$ENV::SAN
[ crl_ext ]
# CRL extensions.
# Only issuerAltName and authorityKeyIdentifier make any sense in a CRL.
# issuerAltName=issuer:copy
authorityKeyIdentifier=keyid:always,issuer:always

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,36 @@
@import url("/bootstrap/css/bootstrap.min.css");
@import url("/bootstrap/css/bootstrap-theme.min.css");
@import url("/bootstrap/glyphicons/glyphicons-halflings.css");
html {
position: relative;
min-height: 100%;
}
body {
padding-top: 70px;
margin-bottom: 60px;
}
.navbar-brand {
padding-top: 0;
}
body.no-menu #jumbotron {
padding: 100px;
background: #3c3c3c no-repeat;
}
body.no-menu #jumbotron .container {
width: 450px;
padding-top: 50px;
background: url("/logo.png") no-repeat;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
background-color: #f5f5f5;
}

View File

@ -0,0 +1,582 @@
/*
manual-cp-man strikes again
http://getbootstrap.com/2.3.2/assets/css/bootstrap.css
*/
[class^="icon-"],
[class*=" icon-"] {
display: inline-block;
width: 14px;
height: 14px;
margin-top: 1px;
*margin-right: .3em;
line-height: 14px;
vertical-align: text-top;
background-image: url("/bootstrap/glyphicons/glyphicons-halflings.png");
background-position: 14px 14px;
background-repeat: no-repeat;
}
.icon-glass {
background-position: 0 0;
}
.icon-music {
background-position: -24px 0;
}
.icon-search {
background-position: -48px 0;
}
.icon-envelope {
background-position: -72px 0;
}
.icon-heart {
background-position: -96px 0;
}
.icon-star {
background-position: -120px 0;
}
.icon-star-empty {
background-position: -144px 0;
}
.icon-user {
background-position: -168px 0;
}
.icon-film {
background-position: -192px 0;
}
.icon-th-large {
background-position: -216px 0;
}
.icon-th {
background-position: -240px 0;
}
.icon-th-list {
background-position: -264px 0;
}
.icon-ok {
background-position: -288px 0;
}
.icon-remove {
background-position: -312px 0;
}
.icon-zoom-in {
background-position: -336px 0;
}
.icon-zoom-out {
background-position: -360px 0;
}
.icon-off {
background-position: -384px 0;
}
.icon-signal {
background-position: -408px 0;
}
.icon-cog {
background-position: -432px 0;
}
.icon-trash {
background-position: -456px 0;
}
.icon-home {
background-position: 0 -24px;
}
.icon-file {
background-position: -24px -24px;
}
.icon-time {
background-position: -48px -24px;
}
.icon-road {
background-position: -72px -24px;
}
.icon-download-alt {
background-position: -96px -24px;
}
.icon-download {
background-position: -120px -24px;
}
.icon-upload {
background-position: -144px -24px;
}
.icon-inbox {
background-position: -168px -24px;
}
.icon-play-circle {
background-position: -192px -24px;
}
.icon-repeat {
background-position: -216px -24px;
}
.icon-refresh {
background-position: -240px -24px;
}
.icon-list-alt {
background-position: -264px -24px;
}
.icon-lock {
background-position: -287px -24px;
}
.icon-flag {
background-position: -312px -24px;
}
.icon-headphones {
background-position: -336px -24px;
}
.icon-volume-off {
background-position: -360px -24px;
}
.icon-volume-down {
background-position: -384px -24px;
}
.icon-volume-up {
background-position: -408px -24px;
}
.icon-qrcode {
background-position: -432px -24px;
}
.icon-barcode {
background-position: -456px -24px;
}
.icon-tag {
background-position: 0 -48px;
}
.icon-tags {
background-position: -25px -48px;
}
.icon-book {
background-position: -48px -48px;
}
.icon-bookmark {
background-position: -72px -48px;
}
.icon-print {
background-position: -96px -48px;
}
.icon-camera {
background-position: -120px -48px;
}
.icon-font {
background-position: -144px -48px;
}
.icon-bold {
background-position: -167px -48px;
}
.icon-italic {
background-position: -192px -48px;
}
.icon-text-height {
background-position: -216px -48px;
}
.icon-text-width {
background-position: -240px -48px;
}
.icon-align-left {
background-position: -264px -48px;
}
.icon-align-center {
background-position: -288px -48px;
}
.icon-align-right {
background-position: -312px -48px;
}
.icon-align-justify {
background-position: -336px -48px;
}
.icon-list {
background-position: -360px -48px;
}
.icon-indent-left {
background-position: -384px -48px;
}
.icon-indent-right {
background-position: -408px -48px;
}
.icon-facetime-video {
background-position: -432px -48px;
}
.icon-picture {
background-position: -456px -48px;
}
.icon-pencil {
background-position: 0 -72px;
}
.icon-map-marker {
background-position: -24px -72px;
}
.icon-adjust {
background-position: -48px -72px;
}
.icon-tint {
background-position: -72px -72px;
}
.icon-edit {
background-position: -96px -72px;
}
.icon-share {
background-position: -120px -72px;
}
.icon-check {
background-position: -144px -72px;
}
.icon-move {
background-position: -168px -72px;
}
.icon-step-backward {
background-position: -192px -72px;
}
.icon-fast-backward {
background-position: -216px -72px;
}
.icon-backward {
background-position: -240px -72px;
}
.icon-play {
background-position: -264px -72px;
}
.icon-pause {
background-position: -288px -72px;
}
.icon-stop {
background-position: -312px -72px;
}
.icon-forward {
background-position: -336px -72px;
}
.icon-fast-forward {
background-position: -360px -72px;
}
.icon-step-forward {
background-position: -384px -72px;
}
.icon-eject {
background-position: -408px -72px;
}
.icon-chevron-left {
background-position: -432px -72px;
}
.icon-chevron-right {
background-position: -456px -72px;
}
.icon-plus-sign {
background-position: 0 -96px;
}
.icon-minus-sign {
background-position: -24px -96px;
}
.icon-remove-sign {
background-position: -48px -96px;
}
.icon-ok-sign {
background-position: -72px -96px;
}
.icon-question-sign {
background-position: -96px -96px;
}
.icon-info-sign {
background-position: -120px -96px;
}
.icon-screenshot {
background-position: -144px -96px;
}
.icon-remove-circle {
background-position: -168px -96px;
}
.icon-ok-circle {
background-position: -192px -96px;
}
.icon-ban-circle {
background-position: -216px -96px;
}
.icon-arrow-left {
background-position: -240px -96px;
}
.icon-arrow-right {
background-position: -264px -96px;
}
.icon-arrow-up {
background-position: -289px -96px;
}
.icon-arrow-down {
background-position: -312px -96px;
}
.icon-share-alt {
background-position: -336px -96px;
}
.icon-resize-full {
background-position: -360px -96px;
}
.icon-resize-small {
background-position: -384px -96px;
}
.icon-plus {
background-position: -408px -96px;
}
.icon-minus {
background-position: -433px -96px;
}
.icon-asterisk {
background-position: -456px -96px;
}
.icon-exclamation-sign {
background-position: 0 -120px;
}
.icon-gift {
background-position: -24px -120px;
}
.icon-leaf {
background-position: -48px -120px;
}
.icon-fire {
background-position: -72px -120px;
}
.icon-eye-open {
background-position: -96px -120px;
}
.icon-eye-close {
background-position: -120px -120px;
}
.icon-warning-sign {
background-position: -144px -120px;
}
.icon-plane {
background-position: -168px -120px;
}
.icon-calendar {
background-position: -192px -120px;
}
.icon-random {
width: 16px;
background-position: -216px -120px;
}
.icon-comment {
background-position: -240px -120px;
}
.icon-magnet {
background-position: -264px -120px;
}
.icon-chevron-up {
background-position: -288px -120px;
}
.icon-chevron-down {
background-position: -313px -119px;
}
.icon-retweet {
background-position: -336px -120px;
}
.icon-shopping-cart {
background-position: -360px -120px;
}
.icon-folder-close {
width: 16px;
background-position: -384px -120px;
}
.icon-folder-open {
width: 16px;
background-position: -408px -120px;
}
.icon-resize-vertical {
background-position: -432px -119px;
}
.icon-resize-horizontal {
background-position: -456px -118px;
}
.icon-hdd {
background-position: 0 -144px;
}
.icon-bullhorn {
background-position: -24px -144px;
}
.icon-bell {
background-position: -48px -144px;
}
.icon-certificate {
background-position: -72px -144px;
}
.icon-thumbs-up {
background-position: -96px -144px;
}
.icon-thumbs-down {
background-position: -120px -144px;
}
.icon-hand-right {
background-position: -144px -144px;
}
.icon-hand-left {
background-position: -168px -144px;
}
.icon-hand-up {
background-position: -192px -144px;
}
.icon-hand-down {
background-position: -216px -144px;
}
.icon-circle-arrow-right {
background-position: -240px -144px;
}
.icon-circle-arrow-left {
background-position: -264px -144px;
}
.icon-circle-arrow-up {
background-position: -288px -144px;
}
.icon-circle-arrow-down {
background-position: -312px -144px;
}
.icon-globe {
background-position: -336px -144px;
}
.icon-wrench {
background-position: -360px -144px;
}
.icon-tasks {
background-position: -384px -144px;
}
.icon-filter {
background-position: -408px -144px;
}
.icon-briefcase {
background-position: -432px -144px;
}
.icon-fullscreen {
background-position: -456px -144px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

File diff suppressed because one or more lines are too long

View File

@ -1,46 +0,0 @@
/* Element CSS Definitions for (MultiRow-)tables
if theme changes are needed include a table.css in the /themes/yourtheme/ */
.listMR {
background-color: #DDD;
font-size: 11px;
padding-left: 6px;
padding-top: 2px;
padding-bottom: 2px;
}
.listMRlr {
border-right: 1px solid #999999;
border-bottom: 1px solid #999999;
border-left: 1px solid #999999;
font-size: 11px;
padding-right: 6px;
padding-left: 6px;
padding-top: 4px;
padding-bottom: 4px;
}
.listMRr {
border-right: 1px solid #999999;
border-bottom: 1px solid #999999;
font-size: 11px;
padding-right: 6px;
padding-left: 6px;
padding-top: 4px;
padding-bottom: 4px;
}
.listMRodd {
background-color: #FFFFFF;
}
.listMReven {
background-color: #F0F0F0;
}
.listMRDescriptionL {
border-right: none;
border-bottom: 2px solid #999999;
}
.listMRDescriptionR {
border-left: none;
border-bottom: 2px solid #999999;
}
.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
}

View File

@ -88,20 +88,19 @@ function output_menu($arrayitem, $target = null) {
if ($item['style']) {
$attr .= sprintf(" style=\"%s\"", htmlentities($item['style']));
}
echo "<li>\n";
printf("<a %s>%s</a>\n", $attr, $item[0]);
echo "</li>\n";
echo "<li>". sprintf("<a %s>%s</a>", $attr, $item[0]). "</li>\n";
}
}
}
// System
$system_menu = array();
$system_menu[] = array(gettext("Logout"), "/index.php?logout");
$system_menu[] = array(gettext("Advanced"), "/system_advanced_admin.php");
$system_menu[] = array(gettext("Firmware"), "/system_firmware.php");
$system_menu[] = array(gettext("General Setup"), "/system.php");
$system_menu[] = array(gettext("High Avail. Sync"), "/system_hasync.php");
$system_menu[] = array(gettext("Logout"), "/index.php?logout");
if ($g['platform'] == "pfSense" or $g['platform'] == "nanobsd")
$system_menu[] = array(gettext("Packages"), "/pkg_mgr_installed.php");
$system_menu[] = array(gettext("Setup Wizard"), "/wizard.php?xml=setup_wizard.xml");
@ -249,7 +248,7 @@ if(! $g['disablehelpmenu']) {
$help_menu = array();
$help_menu[] = array(gettext("About this Page"), $helpurl);
if($g['product_name'] == "pfSense")
$help_menu[] = array(gettext("Bug Database"), "https://www.pfsense.org/j.php?jumpto=redmine");
$help_menu[] = array(gettext("Bug Database"), "https://www.pfsense.org/j.php?jumpto=redmine");
$help_menu[] = array(gettext("User Forum"), "https://www.pfsense.org/j.php?jumpto=forum");
$help_menu[] = array(gettext("Documentation"), "https://www.pfsense.org/j.php?jumpto=doc");
$help_menu[] = array(gettext("Developers Wiki"), "https://www.pfsense.org/j.php?jumpto=devwiki");
@ -261,144 +260,108 @@ if(! $g['disablehelpmenu']) {
}
?>
<nav class="navbar navbar-fixed-top navbar-inverse">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div id="wrapper">
<div id="header">
<div id="header-left"><a href="/index.php" id="status-link"><img src="/themes/<?= $g['theme']; ?>/images/transparent.gif" border="0" alt="transparent" /></a></div>
<div id="header-right">
<div class="container">
<div class="left">webConfigurator</div>
<div class="right" id="menu_messages">
<?php
echo get_menu_messages();
?>
</div>
</div>
<a class="navbar-brand" href="/"><img src="/logo.png" alt="pfSense" /></a>
</div>
</div> <!-- Header DIV -->
<div id="content">
<div id="left">
<div id="navigation" style="z-index:1000;">
<ul id="menu">
<li class="firstdrop">
<div><?php echo gettext("System"); ?></div>
<ul class="subdrop">
<?php
output_menu($system_menu);
?>
</ul>
</li>
<li class="drop">
<div><?php echo gettext("Interfaces"); ?></div>
<ul class="subdrop">
<?php
output_menu($interfaces_menu);
?>
</ul>
</li>
<li class="drop">
<div><?php echo gettext("Firewall"); ?></div>
<ul class="subdrop">
<?php
output_menu($firewall_menu);
?>
</ul>
</li>
<li class="drop">
<div><?php echo gettext("Services"); ?></div>
<ul class="subdrop">
<?php
output_menu($services_menu);
?>
</ul>
</li>
<li class="drop">
<div><?php echo gettext("VPN"); ?></div>
<ul class="subdrop">
<?php
output_menu($vpn_menu);
?>
</ul>
</li>
<li class="drop">
<div><?php echo gettext("Status"); ?></div>
<ul class="subdrop">
<?php
output_menu($status_menu);
?>
</ul>
</li>
<li class="drop">
<div><?php echo gettext("Diagnostics"); ?></div>
<ul id="diag" class="subdrop">
<?php
output_menu($diagnostics_menu);
?>
</ul>
</li>
<li class="drop">
<div><?php echo gettext("Gold"); ?></div>
<ul id="gold" class="subdrop">
<?php
output_menu($gold_menu, "_blank");
?>
</ul>
</li>
<?php if(! $g['disablehelpmenu']): ?>
<li class="lastdrop">
<div><?php echo gettext("Help"); ?></div>
<ul id="help" class="subdrop">
<?php
output_menu($help_menu, "_blank");
?>
</ul>
</li>
<?php endif; ?>
</ul>
</div>
</div> <!-- Left DIV -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?=gettext("System"); ?>
<span class="caret"></span>
</a>
<div id="right">
<ul class="dropdown-menu" role="menu"><?=output_menu($system_menu)?></ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?=gettext("Interfaces"); ?>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu"><?=output_menu($interfaces_menu)?></ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?=gettext("Firewall"); ?>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu"><?=output_menu($firewall_menu)?></ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?=gettext("Services"); ?>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu"><?=output_menu($services_menu)?></ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?=gettext("VPN"); ?>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu"><?=output_menu($vpn_menu)?></ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?=gettext("Status"); ?>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu"><?=output_menu($status_menu)?></ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?=gettext("Diagnostics"); ?>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu"><?=output_menu($diagnostics_menu)?></ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?=gettext("Gold"); ?>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu"><?=output_menu($gold_menu, "_blank")?></ul>
</li>
<?php if(are_notices_pending()):?>
<?php $notices = get_notices(); ?>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?=gettext("Notices"); ?>
<span class="badge"><?=count($notices)?></span>
<span class="caret"></span>
</a>
<?=print_notices($notices)?>
</li>
<?php endif; ?>
<?php if(! $g['disablehelpmenu']): ?>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?=gettext("Help"); ?>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu"><?=output_menu($help_menu, "_blank"); ?></ul>
</li>
<?php endif; ?>
</ul>
</div>
</div>
</nav>
<div class="container">
<h1><?=genhtmltitle($pgtitle);?></h1>
<?php
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domLib.js\"></script>\n";
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domTT.js\"></script>\n";
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/behaviour.js\"></script>\n";
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/fadomatic.js\"></script>\n";
/* display a top alert bar if need be */
$need_alert_display = false;
$found_notices = are_notices_pending();
if($found_notices == true) {
$notices = get_notices();
if(!$notices) {
$need_alert_display = true;
$display_text = print_notices($notices) . "<br />";
}
}
if($need_alert_display == true) {
echo "<div style=\"background-color:#000000\" id=\"roundalert\">";
echo "<table summary=\"round alert\">";
echo "<tr><td><font color=\"#ffffff\">";
echo "&nbsp;&nbsp;<img align=\"middle\" src=\"/top_notification.gif\" alt=\"notification\" />&nbsp;&nbsp;&nbsp;";
echo $display_text;
echo "</font></td>";
echo "</tr>";
echo "</table>";
echo "</div>";
}
function add_to_menu($url, $name) {
if (isAllowedPage($url))
echo "<li><a href=\"{$url}\" class=\"navlnk\">{$name}</a></li>\n";
}
?>
<div>
<span class="pgtitle"><a href="<?= htmlentities($_SERVER['REQUEST_URI']) ?>"><?=genhtmltitle($pgtitle);?></a></span>
<span style="float:right; margin: 0 0 20px 20px">
<?php
/*
//FIXME
if (!$hide_service_status && !empty($shortcuts[$shortcut_section]['service'])) {
$ssvc = array();
switch ($shortcut_section) {
@ -421,15 +384,14 @@ if (!$hide_service_status && !empty($shortcuts[$shortcut_section]['service'])) {
echo get_shortcut_main_link($shortcut_section, true);
echo get_shortcut_status_link($shortcut_section, true);
echo get_shortcut_log_link($shortcut_section, true);
*/
?>
<?php if(! $g['disablehelpicon']): ?>
<a href="<?php echo $helpurl; ?>" title="<?php echo gettext("Help for items on this page"); ?>"><img style="vertical-align:middle" src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_help.gif" border="0" alt="help" /></a>
<?php if(! $g['disablehelpicon']): ?>
<a href="<?=$helpurl?>" title="<?=gettext("Help for items on this page")?>">
<i class="icon-large icon-question-sign"></i>
</a>
<?php endif; ?>
</span>
</div>
<br />
<?php
/* if upgrade in progress, alert user */
@ -443,4 +405,4 @@ if (is_subsystem_dirty('packagelock') || (file_exists('/conf/needs_package_sync'
print_info_box($info_text . "<p><img src='/themes/{$g['theme']}/images/icons/icon_fw-update.gif' alt='firmware update' />");
}
$pgtitle_output = true;
?>
?>

View File

@ -2,26 +2,17 @@
pfSense_MODULE: footer
-->
</div> <!-- Right DIV -->
</div> <!-- Content DIV -->
<div id="footer">
<a target="_blank" href="<?=$g['product_website_footer']?>" class="redlnk"><?=$g['product_name']?></a> is &copy;
<?=$g['product_copyright_years']?> by <a href="<?=$g['product_copyright_url']?>" class="tblnk"><?=$g['product_copyright']?></a>. All Rights Reserved.
[<a href="/license.php" class="tblnk">view license</a>]
</div> <!-- Footer DIV -->
</div>
</div> <!-- Wrapper Div -->
<footer class="footer">
<div class="container">
<p class="text-muted">
<a target="_blank" href="<?=$g['product_website_footer']?>"><?=$g['product_name']?></a> is &copy;
<?=$g['product_copyright_years']?> by <a href="<?=$g['product_copyright_url']?>" class="tblnk"><?=$g['product_copyright']?></a>. All Rights Reserved.
[<a href="/license.php" class="tblnk">view license</a>]
</p>
</div>
</footer>
<?php outputJavaScriptFileInline("/usr/local/www/themes/{$g['theme']}/bottom-loader.js");
/* Disable form autocomplete on all but the login screen. */
if (basename($_SERVER["SCRIPT_FILENAME"] != "index.php") && !$allowautocomplete): ?>
<script type="text/javascript">
//<![CDATA[
(function ($) {
$("input").attr("autocomplete","off");
})(jQuery);
//]]>
</script>
<?php endif; ?>
<script src="/jquery/jquery-1.11.1.min.js"></script>
<script src="/bootstrap/js/bootstrap.min.js"></script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 B

View File

@ -97,15 +97,15 @@ if(!$ignorefirmwarelock) {
/* Reserved table names to avoid colision */
$reserved_table_names = array(
"bogons",
"bogonsv6",
"negate_networks",
"snort2c",
"sshlockout",
"tonatsubnets",
"virusprot",
"vpn_networks",
"webConfiguratorlockout"
"bogons",
"bogonsv6",
"negate_networks",
"snort2c",
"sshlockout",
"tonatsubnets",
"virusprot",
"vpn_networks",
"webConfiguratorlockout"
);
$firewall_rules_dscp_types = array("af11",
@ -275,9 +275,9 @@ function print_input_errors($input_errors) {
<td class="inputerrorsleft">
<img src="/themes/{$g['theme']}/images/icons/icon_error.gif" alt="errors" />
</td>
<td class="inputerrorsright errmsg">
<td class="inputerrorsright errmsg">
EOF;
echo "<p>" . gettext("The following input errors were detected:") . "</p>\n<ul>";
echo "<p>" . gettext("The following input errors were detected:") . "</p>\n<ul>";
foreach ($input_errors as $ierr) {
echo "<li>" . htmlspecialchars($ierr) . "</li>";
}
@ -312,63 +312,15 @@ function print_info_box_np($msg, $name="apply",$value="", $showapply=false) {
$nifty_background = "#FFF";
if(stristr($msg, gettext("apply")) != false || stristr($msg, gettext("save")) != false || stristr($msg, gettext("create")) != false || $showapply) {
$savebutton = "<td class=\"infoboxsave\">";
$savebutton .= "<input name=\"{$name}\" type=\"submit\" class=\"formbtn\" id=\"${name}\" value=\"{$value}\" />";
$dismiss = "alert-dismissible";
$button = '<button type="submit" class="btn btn-primary" name="login" value="'.$value.'">'.$name.'</button>';
if($_POST['if'])
$savebutton .= "<input type=\"hidden\" name=\"if\" value=\"" . htmlspecialchars($_POST['if']) . "\" />";
$savebutton.="</td>";
}
$nifty_redbox = "#990000";
$nifty_blackbox = "#000000";
$themename = $g['theme'];
if(file_exists("/usr/local/www/themes/{$themename}/tabcontrols.php")) {
$toeval = file_get_contents("/usr/local/www/themes/{$themename}/tabcontrols.php");
eval($toeval);
}
if(file_exists("/usr/local/www/themes/{$themename}/infobox.php")) {
$toeval = file_get_contents("/usr/local/www/themes/{$themename}/infobox.php");
eval($toeval);
}
if(!$savebutton) {
$savebutton = "<td class=\"infoboxsave\"><input value=\"" . gettext("Close") . "\" type=\"button\" onclick=\"jQuery(this).parents('table[id=redboxtable]').hide();\" /></td>";
}
echo <<<EOFnp
<table class="infobox" id="redboxtable" summary="red box table">
<tr>
<td>
<div class="infoboxnp" id="redbox">
<table class="infoboxnptable2" summary="message">
<tr>
<td class="infoboxnptd">
&nbsp;&nbsp;&nbsp;<img class="infoboxnpimg" src="/themes/{$g['theme']}/images/icons/icon_exclam.gif" alt="exclamation" />
</td>
<td class="infoboxnptd2">
<b>{$msg}</b>
</td>
{$savebutton}
</tr>
</table>
</div>
<div>
<p>&nbsp;</p>
</div>
</td>
</tr>
</table>
<script type="text/javascript">
//<![CDATA[
NiftyCheck();
Rounded("div#redbox","all","{$nifty_background}","{$nifty_redbox}","smooth");
Rounded("td#blackbox","all","{$nifty_background}","{$nifty_blackbox}","smooth");
//]]>
</script>
EOFnp;
} else
$button = '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
echo '<div class="alert alert-warning" role="alert">'.$msg.'</div>';
}
function print_info_box_np_undo($msg, $name="apply",$value="Apply changes", $undo) {
@ -950,7 +902,7 @@ function echo_array($array,$return_me=false){
* NAME
* display_top_tabs - display tabs with rounded edges
* INPUTS
* $text - array of tabs
* $text - array of tabs
* RESULT
* null
******/

View File

@ -3,8 +3,6 @@
pfSense_MODULE: header
*/
$g['theme'] = get_current_theme();
$pagetitle = gentitle( $pgtitle );
if (isset($config['system']['webgui']['pagenamefirst']))
@ -12,105 +10,23 @@ if (isset($config['system']['webgui']['pagenamefirst']))
else
$tabtitle = $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pagetitle;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?=system_get_language_code();?>" xml:lang="<?=system_get_language_code();?>">
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo($tabtitle); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?=system_get_language_codeset();?>" />
<link rel="apple-touch-icon" href="/themes/<?php echo $g['theme']; ?>/apple-touch-icon.png"/>
<link rel="shortcut icon" href="/themes/<?php echo $g['theme']; ?>/images/icons/favicon.ico"/>
<?php
if (file_exists("{$g['www_path']}/themes/{$g['theme']}/table.css")):
echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/table.css\" />";
else:
echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/css/table.css\" media=\"all\" />";
endif;
?>
<?php if (strpos($_SERVER["SCRIPT_FILENAME"], "wizard.php") !== false &&
file_exists("{$g['www_path']}/themes/{$g['theme']}/wizard.css")): ?>
<?php echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" />"; ?>
<?php else: ?>
<link type="text/css" rel="stylesheet" href="/themes/<?php echo $g['theme']; ?>/all.css" media="all" />
<?php endif; ?>
<link rel="stylesheet" type="text/css" href="/niftycssCode.css" />
<link rel="stylesheet" type="text/css" href="/niftycssprintCode.css" media="print" />
<link rel="stylesheet" type="text/css" href="/themes/<?=$g['theme']?>/new_tab_menu.css" media="all" />
<link rel="stylesheet" type="text/css" href="javascript/jquery/jquery-ui-1.11.1.css" />
<script type="text/javascript" src="/javascript/niftyjsCode.js"></script>
<script type="text/javascript" src="/javascript/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="/javascript/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="/javascript/jquery/jquery-ui-1.11.1.min.js"></script>
<script type="text/javascript">
//<![CDATA[
var theme = "<?php echo $g['theme']; ?>";
jQuery.noConflict();
//]]>
</script>
<script type="text/javascript" src="/javascript/sorttable.js"></script>
<script type="text/javascript" src="/javascript/ticker.js"></script>
<style type="text/css" id="antiClickjack">
/*<![CDATA[*/
body{display:none}
/*]]>*/
</style>
<script type="text/javascript">
//<![CDATA[
if (self === top) {
var antiClickjack = document.getElementById("antiClickjack"); antiClickjack.parentNode.removeChild(antiClickjack);
} else {
top.location = self.location;
}
//]]>
</script>
<?php echo "\t<script type=\"text/javascript\" src=\"/themes/{$g['theme']}/loader.js\"></script>\n"; ?>
<link rel="stylesheet" href="/bootstrap/css/pfSense.css" />
<title><?= $tabtitle ?></title>
</head>
<?php
if($_GET['enablefirebuglite']) {
echo "\t<script type=\"text/javascript\" src=\"/javascript/pi.js\"></script>\n";
echo "\t<script type=\"text/javascript\" src=\"/javascript/firebug-lite.js\"></script>\n";
}
echo "\t<script type=\"text/javascript\" src=\"/javascript/scriptaculous/prototype.js\"></script>\n";
echo "\t<script type=\"text/javascript\" src=\"/javascript/scriptaculous/scriptaculous.js\"></script>\n";
echo "\t<script type=\"text/javascript\" src=\"/javascript/scriptaculous/effects.js\"></script>\n";
echo "\t<script type=\"text/javascript\" src=\"/javascript/scriptaculous/dragdrop.js\"></script>\n";
if(file_exists("{$g['www_path']}/javascript/global.js"))
echo "\t<script type=\"text/javascript\" src=\"/javascript/global.js\"></script>\n";
/*
* Find all javascript files that need to be included
* for this page ... from the arrays ... :)
* Coded by: Erik Kristensen
*/
$dir = trim(basename($_SERVER["SCRIPT_FILENAME"], '.php'));
$path = "{$g['www_path']}/javascript/" . $dir . "/";
if (is_dir($path)) {
if ($dh = opendir($path)) {
while (($file = readdir($dh)) !== false) {
if (is_dir($file))
continue;
echo "\t<script type=\"text/javascript\" src=\"/javascript/{$dir}/{$file}\"></script>\n";
}
closedir($dh);
}
}
if (!isset($closehead))
echo "</head>";
/* If this page is being remotely managed then do not allow the loading of the contents. */
if($config['remote_managed_pages']['item']) {
if ($config['remote_managed_pages']['item']) {
foreach($config['remote_managed_pages']['item'] as $rmp) {
if($rmp == $_SERVER['SCRIPT_NAME']) {
if ($rmp == $_SERVER['SCRIPT_NAME']) {
include("fbegin.inc");
print_info_box_np("This page is currently being managed by a remote machine.");
include("fend.inc");
exit;
}
}
}
}
?>
?>

View File

@ -1,29 +1,29 @@
<?php
/*
headjs.php
headjs.php
Copyright (C) 2013-2014 Electric Sheep Fencing, LP
Copyright (C) 2013-2014 Electric Sheep Fencing, LP
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
pfSense_MODULE: header
@ -42,13 +42,13 @@ function getHeadJS() {
global $g, $use_loader_tab_gif;
if(!$use_loader_tab_gif)
$loader_gif = "/themes/{$g['theme']}/images/misc/loader.gif";
$loader_gif = "/themes/{$g['theme']}/images/misc/loader.gif";
else
$loader_gif = "/themes/{$g['theme']}/images/misc/loader_tab.gif";
$loader_gif = "/themes/{$g['theme']}/images/misc/loader_tab.gif";
$headjs = "
var input_errors = '';
jQuery(document).ready(init);
var input_errors = '';
jQuery(document).ready(init);
";
if (!session_id())
session_start();
@ -56,115 +56,115 @@ function getHeadJS() {
session_commit();
$headjs .= "
{$noajax}
{$noajax}
function init() {
if(jQuery('#submit') && ! noAjaxOnSubmit) {
// debugging helper
//alert('adding observe event for submit button');
jQuery(\"#submit\").click(submit_form);
jQuery('#submit').click(function() {return false;});
var to_insert = \"<div style='visibility:hidden' id='loading' name='loading'><img src='{$loader_gif}' alt='loader' \/><\/div>\";
jQuery('#submit').before(to_insert);
}
}
function submit_form(e){
// debugging helper
//alert(Form.serialize($('iform')));
function init() {
if(jQuery('#submit') && ! noAjaxOnSubmit) {
// debugging helper
//alert('adding observe event for submit button');
jQuery(\"#submit\").click(submit_form);
jQuery('#submit').click(function() {return false;});
var to_insert = \"<div style='visibility:hidden' id='loading' name='loading'><img src='{$loader_gif}' alt='loader' \/><\/div>\";
jQuery('#submit').before(to_insert);
}
}
function submit_form(e){
// debugging helper
//alert(Form.serialize($('iform')));
if(jQuery('#inputerrors'))
jQuery('#inputerrors').html('<center><b><i>Loading...<\/i><\/b><\/center>');
/* dsh: Introduced because pkg_edit tries to set some hidden fields
* if executing submit's onclick event. The click gets deleted
* by Ajax. Hence using onkeydown instead.
*/
if(jQuery('#submit').prop('keydown')) {
jQuery('#submit').keydown();
jQuery('#submit').css('visibility','hidden');
}
if(jQuery('#cancelbutton'))
jQuery('#cancelbutton').css('visibility','hidden');
jQuery('#loading').css('visibility','visible');
// submit the form using Ajax
}
function formSubmitted(resp) {
var responseText = resp.responseText;
// debugging helper
// alert(responseText);
if(responseText.indexOf('html') > 0) {
/* somehow we have been fed an html page! */
//alert('Somehow we have been fed an html page! Forwarding to /.');
document.location.href = '/';
}
eval(responseText);
}
/* this function will be called if an HTTP error will be triggered */
function formFailure(resp) {
showajaxmessage(resp.responseText);
if(jQuery('#submit'))
jQuery('#submit').css('visibility','visible');
if(jQuery('#inputerrors'))
jQuery('#inputerrors').html('<center><b><i>Loading...<\/i><\/b><\/center>');
/* dsh: Introduced because pkg_edit tries to set some hidden fields
* if executing submit's onclick event. The click gets deleted
* by Ajax. Hence using onkeydown instead.
*/
if(jQuery('#submit').prop('keydown')) {
jQuery('#submit').keydown();
jQuery('#submit').css('visibility','hidden');
}
if(jQuery('#cancelbutton'))
jQuery('#cancelbutton').css('visibility','visible');
jQuery('#cancelbutton').css('visibility','hidden');
jQuery('#loading').css('visibility','visible');
// submit the form using Ajax
}
function formSubmitted(resp) {
var responseText = resp.responseText;
// debugging helper
// alert(responseText);
if(responseText.indexOf('html') > 0) {
/* somehow we have been fed an html page! */
//alert('Somehow we have been fed an html page! Forwarding to /.');
document.location.href = '/';
}
eval(responseText);
}
/* this function will be called if an HTTP error will be triggered */
function formFailure(resp) {
showajaxmessage(resp.responseText);
if(jQuery('#submit'))
jQuery('#submit').css('visibility','visible');
if(jQuery('#cancelbutton'))
jQuery('#cancelbutton').css('visibility','visible');
if(jQuery('#loading'))
jQuery('#loading').css('visibility','hidden');
jQuery('#loading').css('visibility','hidden');
}
function showajaxmessage(message) {
var message_html;
}
function showajaxmessage(message) {
var message_html;
if (message == '') {
NiftyCheck();
Rounded(\"div#redbox\",\"all\",\"#FFF\",\"#990000\",\"smooth\");
Rounded(\"td#blackbox\",\"all\",\"#FFF\",\"#000000\",\"smooth\");
if (message == '') {
NiftyCheck();
Rounded(\"div#redbox\",\"all\",\"#FFF\",\"#990000\",\"smooth\");
Rounded(\"td#blackbox\",\"all\",\"#FFF\",\"#000000\",\"smooth\");
if(jQuery('#submit'))
jQuery('#submit').css('visibility','visible');
if(jQuery('#cancelbutton'))
jQuery('#cancelbutton').css('visibility','visible');
if(jQuery('#loading'))
jQuery('#loading').css('visibility','hidden');
if(jQuery('#submit'))
jQuery('#submit').css('visibility','visible');
if(jQuery('#cancelbutton'))
jQuery('#cancelbutton').css('visibility','visible');
if(jQuery('#loading'))
jQuery('#loading').css('visibility','hidden');
return;
}
return;
}
message_html = '<table height=\"32\" width=\"100%\" summary=\"redbox\"><tr><td>';
message_html += '<div style=\"background-color:#990000\" id=\"redbox\">';
message_html += '<table width=\"100%\" summary=\"message\"><tr><td width=\"8%\">';
message_html += '<img style=\"vertical-align:center\" src=\"/themes/{$g['theme']}/images/icons/icon_exclam.gif\" width=\"28\" height=\"32\" alt=\"exclamation\" \/>';
message_html += '<\/td><td width=\"70%\"><font color=\"white\">';
message_html += '<b>' + message + '<\/b><\/font><\/td>';
message_html = '<table><tr><td>';
message_html += '<div style=\"background-color:#990000\" id=\"redbox\">';
message_html += '<table><tr><td width=\"8%\">';
message_html += '<img style=\"vertical-align:center\" src=\"/themes/{$g['theme']}/images/icons/icon_exclam.gif\" width=\"28\" height=\"32\" alt=\"exclamation\" \/>';
message_html += '<\/td><td width=\"70%\"><font color=\"white\">';
message_html += '<b>' + message + '<\/b><\/font><\/td>';
if(message.indexOf('apply') > 0) {
message_html += '<td>';
message_html += '<input name=\"apply\" type=\"submit\" class=\"formbtn\" id=\"apply\" value=\"" . gettext("Apply changes") . "\" \/>';
message_html += '<\/td>';
}
if(message.indexOf('apply') > 0) {
message_html += '<td>';
message_html += '<input name=\"apply\" type=\"submit\" class=\"formbtn\" id=\"apply\" value=\"" . gettext("Apply changes") . "\" \/>';
message_html += '<\/td>';
}
message_html += '<\/tr><\/table><\/div><\/td><\/table><br \/>';
jQuery('#inputerrors').html(message_html);
message_html += '<\/tr><\/table><\/div><\/td><\/table><br \/>';
jQuery('#inputerrors').html(message_html);
NiftyCheck();
Rounded(\"div#redbox\",\"all\",\"#FFF\",\"#990000\",\"smooth\");
Rounded(\"td#blackbox\",\"all\",\"#FFF\",\"#000000\",\"smooth\");
NiftyCheck();
Rounded(\"div#redbox\",\"all\",\"#FFF\",\"#990000\",\"smooth\");
Rounded(\"td#blackbox\",\"all\",\"#FFF\",\"#000000\",\"smooth\");
if(jQuery('#submit'))
jQuery('#submit').css('visibility','visible');
if(jQuery('#cancelbutton'))
jQuery('#cancelbutton').css('visibility','visible');
if(jQuery('#loading'))
jQuery('#loading').css('visibility','hidden');
if(jQuery('#inputerrors'))
window.scrollTo(0, 0);
}
if(jQuery('#submit'))
jQuery('#submit').css('visibility','visible');
if(jQuery('#cancelbutton'))
jQuery('#cancelbutton').css('visibility','visible');
if(jQuery('#loading'))
jQuery('#loading').css('visibility','hidden');
if(jQuery('#inputerrors'))
window.scrollTo(0, 0);
}
";
return $headjs;

View File

@ -2,7 +2,7 @@
/* $Id$ */
/*
index.php
Copyright (C) 2013-2014 Electric Sheep Fencing, LP
Copyright (C) 2013-2014 Electric Sheep Fencing, LP
Copyright (C) 2004-2012 Scott Ullrich
All rights reserved.
@ -14,11 +14,11 @@
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
@ -87,181 +87,141 @@ if($g['disablecrashreporter'] != true) {
}
##build list of widgets
$directory = "/usr/local/www/widgets/widgets/";
$dirhandle = opendir($directory);
$filename = "";
$widgetnames = array();
$widgetfiles = array();
$widgetlist = array();
while (false !== ($filename = readdir($dirhandle))) {
$periodpos = strpos($filename, ".");
/* Ignore files not ending in .php */
if (substr($filename, -4, 4) != ".php")
continue;
$widgetname = substr($filename, 0, $periodpos);
$widgetnames[] = $widgetname;
if ($widgetname != "system_information")
$widgetfiles[] = $filename;
foreach (glob("/usr/local/www/widgets/widgets/*.widget.php") as $file)
{
list($name, $ext) = explode('.widget.php', basename($file), 2);
$widgets[ $name ] = array('name' => ucwords(str_replace('_', ' ', $name)));
}
##sort widgets alphabetically
sort($widgetfiles);
##insert the system information widget as first, so as to be displayed first
array_unshift($widgetfiles, "system_information.widget.php");
unset($widgets['system_information']);
$widgets = array_merge(array('system_information' => array('name' => 'System Information')), $widgets);
##if no config entry found, initialize config entry
if (!is_array($config['widgets'])) {
$config['widgets'] = array();
}
if ($_POST && $_POST['submit']) {
$config['widgets']['sequence'] = $_POST['sequence'];
if ($_POST && $_POST['submit']) {
$config['widgets']['sequence'] = $_POST['sequence'];
foreach ($widgetnames as $widget){
if ($_POST[$widget . '-config']){
$config['widgets'][$widget . '-config'] = $_POST[$widget . '-config'];
}
}
write_config(gettext("Widget configuration has been changed."));
header("Location: index.php");
exit;
}
## Load Functions Files
require_once('includes/functions.inc.php');
## Check to see if we have a swap space,
## if true, display, if false, hide it ...
if(file_exists("/usr/sbin/swapinfo")) {
$swapinfo = `/usr/sbin/swapinfo`;
if(stristr($swapinfo,'%') == true) $showswap=true;
}
## User recently restored his config.
## If packages are installed lets resync
if(file_exists('/conf/needs_package_sync')) {
if($config['installedpackages'] <> '' && is_array($config['installedpackages']['package'])) {
if($g['platform'] == "pfSense" || $g['platform'] == "nanobsd") {
## If the user has logged into webGUI quickly while the system is booting then do not redirect them to
## the package reinstall page. That is about to be done by the boot script anyway.
## The code in fbegin.inc will put up a notice to the user.
if (!platform_booting()) {
header('Location: pkg_mgr_install.php?mode=reinstallall');
exit;
}
}
} else {
conf_mount_rw();
@unlink('/conf/needs_package_sync');
conf_mount_ro();
foreach($widgets as $widgetname => $widgetconfig){
if ($_POST[$widgetname . '-config']){
$config['widgets'][$widgetname . '-config'] = $_POST[$name . '-config'];
}
}
## If it is the first time webConfigurator has been
## accessed since initial install show this stuff.
if(file_exists('/conf/trigger_initial_wizard')) {
echo <<<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?=system_get_language_code();?>" xml:lang="<?=system_get_language_code();?>">
write_config(gettext("Widget configuration has been changed."));
header("Location: index.php");
exit;
}
## Load Functions Files
require_once('includes/functions.inc.php');
## Check to see if we have a swap space,
## if true, display, if false, hide it ...
if(file_exists("/usr/sbin/swapinfo")) {
$swapinfo = `/usr/sbin/swapinfo`;
if(stristr($swapinfo,'%') == true) $showswap=true;
}
## User recently restored his config.
## If packages are installed lets resync
if(file_exists('/conf/needs_package_sync')) {
if($config['installedpackages'] <> '' && is_array($config['installedpackages']['package'])) {
if($g['platform'] == "pfSense" || $g['platform'] == "nanobsd") {
## If the user has logged into webGUI quickly while the system is booting then do not redirect them to
## the package reinstall page. That is about to be done by the boot script anyway.
## The code in fbegin.inc will put up a notice to the user.
if (!platform_booting()) {
header('Location: pkg_mgr_install.php?mode=reinstallall');
exit;
}
}
} else {
conf_mount_rw();
@unlink('/conf/needs_package_sync');
conf_mount_ro();
}
}
## If it is the first time webConfigurator has been
## accessed since initial install show this stuff.
if(file_exists('/conf/trigger_initial_wizard')) {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="/bootstrap/css/pfSense.css" />
<title>{$g['product_name']}.localdomain - {$g['product_name']} first time setup</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?=system_get_language_codeset();?>" />
<link rel="stylesheet" type="text/css" href="/niftycssprintCode.css" media="print" />
<script type="text/javascript">var theme = "{$g['theme']}"</script>
<script type="text/javascript" src="/themes/{$g['theme']}/loader.js"></script>
<meta http-equiv="refresh" content="1;url=wizard.php?xml=setup_wizard.xml" />
</head>
<body id="loading-wizard" class="no-menu">
<div id="jumbotron">
<div class="container">
<p><?=sprintf(gettext("Welcome to %s!\n"),$g['product_name'])?></p>
<p><?=gettext("One moment while we start the initial setup wizard.")?></p>
<p><?=gettext("Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.")?></p>
<p><?=sprintf(gettext("To bypass the wizard, click on the %s logo on the initial page."),$g['product_name'])?></p>
</div>
</div>
</body>
</html>
<?php
exit;
}
EOF;
echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css"))
echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
else
echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
echo "<form>\n";
echo "<center>\n";
echo "<img src=\"/themes/{$g['theme']}/images/logo.gif\" border=\"0\" alt=\"logo\" /><p>\n";
echo "<div \" style=\"width:700px;background-color:#ffffff\" id=\"nifty\">\n";
echo sprintf(gettext("Welcome to %s!\n"),$g['product_name']) . "<p>";
echo gettext("One moment while we start the initial setup wizard.") . "<p>\n";
echo gettext("Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.") . "<p>\n";
echo sprintf(gettext("To bypass the wizard, click on the %s logo on the initial page."),$g['product_name']) . "\n";
echo "</div>\n";
echo "<meta http-equiv=\"refresh\" content=\"1;url=wizard.php?xml=setup_wizard.xml\">\n";
echo "<script type=\"text/javascript\">\n";
echo "//<![CDATA[\n";
echo "NiftyCheck();\n";
echo "Rounded(\"div#nifty\",\"all\",\"#AAA\",\"#FFFFFF\",\"smooth\");\n";
echo "//]]>\n";
echo "</script>\n";
exit;
}
## Find out whether there's hardware encryption or not
unset($hwcrypto);
$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
if ($fd) {
while (!feof($fd)) {
$dmesgl = fgets($fd);
if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches)
or preg_match("/.*(VIA Padlock)/", $dmesgl, $matches)
or preg_match("/^safe.: (\w.*)/", $dmesgl, $matches)
or preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches)
or preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches)
or preg_match("/^glxsb.: (.*?),/", $dmesgl, $matches)
or preg_match("/^aesni.: (.*?),/", $dmesgl, $matches)) {
$hwcrypto = $matches[1];
break;
}
## Find out whether there's hardware encryption or not
unset($hwcrypto);
$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
if ($fd) {
while (!feof($fd)) {
$dmesgl = fgets($fd);
if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches)
or preg_match("/.*(VIA Padlock)/", $dmesgl, $matches)
or preg_match("/^safe.: (\w.*)/", $dmesgl, $matches)
or preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches)
or preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches)
or preg_match("/^glxsb.: (.*?),/", $dmesgl, $matches)
or preg_match("/^aesni.: (.*?),/", $dmesgl, $matches)) {
$hwcrypto = $matches[1];
break;
}
fclose($fd);
}
fclose($fd);
}
##build widget saved list information
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
$pconfig['sequence'] = $config['widgets']['sequence'];
$widgetsfromconfig = array();
$widgetlist = $pconfig['sequence'];
$colpos = array();
$savedwidgetfiles = array();
$widgetname = "";
$widgetlist = explode(",",$widgetlist);
foreach (explode(',', $pconfig['sequence']) as $line)
{
list($file, $col, $display) = explode(':', $line);
##read the widget position and display information
foreach ($widgetlist as $widget){
$dashpos = strpos($widget, "-");
$widgetname = substr($widget, 0, $dashpos);
$colposition = strpos($widget, ":");
$displayposition = strrpos($widget, ":");
$colpos[] = substr($widget,$colposition+1, $displayposition - $colposition-1);
$displayarray[] = substr($widget,$displayposition+1);
$savedwidgetfiles[] = $widgetname . ".widget.php";
// be backwards compatible
$offset = strpos($file, '-container');
if (false !== $offset)
$file = substr($file, 0, $offset);
$widgetsfromconfig[ $file ] = array(
'name' => ucwords(str_replace('_', ' ', $file)),
'col' => $col,
'display' => $display,
);
}
##add widgets that may not be in the saved configuration, in case they are to be displayed later
foreach ($widgetfiles as $defaultwidgets){
if (!in_array($defaultwidgets, $savedwidgetfiles)){
$savedwidgetfiles[] = $defaultwidgets;
}
}
$widgets = array_merge($widgets, $widgetsfromconfig);
##find custom configurations of a particular widget and load its info to $pconfig
foreach ($widgetnames as $widget){
if ($config['widgets'][$widget . '-config']){
$pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config'];
foreach($widgets as $widgetname => $widgetconfig){
if ($config['widgets'][$name . '-config']){
$pconfig[$name . '-config'] = $config['widgets'][$name . '-config'];
}
}
$widgetlist = $savedwidgetfiles;
} else{
// no saved widget sequence found, build default list.
$widgetlist = $widgetfiles;
}
##build list of php include files
@ -278,215 +238,15 @@ foreach($phpincludefiles as $includename) {
include($directory . $includename);
}
##begin AJAX
$jscriptstr = <<<EOD
<script type="text/javascript">
//<![CDATA[
function widgetAjax(widget) {
uri = "widgets/widgets/" + widget + ".widget.php";
var opt = {
// Use GET
type: 'get',
async: true,
// Handle 404
statusCode: {
404: function(t) {
alert('Error 404: location "' + t.statusText + '" was not found.');
}
},
// Handle other errors
error: function(t) {
alert('Error ' + t.status + ' -- ' + t.statusText);
},
success: function(data) {
widget2 = '#' + widget + "-loader";
jQuery(widget2).fadeOut(1000,function(){
jQuery('#' + widget).show();
});
jQuery('#' + widget).html(data);
}
}
jQuery.ajax(uri, opt);
}
function addWidget(selectedDiv){
selectedDiv2 = '#' + selectedDiv + "-container";
if (jQuery(selectedDiv2).css('display') != "none")
{
jQuery(selectedDiv2).effect('shake',{times: 2}, 100);
}
else
{
jQuery(selectedDiv2).show('blind');
widgetAjax(selectedDiv);
selectIntLink = selectedDiv2 + "-input";
jQuery(selectIntLink).val("show");
showSave();
}
}
function configureWidget(selectedDiv){
selectIntLink = '#' + selectedDiv + "-settings";
if (jQuery(selectIntLink).css('display') == "none")
jQuery(selectIntLink).show();
else
jQuery(selectIntLink).hide();
}
function showWidget(selectedDiv,swapButtons){
//appear element
jQuery('#' + selectedDiv).show('blind');
showSave();
d = document;
if (swapButtons){
selectIntLink = selectedDiv + "-min";
textlink = d.getElementById(selectIntLink);
textlink.style.display = "inline";
selectIntLink = selectedDiv + "-open";
textlink = d.getElementById(selectIntLink);
textlink.style.display = "none";
}
selectIntLink = selectedDiv + "-container-input";
textlink = d.getElementById(selectIntLink);
textlink.value = "show";
}
function minimizeWidget(selectedDiv,swapButtons){
//fade element
jQuery('#' + selectedDiv).hide('blind');
showSave();
d = document;
if (swapButtons){
selectIntLink = selectedDiv + "-open";
textlink = d.getElementById(selectIntLink);
textlink.style.display = "inline";
selectIntLink = selectedDiv + "-min";
textlink = d.getElementById(selectIntLink);
textlink.style.display = "none";
}
selectIntLink = selectedDiv + "-container-input";
textlink = d.getElementById(selectIntLink);
textlink.value = "hide";
}
function closeWidget(selectedDiv){
showSave();
selectedDiv2 = "#" + selectedDiv + "-container";
jQuery(selectedDiv2).hide('blind');
selectIntLink = "#" + selectedDiv + "-container-input";
jQuery(selectIntLink).val("close");
}
function showSave(){
d = document;
selectIntLink = "submit";
textlink = d.getElementById(selectIntLink);
textlink.style.display = "inline";
}
function updatePref(){
var widgets = document.getElementsByClassName('widgetdiv');
var widgetSequence = "";
var firstprint = false;
d = document;
for (i=0; i<widgets.length; i++){
if (firstprint)
widgetSequence += ",";
var widget = widgets[i].id;
widgetSequence += widget + ":" + widgets[i].parentNode.id + ":";
widget = widget + "-input";
textlink = d.getElementById(widget).value;
widgetSequence += textlink;
firstprint = true;
}
selectLink = "sequence";
textlink = d.getElementById(selectLink);
textlink.value = widgetSequence;
return true;
}
function hideAllWidgets(){
jQuery('#niftyOutter').fadeTo('slow',0.2);
}
function showAllWidgets(){
jQuery('#niftyOutter').fadeTo('slow',1.0);
}
function changeTabDIV(selectedDiv){
var dashpos = selectedDiv.indexOf("-");
var tabclass = selectedDiv.substring(0,dashpos);
d = document;
//get deactive tabs first
tabclass = tabclass + "-class-tabdeactive";
var tabs = document.getElementsByClassName(tabclass);
var incTabSelected = selectedDiv + "-deactive";
for (i=0; i<tabs.length; i++){
var tab = tabs[i].id;
dashpos = tab.lastIndexOf("-");
var tab2 = tab.substring(0,dashpos) + "-deactive";
if (tab2 == incTabSelected){
tablink = d.getElementById(tab2);
tablink.style.display = "none";
tab2 = tab.substring(0,dashpos) + "-active";
tablink = d.getElementById(tab2);
tablink.style.display = "table-cell";
//now show main div associated with link clicked
tabmain = d.getElementById(selectedDiv);
tabmain.style.display = "block";
}
else
{
tab2 = tab.substring(0,dashpos) + "-deactive";
tablink = d.getElementById(tab2);
tablink.style.display = "table-cell";
tab2 = tab.substring(0,dashpos) + "-active";
tablink = d.getElementById(tab2);
tablink.style.display = "none";
//hide sections we don't want to see
tab2 = tab.substring(0,dashpos);
tabmain = d.getElementById(tab2);
tabmain.style.display = "none";
}
}
}
//]]>
</script>
EOD;
## Set Page Title and Include Header
$pgtitle = array(gettext("Status: Dashboard"));
include("head.inc");
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<script type="text/javascript">
//<![CDATA[
columns = ['col1','col2','col3','col4', 'col5','col6','col7','col8','col9','col10'];
//]]>
</script>
<body class="index">
<?php
include("fbegin.inc");
echo $jscriptstr;
if(!file_exists("/usr/local/www/themes/{$g['theme']}/no_big_logo"))
echo "<center><img src=\"./themes/".$g['theme']."/images/logobig.jpg\" alt=\"big logo\" /></center><br />";
/* Print package server mismatch warning. See https://redmine.pfsense.org/issues/484 */
if (!verify_all_package_servers())
@ -498,292 +258,59 @@ if ($savemsg)
pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
?>
<div id="widgetcontainer" style="display:none">
<div id="content1"><h1><?=gettext("Available Widgets"); ?></h1><p><?php
$widgetfiles_add = $widgetfiles;
sort($widgetfiles_add);
foreach($widgetfiles_add as $widget) {
if(!stristr($widget, "widget.php"))
continue;
$periodpos = strpos($widget, ".");
$widgetname = substr($widget, 0, $periodpos);
$nicename = $widgetname;
$nicename = str_replace("_", " ", $nicename);
//make the title look nice
$nicename = ucwords($nicename);
<div class="panel panel-default">
<div class="panel-heading"><h3><?=gettext("Available Widgets"); ?></h3></div>
<div class="panel-body">
<?php
foreach($widgets as $widgetname => $widgetconfig):
?>
<div class="col-sm-3"><a href="#"><i class="icon icon-plus"></i> <?=$widgetconfig['name']?></a></div>
<?php endforeach; ?>
</div>
</div>
$widgettitle = $widgetname . "_title";
$widgettitlelink = $widgetname . "_title_link";
if ($$widgettitle != "")
{
//echo widget title
?>
<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
<u><?php echo $$widgettitle; ?></u></span><br />
<?php
}
else {?>
<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
<u><?php echo $nicename; ?></u></span><br /><?php
}
}
?>
<div class="panel panel-default">
<div class="panel-heading"><h3><?=gettext("Welcome to the Dashboard page"); ?>!</h3></div>
<div class="panel-body">
<p>
<?=gettext("This page allows you to customize the information you want to be displayed!");?>
<?=gettext("To get started click the");?> FIXME <?=gettext("icon to add widgets.");?><br />
<br />
<?=gettext("You can move any widget around by clicking and dragging the title.");?>
</p>
</div>
</div>
<div id="welcomecontainer" style="display:none">
<div id="welcome-container">
<div style="float:left;width:100%;padding: 2px">
<h1><?=gettext("Welcome to the Dashboard page"); ?>!</h1>
</div>
<div onclick="domTT_close(this);showAllWidgets();" style="width:87%; position: absolute; cursor:pointer; padding: 10px;" >
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" alt="close" style="float:right" />
</div>
<div style="clear:both;"></div>
<p>
<?=gettext("This page allows you to customize the information you want to be displayed!");?><br />
<?=gettext("To get started click the");?> <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="plus" /> <?=gettext("icon to add widgets.");?><br />
<br />
<?=gettext("You can move any widget around by clicking and dragging the title.");?>
</p>
</div>
</div>
<form action="index.php" method="post">
<input type="hidden" value="" name="sequence" id="sequence" />
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="<?=gettext("Click here to add widgets"); ?>" style="cursor: pointer;" onmouseup="domTT_activate(this, event, 'content', document.getElementById('content1'), 'type', 'velcro', 'delay', 0, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');" />
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_info_pkg.gif" alt="<?=gettext("Click here for help"); ?>" style="cursor: help;" onmouseup="hideAllWidgets();domTT_activate(this, event, 'content', document.getElementById('welcome-container'), 'type', 'sticky', 'closeLink', '','delay', 0, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');" />
&nbsp;&nbsp;&nbsp;
<input id="submit" name="submit" type="submit" style="display:none" onclick="return updatePref();" class="formbtn" value="<?=gettext("Save Settings");?>" />
</form>
<!-- fakeClass contains no CSS but is used as an identifier in theme pfsense_ng_fs - loader.js -->
<div id="niftyOutter" class="fakeClass">
<?php
$totalwidgets = count($widgetfiles);
$halftotal = $totalwidgets / 2 - 2;
$widgetcounter = 0;
$directory = "/usr/local/www/widgets/widgets/";
$printed = false;
$firstprint = false;
?>
<div id="col1" style="float:left;width:49%;padding-bottom:40px" class="ui-sortable">
<?php
foreach($widgetlist as $widget) {
if(!stristr($widget, "widget.php"))
continue;
$periodpos = strpos($widget, ".");
$widgetname = substr($widget, 0, $periodpos);
if ($widgetname != ""){
$nicename = $widgetname;
$nicename = str_replace("_", " ", $nicename);
//make the title look nice
$nicename = ucwords($nicename);
}
if ($config['widgets'] && $pconfig['sequence'] != ""){
switch($displayarray[$widgetcounter]){
case "show":
$divdisplay = "block";
$display = "block";
$inputdisplay = "show";
$showWidget = "none";
$mindiv = "inline";
break;
case "hide":
$divdisplay = "block";
$display = "none";
$inputdisplay = "hide";
$showWidget = "inline";
$mindiv = "none";
break;
case "close":
$divdisplay = "none";
$display = "block";
$inputdisplay = "close";
$showWidget = "none";
$mindiv = "inline";
break;
default:
$divdisplay = "none";
$display = "block";
$inputdisplay = "none";
$showWidget = "none";
$mindiv = "inline";
break;
}
} else {
if ($firstprint == false){
$divdisplay = "block";
$display = "block";
$inputdisplay = "show";
$showWidget = "none";
$mindiv = "inline";
$firstprint = true;
} else {
switch ($widget) {
case "interfaces.widget.php":
case "traffic_graphs.widget.php":
$divdisplay = "block";
$display = "block";
$inputdisplay = "show";
$showWidget = "none";
$mindiv = "inline";
break;
default:
$divdisplay = "none";
$display = "block";
$inputdisplay = "close";
$showWidget = "none";
$mindiv = "inline";
break;
}
}
}
if( substr($g['theme'], -3) != "_fs") {
if ($config['widgets'] && $pconfig['sequence'] != ""){
if ($colpos[$widgetcounter] == "col2" && $printed == false)
{
$printed = true;
?>
</div>
<div id="col2" style="float:right;width:49%;padding-bottom:40px" class="ui-sortable">
<?php
}
}
else if ($widgetcounter >= $halftotal && $printed == false){
$printed = true;
?>
</div>
<div id="col2" style="float:right;width:49%;padding-bottom:40px" class="ui-sortable">
<?php
}
}
else {
if ($config['widgets'] && $pconfig['sequence'] != "") {
if ($colpos[$widgetcounter] == "col2" && $printed == false)
{
$printed = true;
?>
</div>
<div id="col2" style="float:right;width:49%;padding-bottom:40px" class="ui-sortable">
<?php
}
else { ?>
<script type="text/javascript">
//<![CDATA[
var colpos = "<?=$colpos[$widgetcounter]?>";
createColumn(colpos);
//]]>
</script>
<?php }
}
}
?>
<div style="clear:both;"></div>
<div id="<?php echo $widgetname;?>-container" class="widgetdiv" style="display:<?php echo $divdisplay; ?>;">
<input type="hidden" value="<?php echo $inputdisplay;?>" id="<?php echo $widgetname;?>-container-input" name="<?php echo $widgetname;?>-container-input" />
<div id="<?php echo $widgetname;?>-topic" class="widgetheader" style="cursor:move">
<div style="float:left;">
<?php
$widgettitle = $widgetname . "_title";
$widgettitlelink = $widgetname . "_title_link";
if ($$widgettitle != "")
{
//only show link if defined
if ($$widgettitlelink != "") {?>
<u><span onclick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
<?php }
//echo widget title
echo $$widgettitle;
if ($$widgettitlelink != "") { ?>
</span></u>
<?php }
}
else{
if ($$widgettitlelink != "") {?>
<u><span onclick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
<?php }
echo $nicename;
if ($$widgettitlelink != "") { ?>
</span></u>
<?php }
}
?>
</div>
<div align="right" style="float:right;">
<div id="<?php echo $widgetname;?>-configure" onclick='return configureWidget("<?php echo $widgetname;?>")' style="display:none; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_configure.gif" alt="configure" /></div>
<div id="<?php echo $widgetname;?>-open" onclick='return showWidget("<?php echo $widgetname;?>",true)' style="display:<?php echo $showWidget;?>; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_open.gif" alt="open" /></div>
<div id="<?php echo $widgetname;?>-min" onclick='return minimizeWidget("<?php echo $widgetname;?>",true)' style="display:<?php echo $mindiv;?>; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_minus.gif" alt="minimize" /></div>
<div id="<?php echo $widgetname;?>-close" onclick='return closeWidget("<?php echo $widgetname;?>",true)' style="display:inline; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" alt="close" /></div>
</div>
<div style="clear:both;"></div>
</div>
<?php if ($divdisplay != "block") { ?>
<div id="<?php echo $widgetname;?>-loader" style="display:<?php echo $display; ?>;" align="center">
<br />
<img src="./themes/<?= $g['theme']; ?>/images/misc/widget_loader.gif" width="25" height="25" alt="<?=gettext("Loading selected widget"); ?>..." />
<br />
</div> <?php $display = "none"; } ?>
<div id="<?php echo $widgetname;?>" style="display:<?php echo $display; ?>;">
<?php
if ($divdisplay == "block")
{
include($directory . $widget);
}
?>
</div>
<div style="clear:both;"></div>
</div>
<?php
$widgetcounter++;
}//end foreach
?>
</div>
<div style="clear:both;"></div>
</div>
<?php include("fend.inc"); ?>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function(in_event)
{
jQuery('.ui-sortable').sortable({connectWith: '.ui-sortable', dropOnEmpty: true, handle: '.widgetheader', change: showSave});
<?php if (!$config['widgets'] && $pconfig['sequence'] != ""){ ?>
hideAllWidgets();
domTT_activate('welcome1', null, 'x', 287, 'y', 107, 'content', document.getElementById('welcome-container'), 'type', 'sticky', 'closeLink', '','delay', 1000, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');
<?php } ?>
});
//]]>
</script>
<?php
//build list of javascript include files
$jsincludefiles = array();
$directory = "widgets/javascript/";
$dirhandle = opendir($directory);
$filename = "";
while (false !== ($filename = readdir($dirhandle))) {
$jsincludefiles[] = $filename;
}
foreach($jsincludefiles as $jsincludename) {
if(!preg_match('/\.js$/', $jsincludename))
continue;
echo "<script src='{$directory}{$jsincludename}' type='text/javascript'></script>\n";
}
foreach ($widgets as $widgetname => $widgetconfig){
//FIXME: do something with stored config
?>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<?=$widgetconfig['name']?>
<span style="float: right">
<a href="#"><i class="icon icon-wrench"></i></a>
<a href="#"><i class="icon icon-plus-sign"></i></a>
<a href="#"><i class="icon icon-minus-sign"></i></a>
<a href="#"><i class="icon icon-remove-sign"></i></a>
</span>
</div>
<div class="panel-body">
<?php include('/usr/local/www/widgets/widgets/'. $widgetname.'.widget.php'); ?>
</div>
</div>
</div>
<?php
}
include("fend.inc");
//build list of javascript include files
foreach (glob('widgets/javascript/*.js') as $file)
echo '<script src="'.$file.'"></script>';
?>
</body>
</html>
</html>

View File

@ -1,114 +0,0 @@
/*
NetUtils.js
part of pfSense (https://www.pfsense.org)
Various helper functions for IPv6 support.
Copyright (C) 2007 Simon Cornelius P. Umacob <simoncpu@gmail.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
function NetUtils_changeIPVersionMask(field, version) {
switch(version){
case 'IPv4':
NetUtils_clearOptions(document.getElementById(field));
NetUtils_loadMaskIPv4(document.getElementById(field), 32);
break;
case 'IPv6':
NetUtils_clearOptions(document.getElementById(field));
NetUtils_loadMaskIPv6(document.getElementById(field), 64);
break;
case 'IPv4_net':
NetUtils_clearOptions(document.getElementById(field));
NetUtils_loadMaskIPv4(document.getElementById(field), 32, 1, 31);
break;
case 'IPv6_net':
NetUtils_clearOptions(document.getElementById(field));
NetUtils_loadMaskIPv6(document.getElementById(field), 64, 1, 63);
break;
}
}
function NetUtils_clearOptions(obj) {
var len = obj.length;
for (var i = 0; i < len; i++) {
obj[0] = null;
}
}
function NetUtils_loadMaskIPv4(obj, sel, min, max) {
var min,
max,
j = 0;
min = min == undefined ? 1 : min;
max = max == undefined ? 32 : max;
for (var i = max; i >= min; i--) {
obj[j] = new Option(i, i);
if (sel == i) {
obj[j].selected = true;
}
j++;
}
}
function NetUtils_loadMaskIPv6(obj, sel, min, max) {
var min,
max,
j = 0;
min = min == undefined ? 1 : min;
max = max == undefined ? 64 : max;
if ((max % 4) != 0) {
obj[j++] = new Option(max, max);
/**
* NOTE: This solution is a kludge.
* If you have a better way, don't hesitate
* to change this. Please send patches. :)
*/
for (var i = 1; i <= 3; i++) {
if (((max - i) % 4) == 0) {
max = max - i;
break;
}
}
}
for (var i = max; i >= min; i -= 4) {
obj[j] = new Option(i, i);
if (sel == i) {
obj[j].selected = true;
}
j++;
}
}

View File

@ -1,336 +0,0 @@
/**
* An autosuggest textbox control.
* @class
* @scope public
*/
function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
oProvider /*:SuggestionProvider*/) {
/**
* The currently selected suggestions.
* @scope private
*/
this.cur /*:int*/ = -1;
/**
* The dropdown list layer.
* @scope private
*/
this.layer = null;
/**
* Suggestion provider for the autosuggest feature.
* @scope private.
*/
this.provider /*:SuggestionProvider*/ = oProvider;
/**
* The textbox to capture.
* @scope private
*/
this.textbox /*:HTMLInputElement*/ = oTextbox;
//initialize the control
this.init();
}
/**
* Autosuggests one or more suggestions for what the user has typed.
* If no suggestions are passed in, then no autosuggest occurs.
* @scope private
* @param aSuggestions An array of suggestion strings.
* @param bTypeAhead If the control should provide a type ahead suggestion.
*/
AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/,
bTypeAhead /*:boolean*/) {
//make sure there's at least one suggestion
if (aSuggestions.length > 0) {
if (bTypeAhead) {
this.typeAhead(aSuggestions[0]);
}
this.showSuggestions(aSuggestions);
} else {
this.hideSuggestions();
}
};
/**
* Creates the dropdown layer to display multiple suggestions.
* @scope private
*/
AutoSuggestControl.prototype.createDropDown = function () {
var oThis = this;
//create the layer and assign styles
this.layer = document.createElement("div");
this.layer.className = "suggestions";
this.layer.style.visibility = "hidden";
this.layer.style.width = this.textbox.offsetWidth;
//when the user clicks on the a suggestion, get the text (innerHTML)
//and place it into a textbox
this.layer.onmousedown =
this.layer.onmouseup =
this.layer.onmouseover = function (oEvent) {
oEvent = oEvent || window.event;
oTarget = oEvent.target || oEvent.srcElement;
if (oEvent.type == "mousedown") {
oThis.textbox.value = oTarget.firstChild.nodeValue;
oThis.hideSuggestions();
} else if (oEvent.type == "mouseover") {
oThis.highlightSuggestion(oTarget);
} else {
oThis.textbox.focus();
}
};
document.body.appendChild(this.layer);
};
/**
* Gets the left coordinate of the textbox.
* @scope private
* @return The left coordinate of the textbox in pixels.
*/
AutoSuggestControl.prototype.getLeft = function () /*:int*/ {
var oNode = this.textbox;
var iLeft = 0;
while(oNode.tagName != "BODY") {
iLeft += oNode.offsetLeft;
oNode = oNode.offsetParent;
}
return iLeft;
};
/**
* Gets the top coordinate of the textbox.
* @scope private
* @return The top coordinate of the textbox in pixels.
*/
AutoSuggestControl.prototype.getTop = function () /*:int*/ {
var oNode = this.textbox;
var iTop = 0;
while(oNode.tagName != "BODY") {
iTop += oNode.offsetTop;
oNode = oNode.offsetParent;
}
return iTop;
};
/**
* Handles three keydown events.
* @scope private
* @param oEvent The event object for the keydown event.
*/
AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) {
switch(oEvent.keyCode) {
case 38: //up arrow
this.previousSuggestion();
break;
case 40: //down arrow
this.nextSuggestion();
break;
case 13: //enter
this.hideSuggestions();
break;
}
};
/**
* Handles keyup events.
* @scope private
* @param oEvent The event object for the keyup event.
*/
AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) {
var iKeyCode = oEvent.keyCode;
//for backspace (8) and delete (46), shows suggestions without typeahead
if (iKeyCode == 8 || iKeyCode == 46) {
this.provider.requestSuggestions(this, false);
//make sure not to interfere with non-character keys
} else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) {
//ignore
} else {
//request suggestions from the suggestion provider with typeahead
this.provider.requestSuggestions(this, true);
}
};
/**
* Hides the suggestion dropdown.
* @scope private
*/
AutoSuggestControl.prototype.hideSuggestions = function () {
this.layer.style.visibility = "hidden";
};
/**
* Highlights the given node in the suggestions dropdown.
* @scope private
* @param oSuggestionNode The node representing a suggestion in the dropdown.
*/
AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) {
for (var i=0; i < this.layer.childNodes.length; i++) {
var oNode = this.layer.childNodes[i];
if (oNode == oSuggestionNode) {
oNode.className = "current";
} else if (oNode.className == "current") {
oNode.className = "";
}
}
};
/**
* Initializes the textbox with event handlers for
* auto suggest functionality.
* @scope private
*/
AutoSuggestControl.prototype.init = function () {
//save a reference to this object
var oThis = this;
//assign the onkeyup event handler
this.textbox.onkeyup = function (oEvent) {
//check for the proper location of the event object
if (!oEvent) {
oEvent = window.event;
}
//call the handleKeyUp() method with the event object
oThis.handleKeyUp(oEvent);
};
//assign onkeydown event handler
this.textbox.onkeydown = function (oEvent) {
//check for the proper location of the event object
if (!oEvent) {
oEvent = window.event;
}
//call the handleKeyDown() method with the event object
oThis.handleKeyDown(oEvent);
};
//assign onblur event handler (hides suggestions)
this.textbox.onblur = function () {
oThis.hideSuggestions();
};
//create the suggestions dropdown
this.createDropDown();
};
/**
* Highlights the next suggestion in the dropdown and
* places the suggestion into the textbox.
* @scope private
*/
AutoSuggestControl.prototype.nextSuggestion = function () {
var cSuggestionNodes = this.layer.childNodes;
if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) {
var oNode = cSuggestionNodes[++this.cur];
this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue;
}
};
/**
* Highlights the previous suggestion in the dropdown and
* places the suggestion into the textbox.
* @scope private
*/
AutoSuggestControl.prototype.previousSuggestion = function () {
var cSuggestionNodes = this.layer.childNodes;
if (cSuggestionNodes.length > 0 && this.cur > 0) {
var oNode = cSuggestionNodes[--this.cur];
this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue;
}
};
/**
* Selects a range of text in the textbox.
* @scope public
* @param iStart The start index (base 0) of the selection.
* @param iLength The number of characters to select.
*/
AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*:int*/) {
//use text ranges for Internet Explorer
if (this.textbox.createTextRange) {
var oRange = this.textbox.createTextRange();
oRange.moveStart("character", iStart);
oRange.moveEnd("character", iLength - this.textbox.value.length);
oRange.select();
//use setSelectionRange() for Mozilla
} else if (this.textbox.setSelectionRange) {
this.textbox.setSelectionRange(iStart, iLength);
}
//set focus back to the textbox
this.textbox.focus();
};
/**
* Builds the suggestion layer contents, moves it into position,
* and displays the layer.
* @scope private
* @param aSuggestions An array of suggestions for the control.
*/
AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) {
var oDiv = null;
this.layer.innerHTML = ""; //clear contents of the layer
for (var i=0; i < aSuggestions.length; i++) {
oDiv = document.createElement("div");
oDiv.appendChild(document.createTextNode(aSuggestions[i]));
this.layer.appendChild(oDiv);
}
this.layer.style.left = this.getLeft() + "px";
this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px";
this.layer.style.visibility = "visible";
};
/**
* Inserts a suggestion into the textbox, highlighting the
* suggested part of the text.
* @scope private
* @param sSuggestion The suggestion for the textbox.
*/
AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) {
//check for support of typeahead functionality
if (this.textbox.createTextRange || this.textbox.setSelectionRange){
var iLen = this.textbox.value.length;
this.textbox.value = sSuggestion;
this.selectRange(iLen, sSuggestion.length);
}
};

View File

@ -1,142 +0,0 @@
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
* http://www.webtoolkit.info/licence
**/
var Base64 = {
// private property
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
// public method for encoding
encode : function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
input = Base64._utf8_encode(input);
while (i < input.length) {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
}
return output;
},
// public method for decoding
decode : function (input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
}
output = Base64._utf8_decode(output);
return output;
},
// private method for UTF-8 encoding
_utf8_encode : function (string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
},
// private method for UTF-8 decoding
_utf8_decode : function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while ( i < utftext.length ) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
};

View File

@ -1,5 +0,0 @@
window.onLoad = function () {
NiftyCheck();
Rounded("div#mainlevel","all","#FFF","#eeeeee","smooth");
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -1,317 +0,0 @@
div.chzn-container {
font-size: 13px;
position: relative;
}
div.chzn-container input {
background: #fff;
background: -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
background: -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
background: -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
border: 1px solid #aaa;
font-family: sans-serif;
font-size: 1em;
margin: 0px;
padding: 4px 5px;
outline: none;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
-ms-border-radius: 3px;
-khtml-border-radius: 3px;
border-radius: 3px;
}
div.chzn-container textarea:focus {
border-color: #058cf5;
-moz-box-shadow: 0px 0px 3px #aaa;
-webkit-box-shadow: 0px 0px 3px #aaa;
box-shadow: 0px 0px 3px #aaa;
}
div.chzn-container div.chzn-drop {
background: #FFF;
border: 1px solid #aaa;
border-width: 0 1px 1px;
left: 0;
position: absolute;
top: 29px;
-webkit-box-shadow: 0px 4px 5px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0px 4px 5px rgba(0, 0, 0, 0.15);
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.15);
z-index: 20;
}
div.chzn-container-single div.chzn-drop {
-moz-border-radius: 0 0 4px 4px;
-webkit-border-radius: 0 0 4px 4px;
-o-border-radius: 0 0 4px 4px;
-ms-border-radius: 0 0 4px 4px;
-khtml-border-radius: 0 0 4px 4px;
border-radius: 0 0 4px 4px;
}
/* SINGLE */
div.chzn-container a.chzn-single {
background: #FFF;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eeeeee), color-stop(0.5, white));
background-image: -moz-linear-gradient(center bottom, #eeeeee 0%, white 50%);
background-image: -o-linear-gradient(bottom, #eeeeee 0%, white 50%);
border: 1px solid #aaa;
display: block;
overflow: hidden;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
-o-border-radius: 4px;
-ms-border-radius: 4px;
-khtml-border-radius: 4px;
border-radius: 4px;
height: 25px;
color: #444;
line-height: 26px;
padding: 0px 0px 0px 8px;
position: relative;
text-decoration: none;
z-index: 19;
white-space: nowrap;
}
div.chzn-container a.chzn-single span {
display: block;
margin-right: 26px;
overflow: hidden;
text-overflow: ellipsis;
}
div.chzn-container a.chzn-single div {
-moz-border-radius-topright: 4px;
-webkit-border-top-right-radius: 4px;
-o-border-top-right-radius: 4px;
-ms-border-top-right-radius: 4px;
-khtml-border-top-right-radius: 4px;
border-top-right-radius: 4px;
-moz-border-radius-bottomright: 4px;
-webkit-border-bottom-right-radius: 4px;
-o-border-bottom-right-radius: 4px;
-ms-border-bottom-right-radius: 4px;
-khtml-border-bottom-right-radius: 4px;
border-bottom-right-radius: 4px;
background: #ccc;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee));
background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
background-image: -o-linear-gradient(bottom, #ccc 0%, #eee 60%);
border-left: 1px solid #aaa;
display: block;
height: 100%;
position: absolute;
right: 0;
top: 0;
width: 18px;
}
div.chzn-container a.chzn-single div b {
background: url('chosen-sprite.png') no-repeat 0 1px;
display: block;
width: 100%;
height: 100%;
}
div.chzn-container div.chzn-search {
padding: 3px 4px;
margin: 0px;
white-space: nowrap;
}
div.chzn-container div.chzn-search input {
background: url('chosen-sprite.png') no-repeat 97% -35px, #ffffff;
background: url('chosen-sprite.png') no-repeat 97% -35px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
background: url('chosen-sprite.png') no-repeat 97% -35px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
background: url('chosen-sprite.png') no-repeat 97% -35px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
-moz-border-radius: 0px;
-webkit-border-radius: 0px;
-o-border-radius: 0px;
-ms-border-radius: 0px;
-khtml-border-radius: 0px;
border-radius: 0px;
margin: 1px 0;
outline: 0;
}
/* Multi */
div.chzn-container ul.chzn-choices {
background: #fff;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
background-image: -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
background-image: -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
margin: 0;
cursor: text;
border: 1px solid #aaa;
overflow: hidden;
height: auto !important;
height: 1%;
padding: 0;
position: relative;
}
div.chzn-container ul.chzn-choices:focus {
border-color: #058cf5;
-moz-box-shadow: 0px 0px 5px #999;
-webkit-box-shadow: 0px 0px 5px #999;
box-shadow: 0px 0px 5px #999;
}
div.chzn-container ul.chzn-choices li {
float: left;
list-style-type: none;
margin: 0px;
}
div.chzn-container ul.chzn-choices li.search-field {
margin: 0px;
white-space: nowrap;
padding: 0px;
}
div.chzn-container ul.chzn-choices li.search-field input {
color: #666;
background: transparent !important;
border: 0px !important;
padding: 5px;
margin: 1px 0;
outline: 0;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
div.chzn-container ul.chzn-choices li.search-field input.default {
color: #999;
}
div.chzn-container ul.chzn-choices li.search-choice {
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
background: #e4e4e4;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #e4e4e4), color-stop(0.7, #eeeeee));
background-image: -moz-linear-gradient(center bottom, #e4e4e4 0%, #eeeeee 70%);
background-image: -o-linear-gradient(bottom, #e4e4e4 0%, #eeeeee 70%);
color: #333;
border: 1px solid #b4b4b4;
line-height: 13px;
padding: 3px 19px 3px 6px;
position: relative;
margin: 3px 0px 3px 5px;
}
div.chzn-container ul.chzn-choices li.search-choice span {
cursor: default;
}
div.chzn-container ul.chzn-choices li.search-choice.search-choice-focus {
background: #d4d4d4;
}
div.chzn-container ul.chzn-choices li.search-choice a.search-choice-close {
position: absolute;
right: 5px;
top: 6px;
display: block;
width: 8px;
height: 9px;
font-size: 1px;
background: url(chosen-sprite.png) right top no-repeat;
}
div.chzn-container ul.chzn-choices li.search-choice a.search-choice-close:hover {
background-position: right -9px;
}
div.chzn-container ul.chzn-choices li.search-choice.search-choice-focus a.search-choice-close {
background-position: right -9px;
}
/* Results */
div.chzn-container ul.chzn-results {
margin: 0 4px 4px 0;
max-height: 190px;
padding: 0 0 0 4px;
position: relative;
overflow-x: hidden;
overflow-y: auto;
z-index: 20;
}
div.chzn-container-multi ul.chzn-results {
margin: -1px 0 0;
padding: 0;
}
div.chzn-container-multi ul.chzn-results li {
border-left: 0px !important;
border-right: 0px !important;
}
div.chzn-container ul.chzn-results li {
line-height: 80%;
padding: 7px 7px 8px;
z-index: 22;
margin: 0;
list-style-type: none;
}
div.chzn-container ul.chzn-results li.active-result {
cursor: pointer;
}
div.chzn-container ul.chzn-results li em {
font-style: normal;
background: #FEFFDC;
}
div.chzn-container ul.chzn-results li.highlighted {
background: #3875d7;
color: #fff;
}
div.chzn-container ul.chzn-results li.highlighted em {
background: transparent;
}
div.chzn-container ul.chzn-results li.no-results {
background: #F4F4F4;
}
div.chzn-container ul.chzn-results li.group-result {
cursor: default;
color: #999;
font-weight: bold;
}
div.chzn-container ul.chzn-results li.group-option {
padding-left: 20px;
}
div.chzn-container-multi div.chzn-drop li.result-selected {
display: none;
}
/* Active */
div.chzn-container-active a.chzn-single {
-webkit-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
border: 1px solid #5897fb;
}
div.chzn-container-active a.chzn-single-with-drop {
border: 1px solid #aaa;
border-width: 1px 1px 1px;
-moz-box-shadow: 0px 1px 0px #FFF inset;
-webkit-box-shadow: 0px 1px 0px #FFF inset;
box-shadow: 0px 1px 0px #FFF inset;
background: #EEE;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, white), color-stop(0.5, #eeeeee));
background-image: -moz-linear-gradient(center bottom, white 0%, #eeeeee 50%);
background-image: -o-linear-gradient(bottom, white 0%, #eeeeee 50%);
-webkit-border-bottom-left-radius: 0px;
-webkit-border-bottom-right-radius: 0px;
-moz-border-radius-bottomleft: 0px;
-moz-border-radius-bottomright: 0px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
}
div.chzn-container-active a.chzn-single-with-drop div {
background: transparent;
border-left: none;
}
div.chzn-container-active a.chzn-single-with-drop div b {
background-position: -18px 1px;
}
div.chzn-container-active ul.chzn-choices {
z-index: 21;
-webkit-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
border: 1px solid #5897fb;
}
div.chzn-container-active ul.chzn-choices input {
color: #111 !important;
}

View File

@ -1,755 +0,0 @@
(function() {
/*
Chosen, a Select Box Enhancer for jQuery and Protoype
by Patrick Filler for Harvest, http://getharvest.com
Available for use under the MIT License, http://en.wikipedia.org/wiki/MIT_License
Copyright (c) 2011 by Harvest
*/ var $, Chosen, SelectParser, get_side_border_padding, root;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
root = typeof exports !== "undefined" && exports !== null ? exports : this;
$ = jQuery;
$.fn.extend({
chosen: function(data, options) {
return $(this).each(function(input_field) {
if (!($(this)).hasClass("chzn-done")) {
return new Chosen(this, data, options);
}
});
}
});
Chosen = (function() {
function Chosen(elmn) {
this.set_default_values();
this.form_field = elmn;
this.form_field_jq = $(this.form_field);
this.is_multiple = this.form_field.multiple;
this.default_text_default = this.form_field.multiple ? "Select Some Options" : "Select an Option";
this.set_up_html();
this.register_observers();
this.form_field_jq.addClass("chzn-done");
}
Chosen.prototype.set_default_values = function() {
this.click_test_action = __bind(function(evt) {
return this.test_active_click(evt);
}, this);
this.active_field = false;
this.mouse_on_container = false;
this.results_showing = false;
this.result_highlighted = null;
this.result_single_selected = null;
return this.choices = 0;
};
Chosen.prototype.set_up_html = function() {
var container_div, dd_top, dd_width, sf_width;
this.container_id = this.form_field.id + "_chzn";
this.f_width = this.form_field_jq.width();
this.default_text = this.form_field_jq.attr('title') ? this.form_field_jq.attr('title') : this.default_text_default;
container_div = $("<div />", {
id: this.container_id,
"class": 'chzn-container',
style: 'width: ' + this.f_width + 'px;'
});
if (this.is_multiple) {
container_div.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
} else {
container_div.html('<a href="javascript:void(0)" class="chzn-single"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" /></div><ul class="chzn-results"></ul></div>');
}
this.form_field_jq.hide().after(container_div);
this.container = $('#' + this.container_id);
this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
this.dropdown = this.container.find('div.chzn-drop').first();
dd_top = this.container.height();
dd_width = this.f_width - get_side_border_padding(this.dropdown);
this.dropdown.css({
"width": dd_width + "px",
"top": dd_top + "px"
});
this.search_field = this.container.find('input').first();
this.search_results = this.container.find('ul.chzn-results').first();
this.search_field_scale();
this.search_no_results = this.container.find('li.no-results').first();
if (this.is_multiple) {
this.search_choices = this.container.find('ul.chzn-choices').first();
this.search_container = this.container.find('li.search-field').first();
} else {
this.search_container = this.container.find('div.chzn-search').first();
this.selected_item = this.container.find('.chzn-single').first();
sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field);
this.search_field.css({
"width": sf_width + "px"
});
}
this.results_build();
return this.set_tab_index();
};
Chosen.prototype.register_observers = function() {
this.container.click(__bind(function(evt) {
return this.container_click(evt);
}, this));
this.container.mouseenter(__bind(function(evt) {
return this.mouse_enter(evt);
}, this));
this.container.mouseleave(__bind(function(evt) {
return this.mouse_leave(evt);
}, this));
this.search_results.click(__bind(function(evt) {
return this.search_results_click(evt);
}, this));
this.search_results.mouseover(__bind(function(evt) {
return this.search_results_mouseover(evt);
}, this));
this.search_results.mouseout(__bind(function(evt) {
return this.search_results_mouseout(evt);
}, this));
this.form_field_jq.bind("liszt:updated", __bind(function(evt) {
return this.results_update_field(evt);
}, this));
this.search_field.blur(__bind(function(evt) {
return this.input_blur(evt);
}, this));
this.search_field.keyup(__bind(function(evt) {
return this.keyup_checker(evt);
}, this));
this.search_field.keydown(__bind(function(evt) {
return this.keydown_checker(evt);
}, this));
if (this.is_multiple) {
this.search_choices.click(__bind(function(evt) {
return this.choices_click(evt);
}, this));
return this.search_field.focus(__bind(function(evt) {
return this.input_focus(evt);
}, this));
} else {
return this.selected_item.focus(__bind(function(evt) {
return this.activate_field(evt);
}, this));
}
};
Chosen.prototype.container_click = function(evt) {
if (evt && evt.type === "click") {
evt.stopPropagation();
}
if (!this.pending_destroy_click) {
if (!this.active_field) {
if (this.is_multiple) {
this.search_field.val("");
}
$(document).click(this.click_test_action);
this.results_show();
} else if (!this.is_multiple && evt && ($(evt.target) === this.selected_item || $(evt.target).parents("a.chzn-single").length)) {
evt.preventDefault();
this.results_toggle();
}
return this.activate_field();
} else {
return this.pending_destroy_click = false;
}
};
Chosen.prototype.mouse_enter = function() {
return this.mouse_on_container = true;
};
Chosen.prototype.mouse_leave = function() {
return this.mouse_on_container = false;
};
Chosen.prototype.input_focus = function(evt) {
if (!this.active_field) {
return setTimeout((__bind(function() {
return this.container_click();
}, this)), 50);
}
};
Chosen.prototype.input_blur = function(evt) {
if (!this.mouse_on_container) {
this.active_field = false;
return setTimeout((__bind(function() {
return this.blur_test();
}, this)), 100);
}
};
Chosen.prototype.blur_test = function(evt) {
if (!this.active_field && this.container.hasClass("chzn-container-active")) {
return this.close_field();
}
};
Chosen.prototype.close_field = function() {
$(document).unbind("click", this.click_test_action);
if (!this.is_multiple) {
this.selected_item.attr("tabindex", this.search_field.attr("tabindex"));
this.search_field.attr("tabindex", -1);
}
this.active_field = false;
this.results_hide();
this.container.removeClass("chzn-container-active");
this.winnow_results_clear();
this.clear_backstroke();
this.show_search_field_default();
return this.search_field_scale();
};
Chosen.prototype.activate_field = function() {
if (!this.is_multiple && !this.active_field) {
this.search_field.attr("tabindex", this.selected_item.attr("tabindex"));
this.selected_item.attr("tabindex", -1);
}
this.container.addClass("chzn-container-active");
this.active_field = true;
this.search_field.val(this.search_field.val());
return this.search_field.focus();
};
Chosen.prototype.test_active_click = function(evt) {
if ($(evt.target).parents('#' + this.container.id).length) {
return this.active_field = true;
} else {
return this.close_field();
}
};
Chosen.prototype.results_build = function() {
var content, data, startTime, _i, _len, _ref;
startTime = new Date();
this.parsing = true;
this.results_data = SelectParser.select_to_array(this.form_field);
if (this.is_multiple && this.choices > 0) {
this.search_choices.find("li.search-choice").remove();
this.choices = 0;
} else if (!this.is_multiple) {
this.selected_item.find("span").text(this.default_text);
}
content = '';
_ref = this.results_data;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
data = _ref[_i];
if (data.group) {
content += this.result_add_group(data);
} else if (!data.empty) {
content += this.result_add_option(data);
if (data.selected && this.is_multiple) {
this.choice_build(data);
} else if (data.selected && !this.is_multiple) {
this.selected_item.find("span").text(data.text);
}
}
}
this.show_search_field_default();
this.search_field_scale();
this.search_results.html(content);
return this.parsing = false;
};
Chosen.prototype.result_add_group = function(group) {
if (!group.disabled) {
group.dom_id = this.form_field.id + "chzn_g_" + group.array_index;
return '<li id="' + group.dom_id + '" class="group-result">' + $("<div />").text(group.label).html() + '</li>';
} else {
return "";
}
};
Chosen.prototype.result_add_option = function(option) {
var classes;
if (!option.disabled) {
option.dom_id = this.form_field.id + "chzn_o_" + option.array_index;
classes = option.selected && this.is_multiple ? [] : ["active-result"];
if (option.selected) {
classes.push("result-selected");
}
if (option.group_array_index != null) {
classes.push("group-option");
}
return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '">' + $("<div />").text(option.text).html() + '</li>';
} else {
return "";
}
};
Chosen.prototype.results_update_field = function() {
this.result_clear_highlight();
this.result_single_selected = null;
return this.results_build();
};
Chosen.prototype.result_do_highlight = function(el) {
var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
if (el.length) {
this.result_clear_highlight();
this.result_highlight = el;
this.result_highlight.addClass("highlighted");
maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
visible_top = this.search_results.scrollTop();
visible_bottom = maxHeight + visible_top;
high_top = this.result_highlight.position().top + this.search_results.scrollTop();
high_bottom = high_top + this.result_highlight.outerHeight();
if (high_bottom >= visible_bottom) {
return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
} else if (high_top < visible_top) {
return this.search_results.scrollTop(high_top);
}
}
};
Chosen.prototype.result_clear_highlight = function() {
if (this.result_highlight) {
this.result_highlight.removeClass("highlighted");
}
return this.result_highlight = null;
};
Chosen.prototype.results_toggle = function() {
if (this.results_showing) {
return this.results_hide();
} else {
return this.results_show();
}
};
Chosen.prototype.results_show = function() {
var dd_top;
if (!this.is_multiple) {
this.selected_item.addClass("chzn-single-with-drop");
if (this.result_single_selected) {
this.result_do_highlight(this.result_single_selected);
}
}
dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1;
this.dropdown.css({
"top": dd_top + "px",
"left": 0
});
this.results_showing = true;
this.search_field.focus();
this.search_field.val(this.search_field.val());
return this.winnow_results();
};
Chosen.prototype.results_hide = function() {
if (!this.is_multiple) {
this.selected_item.removeClass("chzn-single-with-drop");
}
this.result_clear_highlight();
this.dropdown.css({
"left": "-9000px"
});
return this.results_showing = false;
};
Chosen.prototype.set_tab_index = function(el) {
var ti;
if (this.form_field_jq.attr("tabindex")) {
ti = this.form_field_jq.attr("tabindex");
this.form_field_jq.attr("tabindex", -1);
if (this.is_multiple) {
return this.search_field.attr("tabindex", ti);
} else {
this.selected_item.attr("tabindex", ti);
return this.search_field.attr("tabindex", -1);
}
}
};
Chosen.prototype.show_search_field_default = function() {
if (this.is_multiple && this.choices < 1 && !this.active_field) {
this.search_field.val(this.default_text);
return this.search_field.addClass("default");
} else {
this.search_field.val("");
return this.search_field.removeClass("default");
}
};
Chosen.prototype.search_results_click = function(evt) {
var target;
target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
if (target.length) {
this.result_highlight = target;
return this.result_select();
}
};
Chosen.prototype.search_results_mouseover = function(evt) {
var target;
target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
if (target) {
return this.result_do_highlight(target);
}
};
Chosen.prototype.search_results_mouseout = function(evt) {
if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
return this.result_clear_highlight();
}
};
Chosen.prototype.choices_click = function(evt) {
evt.preventDefault();
if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) {
return this.results_show();
}
};
Chosen.prototype.choice_build = function(item) {
var choice_id, link;
choice_id = this.form_field.id + "_chzn_c_" + item.array_index;
this.choices += 1;
this.search_container.before('<li class="search-choice" id="' + choice_id + '"><span>' + item.text + '</span><a href="javascript:void(0)" class="search-choice-close" rel="' + item.array_index + '"></a></li>');
link = $('#' + choice_id).find("a").first();
return link.click(__bind(function(evt) {
return this.choice_destroy_link_click(evt);
}, this));
};
Chosen.prototype.choice_destroy_link_click = function(evt) {
evt.preventDefault();
this.pending_destroy_click = true;
return this.choice_destroy($(evt.target));
};
Chosen.prototype.choice_destroy = function(link) {
this.choices -= 1;
this.show_search_field_default();
if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) {
this.results_hide();
}
this.result_deselect(link.attr("rel"));
return link.parents('li').first().remove();
};
Chosen.prototype.result_select = function() {
var high, high_id, item, position;
if (this.result_highlight) {
high = this.result_highlight;
high_id = high.attr("id");
this.result_clear_highlight();
high.addClass("result-selected");
if (this.is_multiple) {
this.result_deactivate(high);
} else {
this.result_single_selected = high;
}
position = high_id.substr(high_id.lastIndexOf("_") + 1);
item = this.results_data[position];
item.selected = true;
this.form_field.options[item.options_index].selected = true;
if (this.is_multiple) {
this.choice_build(item);
} else {
this.selected_item.find("span").first().text(item.text);
}
this.results_hide();
this.search_field.val("");
this.form_field_jq.trigger("change");
return this.search_field_scale();
}
};
Chosen.prototype.result_activate = function(el) {
return el.addClass("active-result").show();
};
Chosen.prototype.result_deactivate = function(el) {
return el.removeClass("active-result").hide();
};
Chosen.prototype.result_deselect = function(pos) {
var result, result_data;
result_data = this.results_data[pos];
result_data.selected = false;
this.form_field.options[result_data.options_index].selected = false;
result = $("#" + this.form_field.id + "chzn_o_" + pos);
result.removeClass("result-selected").addClass("active-result").show();
this.result_clear_highlight();
this.winnow_results();
this.form_field_jq.trigger("change");
return this.search_field_scale();
};
Chosen.prototype.results_search = function(evt) {
if (this.results_showing) {
return this.winnow_results();
} else {
return this.results_show();
}
};
Chosen.prototype.winnow_results = function() {
var found, option, part, parts, regex, result_id, results, searchText, startTime, startpos, text, zregex, _i, _j, _len, _len2, _ref;
startTime = new Date();
this.no_results_clear();
results = 0;
searchText = this.search_field.val() === this.default_text ? "" : $.trim(this.search_field.val());
regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
_ref = this.results_data;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
option = _ref[_i];
if (!option.disabled && !option.empty) {
if (option.group) {
$('#' + option.dom_id).hide();
} else if (!(this.is_multiple && option.selected)) {
found = false;
result_id = option.dom_id;
if (regex.test(option.text)) {
found = true;
results += 1;
} else if (option.text.indexOf(" ") >= 0 || option.text.indexOf("[") === 0) {
parts = option.text.replace(/\[|\]/g, "").split(" ");
if (parts.length) {
for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
part = parts[_j];
if (regex.test(part)) {
found = true;
results += 1;
}
}
}
}
if (found) {
if (searchText.length) {
startpos = option.text.search(zregex);
text = option.text.substr(0, startpos + searchText.length) + '</em>' + option.text.substr(startpos + searchText.length);
text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
} else {
text = option.text;
}
if ($("#" + result_id).html !== text) {
$("#" + result_id).html(text);
}
this.result_activate($("#" + result_id));
if (option.group_array_index != null) {
$("#" + this.results_data[option.group_array_index].dom_id).show();
}
} else {
if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
this.result_clear_highlight();
}
this.result_deactivate($("#" + result_id));
}
}
}
}
if (results < 1 && searchText.length) {
return this.no_results(searchText);
} else {
return this.winnow_results_set_highlight();
}
};
Chosen.prototype.winnow_results_clear = function() {
var li, lis, _i, _len, _results;
this.search_field.val("");
lis = this.search_results.find("li");
_results = [];
for (_i = 0, _len = lis.length; _i < _len; _i++) {
li = lis[_i];
li = $(li);
_results.push(li.hasClass("group-result") ? li.show() : !this.is_multiple || !li.hasClass("result-selected") ? this.result_activate(li) : void 0);
}
return _results;
};
Chosen.prototype.winnow_results_set_highlight = function() {
var do_high;
if (!this.result_highlight) {
do_high = this.search_results.find(".active-result").first();
if (do_high) {
return this.result_do_highlight(do_high);
}
}
};
Chosen.prototype.no_results = function(terms) {
var no_results_html;
no_results_html = $('<li class="no-results">No results match "<span></span>"</li>');
no_results_html.find("span").first().text(terms);
return this.search_results.append(no_results_html);
};
Chosen.prototype.no_results_clear = function() {
return this.search_results.find(".no-results").remove();
};
Chosen.prototype.keydown_arrow = function() {
var first_active, next_sib;
if (!this.result_highlight) {
first_active = this.search_results.find("li.active-result").first();
if (first_active) {
this.result_do_highlight($(first_active));
}
} else if (this.results_showing) {
next_sib = this.result_highlight.nextAll("li.active-result").first();
if (next_sib) {
this.result_do_highlight(next_sib);
}
}
if (!this.results_showing) {
return this.results_show();
}
};
Chosen.prototype.keyup_arrow = function() {
var prev_sibs;
if (!this.results_showing && !this.is_multiple) {
return this.results_show();
} else if (this.result_highlight) {
prev_sibs = this.result_highlight.prevAll("li.active-result");
if (prev_sibs.length) {
return this.result_do_highlight(prev_sibs.first());
} else {
if (this.choices > 0) {
this.results_hide();
}
return this.result_clear_highlight();
}
}
};
Chosen.prototype.keydown_backstroke = function() {
if (this.pending_backstroke) {
this.choice_destroy(this.pending_backstroke.find("a").first());
return this.clear_backstroke();
} else {
this.pending_backstroke = this.search_container.siblings("li.search-choice").last();
return this.pending_backstroke.addClass("search-choice-focus");
}
};
Chosen.prototype.clear_backstroke = function() {
if (this.pending_backstroke) {
this.pending_backstroke.removeClass("search-choice-focus");
}
return this.pending_backstroke = null;
};
Chosen.prototype.keyup_checker = function(evt) {
var stroke, _ref;
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
this.search_field_scale();
switch (stroke) {
case 8:
if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
return this.keydown_backstroke();
} else if (!this.pending_backstroke) {
this.result_clear_highlight();
return this.results_search();
}
break;
case 13:
evt.preventDefault();
if (this.results_showing) {
return this.result_select();
}
break;
case 27:
if (this.results_showing) {
return this.results_hide();
}
break;
case 9:
case 38:
case 40:
case 16:
break;
default:
return this.results_search();
}
};
Chosen.prototype.keydown_checker = function(evt) {
var stroke, _ref;
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
this.search_field_scale();
if (stroke !== 8 && this.pending_backstroke) {
this.clear_backstroke();
}
switch (stroke) {
case 8:
this.backstroke_length = this.search_field.val().length;
break;
case 9:
this.mouse_on_container = false;
break;
case 13:
evt.preventDefault();
break;
case 38:
evt.preventDefault();
this.keyup_arrow();
break;
case 40:
this.keydown_arrow();
break;
}
};
Chosen.prototype.search_field_scale = function() {
var dd_top, div, h, style, style_block, styles, w, _i, _len;
if (this.is_multiple) {
h = 0;
w = 0;
style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
for (_i = 0, _len = styles.length; _i < _len; _i++) {
style = styles[_i];
style_block += style + ":" + this.search_field.css(style) + ";";
}
div = $('<div />', {
'style': style_block
});
div.text(this.search_field.val());
$('body').append(div);
w = div.width() + 25;
div.remove();
if (w > this.f_width - 10) {
w = this.f_width - 10;
}
this.search_field.css({
'width': w + 'px'
});
dd_top = this.container.height();
return this.dropdown.css({
"top": dd_top + "px"
});
}
};
return Chosen;
})();
get_side_border_padding = function(elmt) {
var side_border_padding;
return side_border_padding = elmt.outerWidth() - elmt.width();
};
root.get_side_border_padding = get_side_border_padding;
SelectParser = (function() {
function SelectParser() {
this.options_index = 0;
this.parsed = [];
}
SelectParser.prototype.add_node = function(child) {
if (child.nodeName === "OPTGROUP") {
return this.add_group(child);
} else {
return this.add_option(child);
}
};
SelectParser.prototype.add_group = function(group) {
var group_position, option, _i, _len, _ref, _results;
group_position = this.parsed.length;
this.parsed.push({
array_index: group_position,
group: true,
label: group.label,
children: 0,
disabled: group.disabled
});
_ref = group.childNodes;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
option = _ref[_i];
_results.push(this.add_option(option, group_position, group.disabled));
}
return _results;
};
SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
if (option.nodeName === "OPTION") {
if (option.text !== "") {
if (group_position != null) {
this.parsed[group_position].children += 1;
}
this.parsed.push({
array_index: this.parsed.length,
options_index: this.options_index,
value: option.value,
text: option.text,
selected: option.selected,
disabled: group_disabled === true ? group_disabled : option.disabled,
group_array_index: group_position
});
} else {
this.parsed.push({
array_index: this.parsed.length,
options_index: this.options_index,
empty: true
});
}
return this.options_index += 1;
}
};
return SelectParser;
})();
SelectParser.select_to_array = function(select) {
var child, parser, _i, _len, _ref;
parser = new SelectParser();
_ref = select.childNodes;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
child = _ref[_i];
parser.add_node(child);
}
return parser.parsed;
};
root.SelectParser = SelectParser;
}).call(this);

File diff suppressed because one or more lines are too long

View File

@ -1,765 +0,0 @@
(function() {
/*
Chosen, a Select Box Enhancer for jQuery and Protoype
by Patrick Filler for Harvest, http://getharvest.com
Available for use under the MIT License, http://en.wikipedia.org/wiki/MIT_License
Copyright (c) 2011 by Harvest
*/ var Chosen, SelectParser, get_side_border_padding, root;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
root = typeof exports !== "undefined" && exports !== null ? exports : this;
Chosen = (function() {
function Chosen(elmn) {
this.set_default_values();
this.form_field = elmn;
this.is_multiple = this.form_field.multiple;
this.default_text_default = this.form_field.multiple ? "Select Some Options" : "Select an Option";
this.set_up_html();
this.register_observers();
}
Chosen.prototype.set_default_values = function() {
this.click_test_action = __bind(function(evt) {
return this.test_active_click(evt);
}, this);
this.active_field = false;
this.mouse_on_container = false;
this.results_showing = false;
this.result_highlighted = null;
this.result_single_selected = null;
this.choices = 0;
this.single_temp = new Template('<a href="javascript:void(0)" class="chzn-single"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" /></div><ul class="chzn-results"></ul></div>');
this.multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
this.choice_temp = new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>');
return this.no_results_temp = new Template('<li class="no-results">No results match "<span>#{terms}</span>"</li>');
};
Chosen.prototype.set_up_html = function() {
var base_template, container_props, dd_top, dd_width, sf_width;
this.container_id = this.form_field.id + "_chzn";
this.f_width = this.form_field.getStyle("width") ? parseInt(this.form_field.getStyle("width"), 10) : this.form_field.getWidth();
container_props = {
'id': this.container_id,
'class': 'chzn-container',
'style': 'width: ' + this.f_width + 'px'
};
this.default_text = this.form_field.readAttribute('title') ? this.form_field.readAttribute('title') : this.default_text_default;
base_template = this.is_multiple ? new Element('div', container_props).update(this.multi_temp.evaluate({
"default": this.default_text
})) : new Element('div', container_props).update(this.single_temp.evaluate({
"default": this.default_text
}));
this.form_field.hide().insert({
after: base_template
});
this.container = $(this.container_id);
this.container.addClassName("chzn-container-" + (this.is_multiple ? "multi" : "single"));
this.dropdown = this.container.down('div.chzn-drop');
dd_top = this.container.getHeight();
dd_width = this.f_width - get_side_border_padding(this.dropdown);
this.dropdown.setStyle({
"width": dd_width + "px",
"top": dd_top + "px"
});
this.search_field = this.container.down('input');
this.search_results = this.container.down('ul.chzn-results');
this.search_field_scale();
this.search_no_results = this.container.down('li.no-results');
if (this.is_multiple) {
this.search_choices = this.container.down('ul.chzn-choices');
this.search_container = this.container.down('li.search-field');
} else {
this.search_container = this.container.down('div.chzn-search');
this.selected_item = this.container.down('.chzn-single');
sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field);
this.search_field.setStyle({
"width": sf_width + "px"
});
}
this.results_build();
return this.set_tab_index();
};
Chosen.prototype.register_observers = function() {
this.container.observe("click", __bind(function(evt) {
return this.container_click(evt);
}, this));
this.container.observe("mouseenter", __bind(function(evt) {
return this.mouse_enter(evt);
}, this));
this.container.observe("mouseleave", __bind(function(evt) {
return this.mouse_leave(evt);
}, this));
this.search_results.observe("click", __bind(function(evt) {
return this.search_results_click(evt);
}, this));
this.search_results.observe("mouseover", __bind(function(evt) {
return this.search_results_mouseover(evt);
}, this));
this.search_results.observe("mouseout", __bind(function(evt) {
return this.search_results_mouseout(evt);
}, this));
this.form_field.observe("liszt:updated", __bind(function(evt) {
return this.results_update_field(evt);
}, this));
this.search_field.observe("blur", __bind(function(evt) {
return this.input_blur(evt);
}, this));
this.search_field.observe("keyup", __bind(function(evt) {
return this.keyup_checker(evt);
}, this));
this.search_field.observe("keydown", __bind(function(evt) {
return this.keydown_checker(evt);
}, this));
if (this.is_multiple) {
this.search_choices.observe("click", __bind(function(evt) {
return this.choices_click(evt);
}, this));
return this.search_field.observe("focus", __bind(function(evt) {
return this.input_focus(evt);
}, this));
} else {
return this.selected_item.observe("focus", __bind(function(evt) {
return this.activate_field(evt);
}, this));
}
};
Chosen.prototype.container_click = function(evt) {
if (evt && evt.type === "click") {
evt.stop();
}
if (!this.pending_destroy_click) {
if (!this.active_field) {
if (this.is_multiple) {
this.search_field.clear();
}
document.observe("click", this.click_test_action);
this.results_show();
} else if (!this.is_multiple && evt && (evt.target === this.selected_item || evt.target.up("a.chzn-single"))) {
this.results_toggle();
}
return this.activate_field();
} else {
return this.pending_destroy_click = false;
}
};
Chosen.prototype.mouse_enter = function() {
return this.mouse_on_container = true;
};
Chosen.prototype.mouse_leave = function() {
return this.mouse_on_container = false;
};
Chosen.prototype.input_focus = function(evt) {
if (!this.active_field) {
return setTimeout(this.container_click.bind(this), 50);
}
};
Chosen.prototype.input_blur = function(evt) {
if (!this.mouse_on_container) {
this.active_field = false;
return setTimeout(this.blur_test.bind(this), 100);
}
};
Chosen.prototype.blur_test = function(evt) {
if (!this.active_field && this.container.hasClassName("chzn-container-active")) {
return this.close_field();
}
};
Chosen.prototype.close_field = function() {
document.stopObserving("click", this.click_test_action);
if (!this.is_multiple) {
this.selected_item.tabIndex = this.search_field.tabIndex;
this.search_field.tabIndex = -1;
}
this.active_field = false;
this.results_hide();
this.container.removeClassName("chzn-container-active");
this.winnow_results_clear();
this.clear_backstroke();
this.show_search_field_default();
return this.search_field_scale();
};
Chosen.prototype.activate_field = function() {
if (!this.is_multiple && !this.active_field) {
this.search_field.tabIndex = this.selected_item.tabIndex;
this.selected_item.tabIndex = -1;
}
this.container.addClassName("chzn-container-active");
this.active_field = true;
this.search_field.value = this.search_field.value;
return this.search_field.focus();
};
Chosen.prototype.test_active_click = function(evt) {
if (evt.target.up('#' + this.container.id)) {
return this.active_field = true;
} else {
return this.close_field();
}
};
Chosen.prototype.results_build = function() {
var content, data, startTime, _i, _len, _ref;
startTime = new Date();
this.parsing = true;
this.results_data = SelectParser.select_to_array(this.form_field);
if (this.is_multiple && this.choices > 0) {
this.search_choices.select("li.search-choice").invoke("remove");
this.choices = 0;
} else if (!this.is_multiple) {
this.selected_item.down("span").update(this.default_text);
}
content = '';
_ref = this.results_data;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
data = _ref[_i];
if (data.group) {
content += this.result_add_group(data);
} else if (!data.empty) {
content += this.result_add_option(data);
if (data.selected && this.is_multiple) {
this.choice_build(data);
} else if (data.selected && !this.is_multiple) {
this.selected_item.down("span").update(data.text);
}
}
}
this.show_search_field_default();
this.search_field_scale();
this.search_results.update(content);
return this.parsing = false;
};
Chosen.prototype.result_add_group = function(group) {
if (!group.disabled) {
group.dom_id = this.form_field.id + "chzn_g_" + group.array_index;
return '<li id="' + group.dom_id + '" class="group-result">' + group.label.escapeHTML() + '</li>';
} else {
return "";
}
};
Chosen.prototype.result_add_option = function(option) {
var classes;
if (!option.disabled) {
option.dom_id = this.form_field.id + "chzn_o_" + option.array_index;
classes = option.selected && this.is_multiple ? [] : ["active-result"];
if (option.selected) {
classes.push("result-selected");
}
if (option.group_array_index != null) {
classes.push("group-option");
}
return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '">' + option.text.escapeHTML() + '</li>';
} else {
return "";
}
};
Chosen.prototype.results_update_field = function() {
this.result_clear_highlight();
this.result_single_selected = null;
return this.results_build();
};
Chosen.prototype.result_do_highlight = function(el) {
var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
this.result_clear_highlight();
this.result_highlight = el;
this.result_highlight.addClassName("highlighted");
maxHeight = parseInt(this.search_results.getStyle('maxHeight'), 10);
visible_top = this.search_results.scrollTop;
visible_bottom = maxHeight + visible_top;
high_top = this.result_highlight.positionedOffset().top;
high_bottom = high_top + this.result_highlight.getHeight();
if (high_bottom >= visible_bottom) {
return this.search_results.scrollTop = (high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0;
} else if (high_top < visible_top) {
return this.search_results.scrollTop = high_top;
}
};
Chosen.prototype.result_clear_highlight = function() {
if (this.result_highlight) {
this.result_highlight.removeClassName('highlighted');
}
return this.result_highlight = null;
};
Chosen.prototype.results_toggle = function() {
if (this.results_showing) {
return this.results_hide();
} else {
return this.results_show();
}
};
Chosen.prototype.results_show = function() {
var dd_top;
if (!this.is_multiple) {
this.selected_item.addClassName('chzn-single-with-drop');
if (this.result_single_selected) {
this.result_do_highlight(this.result_single_selected);
}
}
dd_top = this.is_multiple ? this.container.getHeight() : this.container.getHeight() - 1;
this.dropdown.setStyle({
"top": dd_top + "px",
"left": 0
});
this.results_showing = true;
this.search_field.focus();
this.search_field.value = this.search_field.value;
return this.winnow_results();
};
Chosen.prototype.results_hide = function() {
if (!this.is_multiple) {
this.selected_item.removeClassName('chzn-single-with-drop');
}
this.result_clear_highlight();
this.dropdown.setStyle({
"left": "-9000px"
});
return this.results_showing = false;
};
Chosen.prototype.set_tab_index = function(el) {
var ti;
if (this.form_field.tabIndex) {
ti = this.form_field.tabIndex;
this.form_field.tabIndex = -1;
if (this.is_multiple) {
return this.search_field.tabIndex = ti;
} else {
this.selected_item.tabIndex = ti;
return this.search_field.tabIndex = -1;
}
}
};
Chosen.prototype.show_search_field_default = function() {
if (this.is_multiple && this.choices < 1 && !this.active_field) {
this.search_field.value = this.default_text;
return this.search_field.addClassName("default");
} else {
this.search_field.value = "";
return this.search_field.removeClassName("default");
}
};
Chosen.prototype.search_results_click = function(evt) {
var target;
target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result");
if (target) {
this.result_highlight = target;
return this.result_select();
}
};
Chosen.prototype.search_results_mouseover = function(evt) {
var target;
target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result");
if (target) {
return this.result_do_highlight(target);
}
};
Chosen.prototype.search_results_mouseout = function(evt) {
if (evt.target.hasClassName('active-result') || evt.target.up('.active-result')) {
return this.result_clear_highlight();
}
};
Chosen.prototype.choices_click = function(evt) {
evt.preventDefault();
if (this.active_field && !(evt.target.hasClassName('search-choice') || evt.target.up('.search-choice')) && !this.results_showing) {
return this.results_show();
}
};
Chosen.prototype.choice_build = function(item) {
var choice_id, link;
choice_id = this.form_field.id + "_chzn_c_" + item.array_index;
this.choices += 1;
this.search_container.insert({
before: this.choice_temp.evaluate({
"id": choice_id,
"choice": item.text,
"position": item.array_index
})
});
link = $(choice_id).down('a');
return link.observe("click", __bind(function(evt) {
return this.choice_destroy_link_click(evt);
}, this));
};
Chosen.prototype.choice_destroy_link_click = function(evt) {
evt.preventDefault();
this.pending_destroy_click = true;
return this.choice_destroy(evt.target);
};
Chosen.prototype.choice_destroy = function(link) {
this.choices -= 1;
this.show_search_field_default();
if (this.is_multiple && this.choices > 0 && this.search_field.value.length < 1) {
this.results_hide();
}
this.result_deselect(link.readAttribute("rel"));
return link.up('li').remove();
};
Chosen.prototype.result_select = function() {
var high, item, position;
if (this.result_highlight) {
high = this.result_highlight;
this.result_clear_highlight();
high.addClassName("result-selected");
if (this.is_multiple) {
this.result_deactivate(high);
} else {
this.result_single_selected = high;
}
position = high.id.substr(high.id.lastIndexOf("_") + 1);
item = this.results_data[position];
item.selected = true;
this.form_field.options[item.options_index].selected = true;
if (this.is_multiple) {
this.choice_build(item);
} else {
this.selected_item.down("span").update(item.text);
}
this.results_hide();
this.search_field.value = "";
if (typeof Event.simulate === 'function') {
this.form_field.simulate("change");
}
return this.search_field_scale();
}
};
Chosen.prototype.result_activate = function(el) {
return el.addClassName("active-result").show();
};
Chosen.prototype.result_deactivate = function(el) {
return el.removeClassName("active-result").hide();
};
Chosen.prototype.result_deselect = function(pos) {
var result, result_data;
result_data = this.results_data[pos];
result_data.selected = false;
this.form_field.options[result_data.options_index].selected = false;
result = $(this.form_field.id + "chzn_o_" + pos);
result.removeClassName("result-selected").addClassName("active-result").show();
this.result_clear_highlight();
this.winnow_results();
if (typeof Event.simulate === 'function') {
this.form_field.simulate("change");
}
return this.search_field_scale();
};
Chosen.prototype.results_search = function(evt) {
if (this.results_showing) {
return this.winnow_results();
} else {
return this.results_show();
}
};
Chosen.prototype.winnow_results = function() {
var found, option, part, parts, regex, result_id, results, searchText, startTime, startpos, text, zregex, _i, _j, _len, _len2, _ref;
startTime = new Date();
this.no_results_clear();
results = 0;
searchText = this.search_field.value === this.default_text ? "" : this.search_field.value.strip();
regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
_ref = this.results_data;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
option = _ref[_i];
if (!option.disabled && !option.empty) {
if (option.group) {
$(option.dom_id).hide();
} else if (!(this.is_multiple && option.selected)) {
found = false;
result_id = option.dom_id;
if (regex.test(option.text)) {
found = true;
results += 1;
} else if (option.text.indexOf(" ") >= 0 || option.text.indexOf("[") === 0) {
parts = option.text.replace(/\[|\]/g, "").split(" ");
if (parts.length) {
for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
part = parts[_j];
if (regex.test(part)) {
found = true;
results += 1;
}
}
}
}
if (found) {
if (searchText.length) {
startpos = option.text.search(zregex);
text = option.text.substr(0, startpos + searchText.length) + '</em>' + option.text.substr(startpos + searchText.length);
text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
} else {
text = option.text;
}
if ($(result_id).innerHTML !== text) {
$(result_id).update(text);
}
this.result_activate($(result_id));
if (option.group_array_index != null) {
$(this.results_data[option.group_array_index].dom_id).show();
}
} else {
if ($(result_id) === this.result_highlight) {
this.result_clear_highlight();
}
this.result_deactivate($(result_id));
}
}
}
}
if (results < 1 && searchText.length) {
return this.no_results(searchText);
} else {
return this.winnow_results_set_highlight();
}
};
Chosen.prototype.winnow_results_clear = function() {
var li, lis, _i, _len, _results;
this.search_field.clear();
lis = this.search_results.select("li");
_results = [];
for (_i = 0, _len = lis.length; _i < _len; _i++) {
li = lis[_i];
_results.push(li.hasClassName("group-result") ? li.show() : !this.is_multiple || !li.hasClassName("result-selected") ? this.result_activate(li) : void 0);
}
return _results;
};
Chosen.prototype.winnow_results_set_highlight = function() {
var do_high;
if (!this.result_highlight) {
do_high = this.search_results.down(".active-result");
if (do_high) {
return this.result_do_highlight(do_high);
}
}
};
Chosen.prototype.no_results = function(terms) {
return this.search_results.insert(this.no_results_temp.evaluate({
"terms": terms.escapeHTML()
}));
};
Chosen.prototype.no_results_clear = function() {
var nr, _results;
nr = null;
_results = [];
while (nr = this.search_results.down(".no-results")) {
_results.push(nr.remove());
}
return _results;
};
Chosen.prototype.keydown_arrow = function() {
var actives, nexts, sibs;
actives = this.search_results.select("li.active-result");
if (actives.length) {
if (!this.result_highlight) {
this.result_do_highlight(actives.first());
} else if (this.results_showing) {
sibs = this.result_highlight.nextSiblings();
nexts = sibs.intersect(actives);
if (nexts.length) {
this.result_do_highlight(nexts.first());
}
}
if (!this.results_showing) {
return this.results_show();
}
}
};
Chosen.prototype.keyup_arrow = function() {
var actives, prevs, sibs;
if (!this.results_showing && !this.is_multiple) {
return this.results_show();
} else if (this.result_highlight) {
sibs = this.result_highlight.previousSiblings();
actives = this.search_results.select("li.active-result");
prevs = sibs.intersect(actives);
if (prevs.length) {
return this.result_do_highlight(prevs.first());
} else {
if (this.choices > 0) {
this.results_hide();
}
return this.result_clear_highlight();
}
}
};
Chosen.prototype.keydown_backstroke = function() {
if (this.pending_backstroke) {
this.choice_destroy(this.pending_backstroke.down("a"));
return this.clear_backstroke();
} else {
this.pending_backstroke = this.search_container.siblings("li.search-choice").last();
return this.pending_backstroke.addClassName("search-choice-focus");
}
};
Chosen.prototype.clear_backstroke = function() {
if (this.pending_backstroke) {
this.pending_backstroke.removeClassName("search-choice-focus");
}
return this.pending_backstroke = null;
};
Chosen.prototype.keyup_checker = function(evt) {
var stroke, _ref;
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
this.search_field_scale();
switch (stroke) {
case 8:
if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
return this.keydown_backstroke();
} else if (!this.pending_backstroke) {
this.result_clear_highlight();
return this.results_search();
}
break;
case 13:
evt.preventDefault();
if (this.results_showing) {
return this.result_select();
}
break;
case 27:
if (this.results_showing) {
return this.results_hide();
}
break;
case 9:
case 38:
case 40:
case 16:
break;
default:
return this.results_search();
}
};
Chosen.prototype.keydown_checker = function(evt) {
var stroke, _ref;
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
this.search_field_scale();
if (stroke !== 8 && this.pending_backstroke) {
this.clear_backstroke();
}
switch (stroke) {
case 8:
return this.backstroke_length = this.search_field.value.length;
case 9:
return this.mouse_on_container = false;
case 13:
return evt.preventDefault();
case 38:
evt.preventDefault();
return this.keyup_arrow();
case 40:
return this.keydown_arrow();
}
};
Chosen.prototype.search_field_scale = function() {
var dd_top, div, h, style, style_block, styles, w, _i, _len;
if (this.is_multiple) {
h = 0;
w = 0;
style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
for (_i = 0, _len = styles.length; _i < _len; _i++) {
style = styles[_i];
style_block += style + ":" + this.search_field.getStyle(style) + ";";
}
div = new Element('div', {
'style': style_block
}).update(this.search_field.value);
document.body.appendChild(div);
w = Element.measure(div, 'width') + 25;
div.remove();
if (w > this.f_width - 10) {
w = this.f_width - 10;
}
this.search_field.setStyle({
'width': w + 'px'
});
dd_top = this.container.getHeight();
return this.dropdown.setStyle({
"top": dd_top + "px"
});
}
};
return Chosen;
})();
root.Chosen = Chosen;
document.observe('dom:loaded', function(evt) {
var select, selects, _i, _len, _results;
selects = $$(".chzn-select");
_results = [];
for (_i = 0, _len = selects.length; _i < _len; _i++) {
select = selects[_i];
_results.push(new Chosen(select));
}
return _results;
});
get_side_border_padding = function(elmt) {
var layout, side_border_padding;
layout = new Element.Layout(elmt);
return side_border_padding = layout.get("border-left") + layout.get("border-right") + layout.get("padding-left") + layout.get("padding-right");
};
root.get_side_border_padding = get_side_border_padding;
root = typeof exports !== "undefined" && exports !== null ? exports : this;
SelectParser = (function() {
function SelectParser() {
this.options_index = 0;
this.parsed = [];
}
SelectParser.prototype.add_node = function(child) {
if (child.nodeName === "OPTGROUP") {
return this.add_group(child);
} else {
return this.add_option(child);
}
};
SelectParser.prototype.add_group = function(group) {
var group_position, option, _i, _len, _ref, _results;
group_position = this.parsed.length;
this.parsed.push({
array_index: group_position,
group: true,
label: group.label,
children: 0,
disabled: group.disabled
});
_ref = group.childNodes;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
option = _ref[_i];
_results.push(this.add_option(option, group_position, group.disabled));
}
return _results;
};
SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
if (option.nodeName === "OPTION") {
if (option.text !== "") {
if (group_position != null) {
this.parsed[group_position].children += 1;
}
this.parsed.push({
array_index: this.parsed.length,
options_index: this.options_index,
value: option.value,
text: option.text,
selected: option.selected,
disabled: group_disabled === true ? group_disabled : option.disabled,
group_array_index: group_position
});
} else {
this.parsed.push({
array_index: this.parsed.length,
options_index: this.options_index,
empty: true
});
}
return this.options_index += 1;
}
};
return SelectParser;
})();
SelectParser.select_to_array = function(select) {
var child, parser, _i, _len, _ref;
parser = new SelectParser();
_ref = select.childNodes;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
child = _ref[_i];
parser.add_node(child);
}
return parser.parsed;
};
root.SelectParser = SelectParser;
}).call(this);

File diff suppressed because one or more lines are too long

View File

@ -1,633 +0,0 @@
###
Chosen, a Select Box Enhancer for jQuery and Protoype
by Patrick Filler for Harvest, http://getharvest.com
Available for use under the MIT License, http://en.wikipedia.org/wiki/MIT_License
Copyright (c) 2011 by Harvest
###
root = exports ? this
$ = jQuery
$.fn.extend({
chosen: (data, options) ->
$(this).each((input_field) ->
new Chosen(this, data, options) unless ($ this).hasClass "chzn-done"
)
})
class Chosen
constructor: (elmn) ->
this.set_default_values()
@form_field = elmn
@form_field_jq = $ @form_field
@is_multiple = @form_field.multiple
@default_text_default = if @form_field.multiple then "Select Some Options" else "Select an Option"
this.set_up_html()
this.register_observers()
@form_field_jq.addClass "chzn-done"
set_default_values: ->
@click_test_action = (evt) => this.test_active_click(evt)
@active_field = false
@mouse_on_container = false
@results_showing = false
@result_highlighted = null
@result_single_selected = null
@choices = 0
set_up_html: ->
@container_id = @form_field.id + "_chzn"
@f_width = @form_field_jq.width()
@default_text = if @form_field_jq.attr 'title' then @form_field_jq.attr 'title' else @default_text_default
container_div = ($ "<div />", {
id: @container_id
class: 'chzn-container'
style: 'width: ' + (@f_width) + 'px;' #use parens around @f_width so coffeescript doesn't think + ' px' is a function parameter
})
if @is_multiple
container_div.html '<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + @default_text + '" class="default" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>'
else
container_div.html '<a href="javascript:void(0)" class="chzn-single"><span>' + @default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" /></div><ul class="chzn-results"></ul></div>'
@form_field_jq.hide().after container_div
@container = ($ '#' + @container_id)
@container.addClass( "chzn-container-" + (if @is_multiple then "multi" else "single") )
@dropdown = @container.find('div.chzn-drop').first()
dd_top = @container.height()
dd_width = (@f_width - get_side_border_padding(@dropdown))
@dropdown.css({"width": dd_width + "px", "top": dd_top + "px"})
@search_field = @container.find('input').first()
@search_results = @container.find('ul.chzn-results').first()
this.search_field_scale()
@search_no_results = @container.find('li.no-results').first()
if @is_multiple
@search_choices = @container.find('ul.chzn-choices').first()
@search_container = @container.find('li.search-field').first()
else
@search_container = @container.find('div.chzn-search').first()
@selected_item = @container.find('.chzn-single').first()
sf_width = dd_width - get_side_border_padding(@search_container) - get_side_border_padding(@search_field)
@search_field.css( {"width" : sf_width + "px"} )
this.results_build()
this.set_tab_index()
register_observers: ->
@container.click (evt) => this.container_click(evt)
@container.mouseenter (evt) => this.mouse_enter(evt)
@container.mouseleave (evt) => this.mouse_leave(evt)
@search_results.click (evt) => this.search_results_click(evt)
@search_results.mouseover (evt) => this.search_results_mouseover(evt)
@search_results.mouseout (evt) => this.search_results_mouseout(evt)
@form_field_jq.bind "liszt:updated", (evt) => this.results_update_field(evt)
@search_field.blur (evt) => this.input_blur(evt)
@search_field.keyup (evt) => this.keyup_checker(evt)
@search_field.keydown (evt) => this.keydown_checker(evt)
if @is_multiple
@search_choices.click (evt) => this.choices_click(evt)
@search_field.focus (evt) => this.input_focus(evt)
else
@selected_item.focus (evt) => this.activate_field(evt)
container_click: (evt) ->
if evt and evt.type is "click"
evt.stopPropagation()
if not @pending_destroy_click
if not @active_field
@search_field.val "" if @is_multiple
$(document).click @click_test_action
this.results_show()
else if not @is_multiple and evt and ($(evt.target) is @selected_item || $(evt.target).parents("a.chzn-single").length)
evt.preventDefault()
this.results_toggle()
this.activate_field()
else
@pending_destroy_click = false
mouse_enter: -> @mouse_on_container = true
mouse_leave: -> @mouse_on_container = false
input_focus: (evt) ->
setTimeout (=> this.container_click()), 50 unless @active_field
input_blur: (evt) ->
if not @mouse_on_container
@active_field = false
setTimeout (=> this.blur_test()), 100
blur_test: (evt) ->
this.close_field() if not @active_field and @container.hasClass "chzn-container-active"
close_field: ->
$(document).unbind "click", @click_test_action
if not @is_multiple
@selected_item.attr "tabindex", @search_field.attr("tabindex")
@search_field.attr "tabindex", -1
@active_field = false
this.results_hide()
@container.removeClass "chzn-container-active"
this.winnow_results_clear()
this.clear_backstroke()
this.show_search_field_default()
this.search_field_scale()
activate_field: ->
if not @is_multiple and not @active_field
@search_field.attr "tabindex", (@selected_item.attr "tabindex")
@selected_item.attr "tabindex", -1
@container.addClass "chzn-container-active"
@active_field = true
@search_field.val(@search_field.val())
@search_field.focus()
test_active_click: (evt) ->
if $(evt.target).parents('#' + @container.id).length
@active_field = true
else
this.close_field()
results_build: ->
startTime = new Date()
@parsing = true
@results_data = SelectParser.select_to_array @form_field
if @is_multiple and @choices > 0
@search_choices.find("li.search-choice").remove()
@choices = 0
else if not @is_multiple
@selected_item.find("span").text @default_text
content = ''
for data in @results_data
if data.group
content += this.result_add_group data
else if !data.empty
content += this.result_add_option data
if data.selected and @is_multiple
this.choice_build data
else if data.selected and not @is_multiple
@selected_item.find("span").text data.text
this.show_search_field_default()
this.search_field_scale()
@search_results.html content
@parsing = false
result_add_group: (group) ->
if not group.disabled
group.dom_id = @form_field.id + "chzn_g_" + group.array_index
'<li id="' + group.dom_id + '" class="group-result">' + $("<div />").text(group.label).html() + '</li>'
else
""
result_add_option: (option) ->
if not option.disabled
option.dom_id = @form_field.id + "chzn_o_" + option.array_index
classes = if option.selected and @is_multiple then [] else ["active-result"]
classes.push "result-selected" if option.selected
classes.push "group-option" if option.group_array_index?
'<li id="' + option.dom_id + '" class="' + classes.join(' ') + '">' + $("<div />").text(option.text).html() + '</li>'
else
""
results_update_field: ->
this.result_clear_highlight()
@result_single_selected = null
this.results_build()
result_do_highlight: (el) ->
if el.length
this.result_clear_highlight()
@result_highlight = el
@result_highlight.addClass "highlighted"
maxHeight = parseInt @search_results.css("maxHeight"), 10
visible_top = @search_results.scrollTop()
visible_bottom = maxHeight + visible_top
high_top = @result_highlight.position().top + @search_results.scrollTop()
high_bottom = high_top + @result_highlight.outerHeight()
if high_bottom >= visible_bottom
@search_results.scrollTop if (high_bottom - maxHeight) > 0 then (high_bottom - maxHeight) else 0
else if high_top < visible_top
@search_results.scrollTop high_top
result_clear_highlight: ->
@result_highlight.removeClass "highlighted" if @result_highlight
@result_highlight = null
results_toggle: ->
if @results_showing
this.results_hide()
else
this.results_show()
results_show: ->
if not @is_multiple
@selected_item.addClass "chzn-single-with-drop"
if @result_single_selected
this.result_do_highlight( @result_single_selected )
dd_top = if @is_multiple then @container.height() else (@container.height() - 1)
@dropdown.css {"top": dd_top + "px", "left":0}
@results_showing = true
@search_field.focus()
@search_field.val @search_field.val()
this.winnow_results()
results_hide: ->
@selected_item.removeClass "chzn-single-with-drop" unless @is_multiple
this.result_clear_highlight()
@dropdown.css {"left":"-9000px"}
@results_showing = false
set_tab_index: (el) ->
if @form_field_jq.attr "tabindex"
ti = @form_field_jq.attr "tabindex"
@form_field_jq.attr "tabindex", -1
if @is_multiple
@search_field.attr "tabindex", ti
else
@selected_item.attr "tabindex", ti
@search_field.attr "tabindex", -1
show_search_field_default: ->
if @is_multiple and @choices < 1 and not @active_field
@search_field.val(@default_text)
@search_field.addClass "default"
else
@search_field.val("")
@search_field.removeClass "default"
search_results_click: (evt) ->
target = if $(evt.target).hasClass "active-result" then $(evt.target) else $(evt.target).parents(".active-result").first()
if target.length
@result_highlight = target
this.result_select()
search_results_mouseover: (evt) ->
target = if $(evt.target).hasClass "active-result" then $(evt.target) else $(evt.target).parents(".active-result").first()
this.result_do_highlight( target ) if target
search_results_mouseout: (evt) ->
this.result_clear_highlight() if $(evt.target).hasClass "active-result" or $(evt.target).parents('.active-result').first()
choices_click: (evt) ->
evt.preventDefault()
if( @active_field and not($(evt.target).hasClass "search-choice" or $(evt.target).parents('.search-choice').first) and not @results_showing )
this.results_show()
choice_build: (item) ->
choice_id = @form_field.id + "_chzn_c_" + item.array_index
@choices += 1
@search_container.before '<li class="search-choice" id="' + choice_id + '"><span>' + item.text + '</span><a href="javascript:void(0)" class="search-choice-close" rel="' + item.array_index + '"></a></li>'
link = $('#' + choice_id).find("a").first()
link.click (evt) => this.choice_destroy_link_click(evt)
choice_destroy_link_click: (evt) ->
evt.preventDefault()
@pending_destroy_click = true
this.choice_destroy $(evt.target)
choice_destroy: (link) ->
@choices -= 1
this.show_search_field_default()
this.results_hide() if @is_multiple and @choices > 0 and @search_field.val().length < 1
this.result_deselect (link.attr "rel")
link.parents('li').first().remove()
result_select: ->
if @result_highlight
high = @result_highlight
high_id = high.attr "id"
this.result_clear_highlight()
high.addClass "result-selected"
if @is_multiple
this.result_deactivate high
else
@result_single_selected = high
position = high_id.substr(high_id.lastIndexOf("_") + 1 )
item = @results_data[position]
item.selected = true
@form_field.options[item.options_index].selected = true
if @is_multiple
this.choice_build item
else
@selected_item.find("span").first().text item.text
this.results_hide()
@search_field.val ""
@form_field_jq.trigger "change"
this.search_field_scale()
result_activate: (el) ->
el.addClass("active-result").show()
result_deactivate: (el) ->
el.removeClass("active-result").hide()
result_deselect: (pos) ->
result_data = @results_data[pos]
result_data.selected = false
@form_field.options[result_data.options_index].selected = false
result = $("#" + @form_field.id + "chzn_o_" + pos)
result.removeClass("result-selected").addClass("active-result").show()
this.result_clear_highlight()
this.winnow_results()
@form_field_jq.trigger "change"
this.search_field_scale()
results_search: (evt) ->
if @results_showing
this.winnow_results()
else
this.results_show()
winnow_results: ->
startTime = new Date()
this.no_results_clear()
results = 0
searchText = if @search_field.val() is @default_text then "" else $.trim @search_field.val()
regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i')
zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i')
for option in @results_data
if not option.disabled and not option.empty
if option.group
$('#' + option.dom_id).hide()
else if not (@is_multiple and option.selected)
found = false
result_id = option.dom_id
if regex.test option.text
found = true
results += 1
else if option.text.indexOf(" ") >= 0 or option.text.indexOf("[") == 0
#TODO: replace this substitution of /\[\]/ with a list of characters to skip.
parts = option.text.replace(/\[|\]/g, "").split(" ")
if parts.length
for part in parts
if regex.test part
found = true
results += 1
if found
if searchText.length
startpos = option.text.search zregex
text = option.text.substr(0, startpos + searchText.length) + '</em>' + option.text.substr(startpos + searchText.length)
text = text.substr(0, startpos) + '<em>' + text.substr(startpos)
else
text = option.text
$("#" + result_id).html text if $("#" + result_id).html != text
this.result_activate $("#" + result_id)
$("#" + @results_data[option.group_array_index].dom_id).show() if option.group_array_index?
else
this.result_clear_highlight() if @result_highlight and result_id is @result_highlight.attr 'id'
this.result_deactivate $("#" + result_id)
if results < 1 and searchText.length
this.no_results searchText
else
this.winnow_results_set_highlight()
winnow_results_clear: ->
@search_field.val ""
lis = @search_results.find("li")
for li in lis
li = $(li)
if li.hasClass "group-result"
li.show()
else if not @is_multiple or not li.hasClass "result-selected"
this.result_activate li
winnow_results_set_highlight: ->
if not @result_highlight
do_high = @search_results.find(".active-result").first()
if(do_high)
this.result_do_highlight do_high
no_results: (terms) ->
no_results_html = $('<li class="no-results">No results match "<span></span>"</li>')
no_results_html.find("span").first().text(terms)
@search_results.append no_results_html
no_results_clear: ->
@search_results.find(".no-results").remove()
keydown_arrow: ->
if not @result_highlight
first_active = @search_results.find("li.active-result").first()
this.result_do_highlight $(first_active) if first_active
else if @results_showing
next_sib = @result_highlight.nextAll("li.active-result").first()
this.result_do_highlight next_sib if next_sib
this.results_show() if not @results_showing
keyup_arrow: ->
if not @results_showing and not @is_multiple
this.results_show()
else if @result_highlight
prev_sibs = @result_highlight.prevAll("li.active-result")
if prev_sibs.length
this.result_do_highlight prev_sibs.first()
else
this.results_hide() if @choices > 0
this.result_clear_highlight()
keydown_backstroke: ->
if @pending_backstroke
this.choice_destroy @pending_backstroke.find("a").first()
this.clear_backstroke()
else
@pending_backstroke = @search_container.siblings("li.search-choice").last()
@pending_backstroke.addClass "search-choice-focus"
clear_backstroke: ->
@pending_backstroke.removeClass "search-choice-focus" if @pending_backstroke
@pending_backstroke = null
keyup_checker: (evt) ->
stroke = evt.which ? evt.keyCode
this.search_field_scale()
switch stroke
when 8
if @is_multiple and @backstroke_length < 1 and @choices > 0
this.keydown_backstroke()
else if not @pending_backstroke
this.result_clear_highlight()
this.results_search()
when 13
evt.preventDefault()
this.result_select() if this.results_showing
when 27
this.results_hide() if @results_showing
when 9, 38, 40, 16
# don't do anything on these keys
else this.results_search()
keydown_checker: (evt) ->
stroke = evt.which ? evt.keyCode
this.search_field_scale()
this.clear_backstroke() if stroke != 8 and this.pending_backstroke
switch stroke
when 8
@backstroke_length = this.search_field.val().length
break
when 9
@mouse_on_container = false
break
when 13
evt.preventDefault()
break
when 38
evt.preventDefault()
this.keyup_arrow()
break
when 40
this.keydown_arrow()
break
search_field_scale: ->
if @is_multiple
h = 0
w = 0
style_block = "position:absolute; left: -1000px; top: -1000px; display:none;"
styles = ['font-size','font-style', 'font-weight', 'font-family','line-height', 'text-transform', 'letter-spacing']
for style in styles
style_block += style + ":" + @search_field.css(style) + ";"
div = $('<div />', { 'style' : style_block })
div.text @search_field.val()
$('body').append div
w = div.width() + 25
div.remove()
if( w > @f_width-10 )
w = @f_width - 10
@search_field.css({'width': w + 'px'})
dd_top = @container.height()
@dropdown.css({"top": dd_top + "px"})
get_side_border_padding = (elmt) ->
side_border_padding = elmt.outerWidth() - elmt.width()
root.get_side_border_padding = get_side_border_padding
class SelectParser
constructor: ->
@options_index = 0
@parsed = []
add_node: (child) ->
if child.nodeName is "OPTGROUP"
this.add_group child
else
this.add_option child
add_group: (group) ->
group_position = @parsed.length
@parsed.push
array_index: group_position
group: true
label: group.label
children: 0
disabled: group.disabled
this.add_option( option, group_position, group.disabled ) for option in group.childNodes
add_option: (option, group_position, group_disabled) ->
if option.nodeName is "OPTION"
if option.text != ""
if group_position?
@parsed[group_position].children += 1
@parsed.push
array_index: @parsed.length
options_index: @options_index
value: option.value
text: option.text
selected: option.selected
disabled: if group_disabled is true then group_disabled else option.disabled
group_array_index: group_position
else
@parsed.push
array_index: @parsed.length
options_index: @options_index
empty: true
@options_index += 1
SelectParser.select_to_array = (select) ->
parser = new SelectParser()
parser.add_node( child ) for child in select.childNodes
parser.parsed
root.SelectParser = SelectParser

View File

@ -1,629 +0,0 @@
###
Chosen, a Select Box Enhancer for jQuery and Protoype
by Patrick Filler for Harvest, http://getharvest.com
Available for use under the MIT License, http://en.wikipedia.org/wiki/MIT_License
Copyright (c) 2011 by Harvest
###
root = exports ? this
class Chosen
constructor: (elmn) ->
this.set_default_values()
@form_field = elmn
@is_multiple = @form_field.multiple
@default_text_default = if @form_field.multiple then "Select Some Options" else "Select an Option"
this.set_up_html()
this.register_observers()
set_default_values: ->
@click_test_action = (evt) => this.test_active_click(evt)
@active_field = false
@mouse_on_container = false
@results_showing = false
@result_highlighted = null
@result_single_selected = null
@choices = 0
# HTML Templates
@single_temp = new Template('<a href="javascript:void(0)" class="chzn-single"><span>#{default}</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" /></div><ul class="chzn-results"></ul></div>')
@multi_temp = new Template('<ul class="chzn-choices"><li class="search-field"><input type="text" value="#{default}" class="default" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>')
@choice_temp = new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>')
@no_results_temp = new Template('<li class="no-results">No results match "<span>#{terms}</span>"</li>')
set_up_html: ->
@container_id = @form_field.id + "_chzn"
@f_width = if @form_field.getStyle("width") then parseInt @form_field.getStyle("width"), 10 else @form_field.getWidth()
container_props =
'id': @container_id
'class': 'chzn-container'
'style': 'width: ' + (@f_width) + 'px' #use parens around @f_width so coffeescript doesn't think + ' px' is a function parameter
@default_text = if @form_field.readAttribute 'title' then @form_field.readAttribute 'title' else @default_text_default
base_template = if @is_multiple then new Element('div', container_props).update( @multi_temp.evaluate({ "default": @default_text}) ) else new Element('div', container_props).update( @single_temp.evaluate({ "default":@default_text }) )
@form_field.hide().insert({ after: base_template })
@container = $(@container_id)
@container.addClassName( "chzn-container-" + (if @is_multiple then "multi" else "single") )
@dropdown = @container.down('div.chzn-drop')
dd_top = @container.getHeight()
dd_width = (@f_width - get_side_border_padding(@dropdown))
@dropdown.setStyle({"width": dd_width + "px", "top": dd_top + "px"})
@search_field = @container.down('input')
@search_results = @container.down('ul.chzn-results')
this.search_field_scale()
@search_no_results = @container.down('li.no-results')
if @is_multiple
@search_choices = @container.down('ul.chzn-choices')
@search_container = @container.down('li.search-field')
else
@search_container = @container.down('div.chzn-search')
@selected_item = @container.down('.chzn-single')
sf_width = dd_width - get_side_border_padding(@search_container) - get_side_border_padding(@search_field)
@search_field.setStyle( {"width" : sf_width + "px"} )
this.results_build()
this.set_tab_index()
register_observers: ->
@container.observe "click", (evt) => this.container_click(evt)
@container.observe "mouseenter", (evt) => this.mouse_enter(evt)
@container.observe "mouseleave", (evt) => this.mouse_leave(evt)
@search_results.observe "click", (evt) => this.search_results_click(evt)
@search_results.observe "mouseover", (evt) => this.search_results_mouseover(evt)
@search_results.observe "mouseout", (evt) => this.search_results_mouseout(evt)
@form_field.observe "liszt:updated", (evt) => this.results_update_field(evt)
@search_field.observe "blur", (evt) => this.input_blur(evt)
@search_field.observe "keyup", (evt) => this.keyup_checker(evt)
@search_field.observe "keydown", (evt) => this.keydown_checker(evt)
if @is_multiple
@search_choices.observe "click", (evt) => this.choices_click(evt)
@search_field.observe "focus", (evt) => this.input_focus(evt)
else
@selected_item.observe "focus", (evt) => this.activate_field(evt)
container_click: (evt) ->
if evt and evt.type is "click"
evt.stop()
if not @pending_destroy_click
if not @active_field
@search_field.clear() if @is_multiple
document.observe "click", @click_test_action
this.results_show()
else if not @is_multiple and evt and (evt.target is @selected_item || evt.target.up("a.chzn-single"))
this.results_toggle()
this.activate_field()
else
@pending_destroy_click = false
mouse_enter: -> @mouse_on_container = true
mouse_leave: -> @mouse_on_container = false
input_focus: (evt) ->
setTimeout this.container_click.bind(this), 50 unless @active_field
input_blur: (evt) ->
if not @mouse_on_container
@active_field = false
setTimeout this.blur_test.bind(this), 100
blur_test: (evt) ->
this.close_field() if not @active_field and @container.hasClassName("chzn-container-active")
close_field: ->
document.stopObserving "click", @click_test_action
if not @is_multiple
@selected_item.tabIndex = @search_field.tabIndex
@search_field.tabIndex = -1
@active_field = false
this.results_hide()
@container.removeClassName "chzn-container-active"
this.winnow_results_clear()
this.clear_backstroke()
this.show_search_field_default()
this.search_field_scale()
activate_field: ->
if not @is_multiple and not @active_field
@search_field.tabIndex = @selected_item.tabIndex
@selected_item.tabIndex = -1
@container.addClassName "chzn-container-active"
@active_field = true
@search_field.value = @search_field.value
@search_field.focus()
test_active_click: (evt) ->
if evt.target.up('#' + @container.id)
@active_field = true
else
this.close_field()
results_build: ->
startTime = new Date()
@parsing = true
@results_data = SelectParser.select_to_array @form_field
if @is_multiple and @choices > 0
@search_choices.select("li.search-choice").invoke("remove")
@choices = 0
else if not @is_multiple
@selected_item.down("span").update(@default_text)
content = ''
for data in @results_data
if data.group
content += this.result_add_group data
else if !data.empty
content += this.result_add_option data
if data.selected and @is_multiple
this.choice_build data
else if data.selected and not @is_multiple
@selected_item.down("span").update( data.text )
this.show_search_field_default()
this.search_field_scale()
@search_results.update content
@parsing = false
result_add_group: (group) ->
if not group.disabled
group.dom_id = @form_field.id + "chzn_g_" + group.array_index
'<li id="' + group.dom_id + '" class="group-result">' + group.label.escapeHTML() + '</li>'
else
""
result_add_option: (option) ->
if not option.disabled
option.dom_id = @form_field.id + "chzn_o_" + option.array_index
classes = if option.selected and @is_multiple then [] else ["active-result"]
classes.push "result-selected" if option.selected
classes.push "group-option" if option.group_array_index?
'<li id="' + option.dom_id + '" class="' + classes.join(' ') + '">' + option.text.escapeHTML() + '</li>'
else
""
results_update_field: ->
this.result_clear_highlight()
@result_single_selected = null
this.results_build()
result_do_highlight: (el) ->
this.result_clear_highlight()
@result_highlight = el
@result_highlight.addClassName "highlighted"
maxHeight = parseInt @search_results.getStyle('maxHeight'), 10
visible_top = @search_results.scrollTop
visible_bottom = maxHeight + visible_top
high_top = @result_highlight.positionedOffset().top
high_bottom = high_top + @result_highlight.getHeight()
if high_bottom >= visible_bottom
@search_results.scrollTop = if (high_bottom - maxHeight) > 0 then (high_bottom - maxHeight) else 0
else if high_top < visible_top
@search_results.scrollTop = high_top
result_clear_highlight: ->
@result_highlight.removeClassName('highlighted') if @result_highlight
@result_highlight = null
results_toggle: ->
if @results_showing
this.results_hide()
else
this.results_show()
results_show: ->
if not @is_multiple
@selected_item.addClassName('chzn-single-with-drop')
if @result_single_selected
this.result_do_highlight( @result_single_selected )
dd_top = if @is_multiple then @container.getHeight() else (@container.getHeight() - 1)
@dropdown.setStyle {"top": dd_top + "px", "left":0}
@results_showing = true
@search_field.focus()
@search_field.value = @search_field.value
this.winnow_results()
results_hide: ->
@selected_item.removeClassName('chzn-single-with-drop') unless @is_multiple
this.result_clear_highlight()
@dropdown.setStyle({"left":"-9000px"})
@results_showing = false
set_tab_index: (el) ->
if @form_field.tabIndex
ti = @form_field.tabIndex
@form_field.tabIndex = -1
if @is_multiple
@search_field.tabIndex = ti
else
@selected_item.tabIndex = ti
@search_field.tabIndex = -1
show_search_field_default: ->
if @is_multiple and @choices < 1 and not @active_field
@search_field.value = @default_text
@search_field.addClassName "default"
else
@search_field.value = ""
@search_field.removeClassName "default"
search_results_click: (evt) ->
target = if evt.target.hasClassName("active-result") then evt.target else evt.target.up(".active-result")
if target
@result_highlight = target
this.result_select()
search_results_mouseover: (evt) ->
target = if evt.target.hasClassName("active-result") then evt.target else evt.target.up(".active-result")
this.result_do_highlight( target ) if target
search_results_mouseout: (evt) ->
this.result_clear_highlight() if evt.target.hasClassName('active-result') or evt.target.up('.active-result')
choices_click: (evt) ->
evt.preventDefault()
if( @active_field and not(evt.target.hasClassName('search-choice') or evt.target.up('.search-choice')) and not @results_showing )
this.results_show()
choice_build: (item) ->
choice_id = @form_field.id + "_chzn_c_" + item.array_index
@choices += 1
@search_container.insert { before: @choice_temp.evaluate({"id":choice_id, "choice":item.text, "position":item.array_index}) }
link = $(choice_id).down('a')
link.observe "click", (evt) => this.choice_destroy_link_click(evt)
choice_destroy_link_click: (evt) ->
evt.preventDefault()
@pending_destroy_click = true
this.choice_destroy evt.target
choice_destroy: (link) ->
@choices -= 1
this.show_search_field_default()
this.results_hide() if @is_multiple and @choices > 0 and @search_field.value.length < 1
this.result_deselect link.readAttribute("rel")
link.up('li').remove()
result_select: ->
if @result_highlight
high = @result_highlight
this.result_clear_highlight()
high.addClassName("result-selected")
if @is_multiple
this.result_deactivate high
else
@result_single_selected = high
position = high.id.substr(high.id.lastIndexOf("_") + 1 )
item = @results_data[position]
item.selected = true
@form_field.options[item.options_index].selected = true
if @is_multiple
this.choice_build item
else
@selected_item.down("span").update(item.text)
this.results_hide()
@search_field.value = ""
@form_field.simulate("change") if typeof Event.simulate is 'function'
this.search_field_scale()
result_activate: (el) ->
el.addClassName("active-result").show()
result_deactivate: (el) ->
el.removeClassName("active-result").hide()
result_deselect: (pos) ->
result_data = @results_data[pos]
result_data.selected = false
@form_field.options[result_data.options_index].selected = false
result = $(@form_field.id + "chzn_o_" + pos)
result.removeClassName("result-selected").addClassName("active-result").show()
this.result_clear_highlight()
this.winnow_results()
@form_field.simulate("change") if typeof Event.simulate is 'function'
this.search_field_scale()
results_search: (evt) ->
if @results_showing
this.winnow_results()
else
this.results_show()
winnow_results: ->
startTime = new Date()
this.no_results_clear()
results = 0
searchText = if @search_field.value is @default_text then "" else @search_field.value.strip()
regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i')
zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i')
for option in @results_data
if not option.disabled and not option.empty
if option.group
$(option.dom_id).hide()
else if not (@is_multiple and option.selected)
found = false
result_id = option.dom_id
if regex.test option.text
found = true
results += 1
else if option.text.indexOf(" ") >= 0 or option.text.indexOf("[") == 0
#TODO: replace this substitution of /\[\]/ with a list of characters to skip.
parts = option.text.replace(/\[|\]/g, "").split(" ")
if parts.length
for part in parts
if regex.test part
found = true
results += 1
if found
if searchText.length
startpos = option.text.search zregex
text = option.text.substr(0, startpos + searchText.length) + '</em>' + option.text.substr(startpos + searchText.length)
text = text.substr(0, startpos) + '<em>' + text.substr(startpos)
else
text = option.text
$(result_id).update text if $(result_id).innerHTML != text
this.result_activate $(result_id)
$(@results_data[option.group_array_index].dom_id).show() if option.group_array_index?
else
this.result_clear_highlight() if $(result_id) is @result_highlight
this.result_deactivate $(result_id)
if results < 1 and searchText.length
this.no_results(searchText)
else
this.winnow_results_set_highlight()
winnow_results_clear: ->
@search_field.clear()
lis = @search_results.select("li")
for li in lis
if li.hasClassName("group-result")
li.show()
else if not @is_multiple or not li.hasClassName("result-selected")
this.result_activate li
winnow_results_set_highlight: ->
if not @result_highlight
do_high = @search_results.down(".active-result")
if(do_high)
this.result_do_highlight do_high
no_results: (terms) ->
@search_results.insert @no_results_temp.evaluate({"terms":terms.escapeHTML()})
no_results_clear: ->
nr = null
nr.remove() while nr = @search_results.down(".no-results")
keydown_arrow: ->
actives = @search_results.select("li.active-result")
if actives.length
if not @result_highlight
this.result_do_highlight actives.first()
else if @results_showing
sibs = @result_highlight.nextSiblings()
nexts = sibs.intersect(actives)
this.result_do_highlight nexts.first() if nexts.length
this.results_show() if not @results_showing
keyup_arrow: ->
if not @results_showing and not @is_multiple
this.results_show()
else if @result_highlight
sibs = @result_highlight.previousSiblings()
actives = @search_results.select("li.active-result")
prevs = sibs.intersect(actives)
if prevs.length
this.result_do_highlight prevs.first()
else
this.results_hide() if @choices > 0
this.result_clear_highlight()
keydown_backstroke: ->
if @pending_backstroke
this.choice_destroy @pending_backstroke.down("a")
this.clear_backstroke()
else
@pending_backstroke = @search_container.siblings("li.search-choice").last()
@pending_backstroke.addClassName("search-choice-focus")
clear_backstroke: ->
@pending_backstroke.removeClassName("search-choice-focus") if @pending_backstroke
@pending_backstroke = null
keyup_checker: (evt) ->
stroke = evt.which ? evt.keyCode
this.search_field_scale()
switch stroke
when 8
if @is_multiple and @backstroke_length < 1 and @choices > 0
this.keydown_backstroke()
else if not @pending_backstroke
this.result_clear_highlight()
this.results_search()
when 13
evt.preventDefault()
this.result_select() if this.results_showing
when 27
this.results_hide() if @results_showing
when 9, 38, 40, 16
# don't do anything on these keys
else this.results_search()
keydown_checker: (evt) ->
stroke = evt.which ? evt.keyCode
this.search_field_scale()
this.clear_backstroke() if stroke != 8 and this.pending_backstroke
switch stroke
when 8
@backstroke_length = this.search_field.value.length
when 9
@mouse_on_container = false
when 13
evt.preventDefault()
when 38
evt.preventDefault()
this.keyup_arrow()
when 40
this.keydown_arrow()
search_field_scale: ->
if @is_multiple
h = 0
w = 0
style_block = "position:absolute; left: -1000px; top: -1000px; display:none;"
styles = ['font-size','font-style', 'font-weight', 'font-family','line-height', 'text-transform', 'letter-spacing']
for style in styles
style_block += style + ":" + @search_field.getStyle(style) + ";"
div = new Element('div', { 'style' : style_block }).update(@search_field.value)
document.body.appendChild(div)
w = Element.measure(div, 'width') + 25
div.remove()
if( w > @f_width-10 )
w = @f_width - 10
@search_field.setStyle({'width': w + 'px'})
dd_top = @container.getHeight()
@dropdown.setStyle({"top": dd_top + "px"})
root.Chosen = Chosen
document.observe 'dom:loaded', (evt) ->
selects = $$(".chzn-select")
new Chosen select for select in selects
get_side_border_padding = (elmt) ->
layout = new Element.Layout(elmt)
side_border_padding = layout.get("border-left") + layout.get("border-right") + layout.get("padding-left") + layout.get("padding-right")
root.get_side_border_padding = get_side_border_padding
root = exports ? this
class SelectParser
constructor: ->
@options_index = 0
@parsed = []
add_node: (child) ->
if child.nodeName is "OPTGROUP"
this.add_group child
else
this.add_option child
add_group: (group) ->
group_position = @parsed.length
@parsed.push
array_index: group_position
group: true
label: group.label
children: 0
disabled: group.disabled
this.add_option( option, group_position, group.disabled ) for option in group.childNodes
add_option: (option, group_position, group_disabled) ->
if option.nodeName is "OPTION"
if option.text != ""
if group_position?
@parsed[group_position].children += 1
@parsed.push
array_index: @parsed.length
options_index: @options_index
value: option.value
text: option.text
selected: option.selected
disabled: if group_disabled is true then group_disabled else option.disabled
group_array_index: group_position
else
@parsed.push
array_index: @parsed.length
options_index: @options_index
empty: true
@options_index += 1
SelectParser.select_to_array = (select) ->
parser = new SelectParser()
parser.add_node( child ) for child in select.childNodes
parser.parsed
root.SelectParser = SelectParser

View File

@ -1,178 +0,0 @@
/* This is a very basic stylesheet for the date-picker. Feel free to create your own. */
/* The wrapper div */
.datePicker
{
position:absolute;
min-width:21em;
width:21em;
z-index:9999;
text-align:center;
font:900 0.8em/0.8em Verdana, Sans-Serif;
background:transparent;
}
/*
Quirksmode necessity
--------------------
If your HTML document renders in quirksmode (i.e. has no doctype declaration)
then uncomment the following CSS rule or the datePicker will be HUGE...
.datePicker th,
.datePicker td
{
font-size:11px;
}
*/
/* The iframe hack to cover selectlists in Internet Explorer <= v6 */
.iehack
{
position:absolute;
background:#fff;
z-index:9998;
padding:0;
border:0;
display:none;
}
/* The button created beside each input */
.date-picker-control
{
border:0 none;
padding:0;
margin-left:4px;
background:transparent url(../media/cal.gif) no-repeat 0 0;
width:16px;
height:16px;
margin-top:0;
vertical-align:top;
cursor:pointer;
}
/* The next & previous buttons */
.datePicker th button
{
display:inline;
padding:0;
margin:0;
color:#000;
height:1em;
width:0.8em;
line-height:0.8em;
border-width:0;
font-family: georgia, times new roman, palatino, times, bookman, serif;
background:transparent;
font-weight:bold;
cursor:pointer;
}
.datePicker th button:active,
.datePicker th button:focus,
.date-picker-control:active,
.date-picker-control:focus
{
outline:none;
}
.datePicker th button.prev-but
{
text-align:left;
}
.datePicker th button.next-but
{
text-align:right;
}
/* The mon, tue, wed etc day buttons */
.datePicker th button.fd-day-header
{
text-align:center;
margin:0 auto;
font:900 1em Verdana, Sans-Serif;
height:auto;
width:auto;
text-decoration:none;
line-height:1.4em;
}
/* The table */
.datePicker table
{
position:relative;
margin:0;
padding:0;
border:1px solid #ccc;
background:#fff url(../media/gradient-e5e5e5-ffffff.gif) repeat-x 0 -20px;
text-align:center;
width:100%;
}
.datePicker table tfoot td
{
background:#fff url(../media/gradient-e5e5e5-ffffff.gif) repeat-x 0 -40px;
}
/* Common TD & TH styling */
.datePicker table td
{
border: 1px solid #ccc;
padding:0.6em 0.5em 0.5em 0.5em;
/* Opera requires a line-height bigger than 1em in order to redraw properly */
line-height:1.2em;
cursor:default;
background:#fff url(../media/gradient-e5e5e5-ffffff.gif) repeat-x 0 -50px;
}
.datePicker table th
{
border:0 none;
padding:0;
line-height:1em;
font-weight:bold;
color:#222;
text-align:center;
}
/* The "mon tue wed etc" day header button styles */
.datePicker table th.date-picker-day-header
{
text-transform:lowercase;
cursor:help;
}
/* The "todays date" style */
.datePicker table td.date-picker-today
{
background:#fff url(../media/bullet2.gif) no-repeat 0 0;
color:rgb(100,100,100) !important;
}
/* The "selected date" style */
.datePicker table td.date-picker-selected-date
{
color:#333 !important;
border-color:#333 !important;
}
/* the "highlight days" style */
td.date-picker-highlight
{
color:#a86666;
}
/* The date "out of range" style */
.datePicker table td.out-of-range
{
color:#ccc !important;
font-style:oblique;
background:transparent !important;
cursor:default !important;
}
/* The "disabled days" style */
.datePicker table td.day-disabled
{
color:#aaa !important;
background:transparent !important;
cursor:default !important;
}
/* The "active cursor" style */
.datePicker table td#date-picker-hover
{
background:#fff url(../media/bg_header.jpg) no-repeat 0 0;
cursor:pointer;
border-color:rgb(100,130,170);
color:rgb(100,130,170);
}
/* Remove the images for Internet Explorer <= v6 using the "* html" hack */
* html .datePicker table td.date-picker-selected,
* html .datePicker table td.date-picker-hover,
* html .datePicker table td
{
background-image:none;
}

View File

@ -1,6 +0,0 @@
<html>
<head>
</head>
<body>
</body>
</html>

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 526 B

View File

@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,254 +0,0 @@
/*
Behaviour v1.1 by Ben Nolan, June 2005. Based largely on the work
of Simon Willison (see comments by Simon below).
Description:
Uses css selectors to apply javascript behaviours to enable
unobtrusive javascript in html documents.
Usage:
var myrules = {
'b.someclass' : function(element){
element.onclick = function(){
alert(this.innerHTML);
}
},
'#someid u' : function(element){
element.onmouseover = function(){
this.innerHTML = "BLAH!";
}
}
};
Behaviour.register(myrules);
// Call Behaviour.apply() to re-apply the rules (if you
// update the dom, etc).
License:
This file is entirely BSD licensed.
More information:
http://ripcord.co.nz/behaviour/
*/
var Behaviour = {
list : new Array,
register : function(sheet){
Behaviour.list.push(sheet);
},
start : function(){
Behaviour.addLoadEvent(function(){
Behaviour.apply();
});
},
apply : function(){
for (h=0;sheet=Behaviour.list[h];h++){
for (selector in sheet){
list = document.getElementsBySelector(selector);
if (!list){
continue;
}
for (i=0;element=list[i];i++){
sheet[selector](element);
}
}
}
},
addLoadEvent : function(func){
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
};
}
}
};
Behaviour.start();
/*
The following code is Copyright (C) Simon Willison 2004.
document.getElementsBySelector(selector)
- returns an array of element objects from the current document
matching the CSS selector. Selectors can contain element names,
class names and ids and can be nested. For example:
elements = document.getElementsBySelect('div#main p a.external')
Will return an array of all 'a' elements with 'external' in their
class attribute that are contained inside 'p' elements that are
contained inside the 'div' element which has id="main"
New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
See http://www.w3.org/TR/css3-selectors/#attribute-selectors
Version 0.4 - Simon Willison, March 25th 2003
-- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
-- Opera 7 fails
*/
function getAllChildren(e) {
// Returns all children of element. Workaround required for IE5/Windows. Ugh.
return e.all ? e.all : e.getElementsByTagName('*');
}
document.getElementsBySelector = function(selector) {
// Attempt to fail gracefully in lesser browsers
if (!document.getElementsByTagName) {
return new Array();
}
// Split selector in to tokens
var tokens = selector.split(' ');
var currentContext = new Array(document);
for (var i = 0; i < tokens.length; i++) {
token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');
if (token.indexOf('#') > -1) {
// Token is an ID selector
var bits = token.split('#');
var tagName = bits[0];
var id = bits[1];
var element = document.getElementById(id);
if (tagName && element.nodeName.toLowerCase() != tagName) {
// tag with that ID not found, return false
return new Array();
}
// Set currentContext to contain just this element
currentContext = new Array(element);
continue; // Skip to next token
}
if (token.indexOf('.') > -1) {
// Token contains a class selector
var bits = token.split('.');
var tagName = bits[0];
var className = bits[1];
if (!tagName) {
tagName = '*';
}
// Get elements matching tag, filter them for class selector
var found = new Array;
var foundCount = 0;
for (var h = 0; h < currentContext.length; h++) {
var elements;
if (tagName == '*') {
elements = getAllChildren(currentContext[h]);
} else {
elements = currentContext[h].getElementsByTagName(tagName);
}
for (var j = 0; j < elements.length; j++) {
found[foundCount++] = elements[j];
}
}
currentContext = new Array;
var currentContextIndex = 0;
for (var k = 0; k < found.length; k++) {
if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) {
currentContext[currentContextIndex++] = found[k];
}
}
continue; // Skip to next token
}
// Code to deal with attribute selectors
if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
var tagName = RegExp.$1;
var attrName = RegExp.$2;
var attrOperator = RegExp.$3;
var attrValue = RegExp.$4;
if (!tagName) {
tagName = '*';
}
// Grab all of the tagName elements within current context
var found = new Array;
var foundCount = 0;
for (var h = 0; h < currentContext.length; h++) {
var elements;
if (tagName == '*') {
elements = getAllChildren(currentContext[h]);
} else {
elements = currentContext[h].getElementsByTagName(tagName);
}
for (var j = 0; j < elements.length; j++) {
found[foundCount++] = elements[j];
}
}
currentContext = new Array;
var currentContextIndex = 0;
var checkFunction; // This function will be used to filter the elements
switch (attrOperator) {
case '=': // Equality
checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
break;
case '~': // Match one of space separated words
checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
break;
case '|': // Match start with value followed by optional hyphen
checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
break;
case '^': // Match starts with value
checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
break;
case '$': // Match ends with value - fails with "Warning" in Opera 7
checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
break;
case '*': // Match ends with value
checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
break;
default :
// Just test for existence of attribute
checkFunction = function(e) { return e.getAttribute(attrName); };
}
currentContext = new Array;
var currentContextIndex = 0;
for (var k = 0; k < found.length; k++) {
if (checkFunction(found[k])) {
currentContext[currentContextIndex++] = found[k];
}
}
// alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
continue; // Skip to next token
}
if (!currentContext[0]){
return;
}
// If we get here, token is JUST an element (not a class or ID selector)
tagName = token;
var found = new Array;
var foundCount = 0;
for (var h = 0; h < currentContext.length; h++) {
var elements = currentContext[h].getElementsByTagName(tagName);
for (var j = 0; j < elements.length; j++) {
found[foundCount++] = elements[j];
}
}
currentContext = found;
}
return currentContext;
}
/* That revolting regular expression explained
/^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/
\---/ \---/\-------------/ \-------/
| | | |
| | | The value
| | ~,|,^,$,* or =
| Attribute
Tag
*/

View File

@ -1,706 +0,0 @@
/** $Id: domLib.js 2321 2006-06-12 06:45:41Z dallen $ */
// {{{ license
/*
* Copyright 2002-2005 Dan Allen, Mojavelinux.com (dan.allen@mojavelinux.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// }}}
// {{{ intro
/**
* Title: DOM Library Core
* Version: 0.70
*
* Summary:
* A set of commonly used functions that make it easier to create javascript
* applications that rely on the DOM.
*
* Updated: 2005/05/17
*
* Maintainer: Dan Allen <dan.allen@mojavelinux.com>
* Maintainer: Jason Rust <jrust@rustyparts.com>
*
* License: Apache 2.0
*/
// }}}
// {{{ global constants (DO NOT EDIT)
// -- Browser Detection --
var domLib_userAgent = navigator.userAgent.toLowerCase();
var domLib_isMac = navigator.appVersion.indexOf('Mac') != -1;
var domLib_isWin = domLib_userAgent.indexOf('windows') != -1;
// NOTE: could use window.opera for detecting Opera
var domLib_isOpera = domLib_userAgent.indexOf('opera') != -1;
var domLib_isOpera7up = domLib_userAgent.match(/opera.(7|8)/i);
var domLib_isSafari = domLib_userAgent.indexOf('safari') != -1;
var domLib_isKonq = domLib_userAgent.indexOf('konqueror') != -1;
// Both konqueror and safari use the khtml rendering engine
var domLib_isKHTML = (domLib_isKonq || domLib_isSafari || domLib_userAgent.indexOf('khtml') != -1);
var domLib_isIE = (!domLib_isKHTML && !domLib_isOpera && (domLib_userAgent.indexOf('msie 5') != -1 || domLib_userAgent.indexOf('msie 6') != -1 || domLib_userAgent.indexOf('msie 7') != -1 || domLib_userAgent.indexOf('msie 8') != -1));
var domLib_isIE5up = domLib_isIE;
var domLib_isIE50 = (domLib_isIE && domLib_userAgent.indexOf('msie 5.0') != -1);
var domLib_isIE55 = (domLib_isIE && domLib_userAgent.indexOf('msie 5.5') != -1);
var domLib_isIE5 = (domLib_isIE50 || domLib_isIE55);
// safari and konq may use string "khtml, like gecko", so check for destinctive /
var domLib_isGecko = domLib_userAgent.indexOf('gecko/') != -1;
var domLib_isMacIE = (domLib_isIE && domLib_isMac);
var domLib_isIE55up = domLib_isIE5up && !domLib_isIE50 && !domLib_isMacIE;
var domLib_isIE6up = domLib_isIE55up && !domLib_isIE55;
// -- Browser Abilities --
var domLib_standardsMode = (document.compatMode && document.compatMode == 'CSS1Compat');
var domLib_useLibrary = (domLib_isOpera7up || domLib_isKHTML || domLib_isIE5up || domLib_isGecko || domLib_isMacIE || document.defaultView);
// fixed in Konq3.2
var domLib_hasBrokenTimeout = (domLib_isMacIE || (domLib_isKonq && domLib_userAgent.match(/konqueror\/3.([2-9])/) == null));
var domLib_canFade = (domLib_isGecko || domLib_isIE || domLib_isSafari || domLib_isOpera);
var domLib_canDrawOverSelect = (domLib_isMac || domLib_isOpera || domLib_isGecko);
var domLib_canDrawOverFlash = (domLib_isMac || domLib_isWin);
// -- Event Variables --
var domLib_eventTarget = domLib_isIE ? 'srcElement' : 'currentTarget';
var domLib_eventButton = domLib_isIE ? 'button' : 'which';
var domLib_eventTo = domLib_isIE ? 'toElement' : 'relatedTarget';
var domLib_stylePointer = domLib_isIE ? 'hand' : 'pointer';
// NOTE: a bug exists in Opera that prevents maxWidth from being set to 'none', so we make it huge
var domLib_styleNoMaxWidth = domLib_isOpera ? '10000px' : 'none';
var domLib_hidePosition = '-1000px';
var domLib_scrollbarWidth = 14;
var domLib_autoId = 1;
var domLib_zIndex = 1010;
// -- Detection --
var domLib_collisionElements;
var domLib_collisionsCached = false;
var domLib_timeoutStateId = 0;
var domLib_timeoutStates = new domTT_Hash();
// }}}
// {{{ DOM enhancements
if (!document.ELEMENT_NODE)
{
document.ELEMENT_NODE = 1;
document.ATTRIBUTE_NODE = 2;
document.TEXT_NODE = 3;
document.DOCUMENT_NODE = 9;
document.DOCUMENT_FRAGMENT_NODE = 11;
}
function domLib_clone(obj)
{
var copy = {};
for (var i in obj)
{
var value = obj[i];
try
{
if (value != null && typeof(value) == 'object' && value != window && !value.nodeType)
{
copy[i] = domLib_clone(value);
}
else
{
copy[i] = value;
}
}
catch(e)
{
copy[i] = value;
}
}
return copy;
}
// }}}
// {{{ class domTT_Hash()
function domTT_Hash()
{
this.length = 0;
this.numericLength = 0;
this.elementData = [];
for (var i = 0; i < arguments.length; i += 2)
{
if (typeof(arguments[i + 1]) != 'undefined')
{
this.elementData[arguments[i]] = arguments[i + 1];
this.length++;
if (arguments[i] == parseInt(arguments[i]))
{
this.numericLength++;
}
}
}
}
// using prototype as opposed to inner functions saves on memory
domTT_Hash.prototype.get = function(in_key)
{
if (typeof(this.elementData[in_key]) != 'undefined') {
return this.elementData[in_key];
}
return null;
};
domTT_Hash.prototype.set = function(in_key, in_value)
{
if (typeof(in_value) != 'undefined')
{
if (typeof(this.elementData[in_key]) == 'undefined')
{
this.length++;
if (in_key == parseInt(in_key))
{
this.numericLength++;
}
}
return this.elementData[in_key] = in_value;
}
return false;
};
domTT_Hash.prototype.remove = function(in_key)
{
var tmp_value;
if (typeof(this.elementData[in_key]) != 'undefined')
{
this.length--;
if (in_key == parseInt(in_key))
{
this.numericLength--;
}
tmp_value = this.elementData[in_key];
delete this.elementData[in_key];
}
return tmp_value;
};
domTT_Hash.prototype.size = function()
{
return this.length;
};
domTT_Hash.prototype.has = function(in_key)
{
return typeof(this.elementData[in_key]) != 'undefined';
};
domTT_Hash.prototype.find = function(in_obj)
{
for (var tmp_key in this.elementData)
{
if (this.elementData[tmp_key] == in_obj)
{
return tmp_key;
}
}
return null;
};
domTT_Hash.prototype.merge = function(in_hash)
{
for (var tmp_key in in_hash.elementData)
{
if (typeof(this.elementData[tmp_key]) == 'undefined')
{
this.length++;
if (tmp_key == parseInt(tmp_key))
{
this.numericLength++;
}
}
this.elementData[tmp_key] = in_hash.elementData[tmp_key];
}
};
domTT_Hash.prototype.compare = function(in_hash)
{
if (this.length != in_hash.length)
{
return false;
}
for (var tmp_key in this.elementData)
{
if (this.elementData[tmp_key] != in_hash.elementData[tmp_key])
{
return false;
}
}
return true;
};
// }}}
// {{{ domLib_isDescendantOf()
function domLib_isDescendantOf(in_object, in_ancestor, in_bannedTags)
{
if (in_object == null)
{
return false;
}
if (in_object == in_ancestor)
{
return true;
}
if (typeof(in_bannedTags) != 'undefined' &&
(',' + in_bannedTags.join(',') + ',').indexOf(',' + in_object.tagName + ',') != -1)
{
return false;
}
while (in_object != document.documentElement)
{
try
{
if ((tmp_object = in_object.offsetParent) && tmp_object == in_ancestor)
{
return true;
}
else if ((tmp_object = in_object.parentNode) == in_ancestor)
{
return true;
}
else
{
in_object = tmp_object;
}
}
// in case we get some wierd error, assume we left the building
catch(e)
{
return false;
}
}
return false;
}
// }}}
// {{{ domLib_detectCollisions()
/**
* For any given target element, determine if elements on the page
* are colliding with it that do not obey the rules of z-index.
*/
function domLib_detectCollisions(in_object, in_recover, in_useCache)
{
// the reason for the cache is that if the root menu is built before
// the page is done loading, then it might not find all the elements.
// so really the only time you don't use cache is when building the
// menu as part of the page load
if (!domLib_collisionsCached)
{
var tags = [];
if (!domLib_canDrawOverFlash)
{
tags[tags.length] = 'object';
}
if (!domLib_canDrawOverSelect)
{
tags[tags.length] = 'select';
}
domLib_collisionElements = domLib_getElementsByTagNames(tags, true);
domLib_collisionsCached = in_useCache;
}
// if we don't have a tip, then unhide selects
if (in_recover)
{
for (var cnt = 0; cnt < domLib_collisionElements.length; cnt++)
{
var thisElement = domLib_collisionElements[cnt];
if (!thisElement.hideList)
{
thisElement.hideList = new domTT_Hash();
}
thisElement.hideList.remove(in_object.id);
if (!thisElement.hideList.length)
{
domLib_collisionElements[cnt].style.visibility = 'visible';
if (domLib_isKonq)
{
domLib_collisionElements[cnt].style.display = '';
}
}
}
return;
}
else if (domLib_collisionElements.length == 0)
{
return;
}
// okay, we have a tip, so hunt and destroy
var objectOffsets = domLib_getOffsets(in_object);
for (var cnt = 0; cnt < domLib_collisionElements.length; cnt++)
{
var thisElement = domLib_collisionElements[cnt];
// if collision element is in active element, move on
// WARNING: is this too costly?
if (domLib_isDescendantOf(thisElement, in_object))
{
continue;
}
// konqueror only has trouble with multirow selects
if (domLib_isKonq &&
thisElement.tagName == 'SELECT' &&
(thisElement.size <= 1 && !thisElement.multiple))
{
continue;
}
if (!thisElement.hideList)
{
thisElement.hideList = new domTT_Hash();
}
var selectOffsets = domLib_getOffsets(thisElement);
var center2centerDistance = Math.sqrt(Math.pow(selectOffsets.get('leftCenter') - objectOffsets.get('leftCenter'), 2) + Math.pow(selectOffsets.get('topCenter') - objectOffsets.get('topCenter'), 2));
var radiusSum = selectOffsets.get('radius') + objectOffsets.get('radius');
// the encompassing circles are overlapping, get in for a closer look
if (center2centerDistance < radiusSum)
{
// tip is left of select
if ((objectOffsets.get('leftCenter') <= selectOffsets.get('leftCenter') && objectOffsets.get('right') < selectOffsets.get('left')) ||
// tip is right of select
(objectOffsets.get('leftCenter') > selectOffsets.get('leftCenter') && objectOffsets.get('left') > selectOffsets.get('right')) ||
// tip is above select
(objectOffsets.get('topCenter') <= selectOffsets.get('topCenter') && objectOffsets.get('bottom') < selectOffsets.get('top')) ||
// tip is below select
(objectOffsets.get('topCenter') > selectOffsets.get('topCenter') && objectOffsets.get('top') > selectOffsets.get('bottom')))
{
thisElement.hideList.remove(in_object.id);
if (!thisElement.hideList.length)
{
thisElement.style.visibility = 'visible';
if (domLib_isKonq)
{
thisElement.style.display = '';
}
}
}
else
{
thisElement.hideList.set(in_object.id, true);
thisElement.style.visibility = 'hidden';
if (domLib_isKonq)
{
thisElement.style.display = 'none';
}
}
}
}
}
// }}}
// {{{ domLib_getOffsets()
function domLib_getOffsets(in_object, in_preserveScroll)
{
if (typeof(in_preserveScroll) == 'undefined') {
in_preserveScroll = false;
}
var originalObject = in_object;
var originalWidth = in_object.offsetWidth;
var originalHeight = in_object.offsetHeight;
var offsetLeft = 0;
var offsetTop = 0;
while (in_object)
{
offsetLeft += in_object.offsetLeft;
offsetTop += in_object.offsetTop;
in_object = in_object.offsetParent;
// consider scroll offset of parent elements
if (in_object && !in_preserveScroll)
{
offsetLeft -= in_object.scrollLeft;
offsetTop -= in_object.scrollTop;
}
}
// MacIE misreports the offsets (even with margin: 0 in body{}), still not perfect
if (domLib_isMacIE) {
offsetLeft += 10;
offsetTop += 10;
}
return new domTT_Hash(
'left', offsetLeft,
'top', offsetTop,
'right', offsetLeft + originalWidth,
'bottom', offsetTop + originalHeight,
'leftCenter', offsetLeft + originalWidth/2,
'topCenter', offsetTop + originalHeight/2,
'radius', Math.max(originalWidth, originalHeight)
);
}
// }}}
// {{{ domLib_setTimeout()
function domLib_setTimeout(in_function, in_timeout, in_args)
{
if (typeof(in_args) == 'undefined')
{
in_args = [];
}
if (in_timeout == -1)
{
// timeout event is disabled
return 0;
}
else if (in_timeout == 0)
{
in_function(in_args);
return 0;
}
// must make a copy of the arguments so that we release the reference
var args = domLib_clone(in_args);
if (!domLib_hasBrokenTimeout)
{
return setTimeout(function() { in_function(args); }, in_timeout);
}
else
{
var id = domLib_timeoutStateId++;
var data = new domTT_Hash();
data.set('function', in_function);
data.set('args', args);
domLib_timeoutStates.set(id, data);
data.set('timeoutId', setTimeout('domLib_timeoutStates.get(' + id + ').get(\'function\')(domLib_timeoutStates.get(' + id + ').get(\'args\')); domLib_timeoutStates.remove(' + id + ');', in_timeout));
return id;
}
}
// }}}
// {{{ domLib_clearTimeout()
function domLib_clearTimeout(in_id)
{
if (!domLib_hasBrokenTimeout)
{
if (in_id > 0) {
clearTimeout(in_id);
}
}
else
{
if (domLib_timeoutStates.has(in_id))
{
clearTimeout(domLib_timeoutStates.get(in_id).get('timeoutId'));
domLib_timeoutStates.remove(in_id);
}
}
}
// }}}
// {{{ domLib_getEventPosition()
function domLib_getEventPosition(in_eventObj)
{
var eventPosition = new domTT_Hash('x', 0, 'y', 0, 'scrollX', 0, 'scrollY', 0);
// IE varies depending on standard compliance mode
if (domLib_isIE)
{
var doc = (domLib_standardsMode ? document.documentElement : document.body);
// NOTE: events may fire before the body has been loaded
if (doc)
{
eventPosition.set('x', in_eventObj.clientX + doc.scrollLeft);
eventPosition.set('y', in_eventObj.clientY + doc.scrollTop);
eventPosition.set('scrollX', doc.scrollLeft);
eventPosition.set('scrollY', doc.scrollTop);
}
}
else
{
eventPosition.set('x', in_eventObj.pageX);
eventPosition.set('y', in_eventObj.pageY);
eventPosition.set('scrollX', in_eventObj.pageX - in_eventObj.clientX);
eventPosition.set('scrollY', in_eventObj.pageY - in_eventObj.clientY);
}
return eventPosition;
}
// }}}
// {{{ domLib_cancelBubble()
function domLib_cancelBubble(in_event)
{
var eventObj = in_event ? in_event : window.event;
eventObj.cancelBubble = true;
}
// }}}
// {{{ domLib_getIFrameReference()
function domLib_getIFrameReference(in_frame)
{
if (domLib_isGecko || domLib_isIE)
{
return in_frame.frameElement;
}
else
{
// we could either do it this way or require an id on the frame
// equivalent to the name
var name = in_frame.name;
if (!name || !in_frame.parent)
{
return null;
}
var candidates = in_frame.parent.document.getElementsByTagName('iframe');
for (var i = 0; i < candidates.length; i++)
{
if (candidates[i].name == name)
{
return candidates[i];
}
}
return null;
}
}
// }}}
// {{{ domLib_getElementsByClass()
function domLib_getElementsByClass(in_class)
{
var elements = domLib_isIE5 ? document.all : document.getElementsByTagName('*');
var matches = [];
var cnt = 0;
for (var i = 0; i < elements.length; i++)
{
if ((" " + elements[i].className + " ").indexOf(" " + in_class + " ") != -1)
{
matches[cnt++] = elements[i];
}
}
return matches;
}
// }}}
// {{{ domLib_getElementsByTagNames()
function domLib_getElementsByTagNames(in_list, in_excludeHidden)
{
var elements = [];
for (var i = 0; i < in_list.length; i++)
{
var matches = document.getElementsByTagName(in_list[i]);
for (var j = 0; j < matches.length; j++)
{
// skip objects that have nested embeds, or else we get "flashing"
if (matches[j].tagName == 'OBJECT' && domLib_isGecko)
{
var kids = matches[j].childNodes;
var skip = false;
for (var k = 0; k < kids.length; k++)
{
if (kids[k].tagName == 'EMBED')
{
skip = true;
break;
}
}
if (skip) continue;
}
if (in_excludeHidden && domLib_getComputedStyle(matches[j], 'visibility') == 'hidden')
{
continue;
}
elements[elements.length] = matches[j];
}
}
return elements;
}
// }}}
// {{{ domLib_getComputedStyle()
function domLib_getComputedStyle(in_obj, in_property)
{
if (domLib_isIE)
{
var humpBackProp = in_property.replace(/-(.)/, function (a, b) { return b.toUpperCase(); });
return eval('in_obj.currentStyle.' + humpBackProp);
}
// getComputedStyle() is broken in konqueror, so let's go for the style object
else if (domLib_isKonq)
{
//var humpBackProp = in_property.replace(/-(.)/, function (a, b) { return b.toUpperCase(); });
return eval('in_obj.style.' + in_property);
}
else
{
return document.defaultView.getComputedStyle(in_obj, null).getPropertyValue(in_property);
}
}
// }}}
// {{{ makeTrue()
function makeTrue()
{
return true;
}
// }}}
// {{{ makeFalse()
function makeFalse()
{
return false;
}
// }}}

File diff suppressed because it is too large Load Diff

View File

@ -1,180 +0,0 @@
/** $Id$ */
// Title: Fadomatic
// Version: 1.2
// Homepage: http://chimpen.com/fadomatic
// Author: Philip McCarthy <fadomatic@chimpen.com>
// Fade interval in milliseconds
// Make this larger if you experience performance issues
Fadomatic.INTERVAL_MILLIS = 50;
// Creates a fader
// element - The element to fade
// speed - The speed to fade at, from 0.0 to 100.0
// initialOpacity (optional, default 100) - element's starting opacity, 0 to 100
// minOpacity (optional, default 0) - element's minimum opacity, 0 to 100
// maxOpacity (optional, default 0) - element's minimum opacity, 0 to 100
function Fadomatic (element, rate, initialOpacity, minOpacity, maxOpacity) {
this._element = element;
this._intervalId = null;
this._rate = rate;
this._isFadeOut = true;
// Set initial opacity and bounds
// NB use 99 instead of 100 to avoid flicker at start of fade
this._minOpacity = 0;
this._maxOpacity = 99;
this._opacity = 99;
if (typeof minOpacity != 'undefined') {
if (minOpacity < 0) {
this._minOpacity = 0;
} else if (minOpacity > 99) {
this._minOpacity = 99;
} else {
this._minOpacity = minOpacity;
}
}
if (typeof maxOpacity != 'undefined') {
if (maxOpacity < 0) {
this._maxOpacity = 0;
} else if (maxOpacity > 99) {
this._maxOpacity = 99;
} else {
this._maxOpacity = maxOpacity;
}
if (this._maxOpacity < this._minOpacity) {
this._maxOpacity = this._minOpacity;
}
}
if (typeof initialOpacity != 'undefined') {
if (initialOpacity > this._maxOpacity) {
this._opacity = this._maxOpacity;
} else if (initialOpacity < this._minOpacity) {
this._opacity = this._minOpacity;
} else {
this._opacity = initialOpacity;
}
}
// See if we're using W3C opacity, MSIE filter, or just
// toggling visiblity
if(typeof element.style.opacity != 'undefined') {
this._updateOpacity = this._updateOpacityW3c;
} else if(typeof element.style.filter != 'undefined') {
// If there's not an alpha filter on the element already,
// add one
if (element.style.filter.indexOf("alpha") == -1) {
// Attempt to preserve existing filters
var existingFilters="";
if (element.style.filter) {
existingFilters = element.style.filter+" ";
}
element.style.filter = existingFilters+"alpha(opacity="+this._opacity+")";
}
this._updateOpacity = this._updateOpacityMSIE;
} else {
this._updateOpacity = this._updateVisibility;
}
this._updateOpacity();
}
// Initiates a fade out
Fadomatic.prototype.fadeOut = function () {
this._isFadeOut = true;
this._beginFade();
};
// Initiates a fade in
Fadomatic.prototype.fadeIn = function () {
this._isFadeOut = false;
this._beginFade();
};
// Makes the element completely opaque, stops any fade in progress
Fadomatic.prototype.show = function () {
this.haltFade();
this._opacity = this._maxOpacity;
this._updateOpacity();
};
// Makes the element completely transparent, stops any fade in progress
Fadomatic.prototype.hide = function () {
this.haltFade();
this._opacity = 0;
this._updateOpacity();
};
// Halts any fade in progress
Fadomatic.prototype.haltFade = function () {
clearInterval(this._intervalId);
};
// Resumes a fade where it was halted
Fadomatic.prototype.resumeFade = function () {
this._beginFade();
};
// Pseudo-private members
Fadomatic.prototype._beginFade = function () {
this.haltFade();
var objref = this;
this._intervalId = setInterval(function() { objref._tickFade(); },Fadomatic.INTERVAL_MILLIS);
};
Fadomatic.prototype._tickFade = function () {
if (this._isFadeOut) {
this._opacity -= this._rate;
if (this._opacity < this._minOpacity) {
this._opacity = this._minOpacity;
this.haltFade();
}
} else {
this._opacity += this._rate;
if (this._opacity > this._maxOpacity ) {
this._opacity = this._maxOpacity;
this.haltFade();
}
}
this._updateOpacity();
};
Fadomatic.prototype._updateVisibility = function () {
if (this._opacity > 0) {
this._element.style.visibility = 'visible';
} else {
this._element.style.visibility = 'hidden';
}
};
Fadomatic.prototype._updateOpacityW3c = function () {
this._element.style.opacity = this._opacity/100;
this._updateVisibility();
};
Fadomatic.prototype._updateOpacityMSIE = function () {
this._element.filters.alpha.opacity = this._opacity;
this._updateVisibility();
};
Fadomatic.prototype._updateOpacity = null;

View File

@ -1,168 +0,0 @@
if (typeof getURL == 'undefined') {
getURL = function(url, callback) {
if (!url)
throw 'No URL for getURL';
try {
if (typeof callback.operationComplete == 'function')
callback = callback.operationComplete;
} catch (e) {}
if (typeof callback != 'function')
throw 'No callback function for getURL';
var http_request = null;
if (typeof XMLHttpRequest != 'undefined') {
http_request = new XMLHttpRequest();
}
else if (typeof ActiveXObject != 'undefined') {
try {
http_request = new ActiveXObject('Msxml2.XMLHTTP');
} catch (e) {
try {
http_request = new ActiveXObject('Microsoft.XMLHTTP');
} catch (e) {}
}
}
if (!http_request)
throw 'Both getURL and XMLHttpRequest are undefined';
http_request.onreadystatechange = function() {
if (http_request.readyState == 4) {
callback( { success : true,
content : http_request.responseText,
contentType : http_request.getResponseHeader("Content-Type") } );
}
};
http_request.open('GET', url, true);
http_request.send(null);
};
}
function outputrule(req) {
alert(req.content);
}
function fetch_new_rules() {
if(isPaused)
return;
if(isBusy)
return;
isBusy = true;
getURL('diag_logs_filter_dynamic.php?lastsawtime=' + lastsawtime, fetch_new_rules_callback);
}
function fetch_new_rules_callback(callback_data) {
if(isPaused)
return;
var data_split;
var new_data_to_add = Array();
var data = callback_data.content;
data_split = data.split("\n");
for(var x=0; x<data_split.length-1; x++) {
/* loop through rows */
row_split = data_split[x].split("||");
lastsawtime = row_split[9];
var tmp = format_log_line(row_split);
if ( !(tmp) ) continue;
new_data_to_add[new_data_to_add.length] = tmp;
}
update_table_rows(new_data_to_add);
isBusy = false;
}
function in_arrayi(needle, haystack) {
var i = haystack.length;
while (i--) {
if (haystack[i].toLowerCase() === needle.toLowerCase()) {
return true;
}
}
return false;
}
function update_table_rows(data) {
if(isPaused)
return;
var isIE = navigator.appName.indexOf('Microsoft') != -1;
var isSafari = navigator.userAgent.indexOf('Safari') != -1;
var isOpera = navigator.userAgent.indexOf('Opera') != -1;
var showanim = 1;
if (isIE) {
showanim = 0;
}
var startat = data.length - nentries;
if (startat < 0) {
startat = 0;
}
data = data.slice(startat, data.length);
var rows = jQuery('#filter-log-entries>tr');
// Number of rows to move by
var move = rows.length + data.length - nentries;
if (move < 0)
move = 0;
if (isReverse == false) {
for (var i = move; i < rows.length; i++) {
jQuery(rows[i - move]).html(jQuery(rows[i]).html());
}
var tbody = jQuery('#filter-log-entries');
for (var i = 0; i < data.length; i++) {
var rowIndex = rows.length - move + i;
if (rowIndex < rows.length) {
jQuery(rows[rowIndex]).html(data[i]);
} else {
jQuery(tbody).append('<tr>' + data[i] + '</tr>');
}
}
} else {
for (var i = rows.length - 1; i >= move; i--) {
jQuery(rows[i]).html(jQuery(rows[i - move]).html());
}
var tbody = jQuery('#filter-log-entries');
for (var i = 0; i < data.length; i++) {
var rowIndex = move - 1 - i;
if (rowIndex >= 0) {
jQuery(rows[rowIndex]).html(data[i]);
} else {
jQuery(tbody).prepend('<tr>' + data[i] + '</tr>');
}
}
}
// Much easier to go through each of the rows once they've all be added.
rows = jQuery('#filter-log-entries>tr');
for (var i = 0; i < rows.length; i++) {
rows[i].className = i % 2 == 0 ? 'listMRodd' : 'listMReven';
}
}
function toggle_pause() {
if(isPaused) {
isPaused = false;
fetch_new_rules();
} else {
isPaused = true;
}
}
/* start local AJAX engine */
if (typeof updateDelay != 'undefined') {
timer = setInterval('fetch_new_rules()', updateDelay);
}
function toggleListDescriptions(){
var ss = document.styleSheets;
for (var i=0; i<ss.length; i++) {
var rules = ss[i].cssRules || ss[i].rules;
for (var j=0; j<rules.length; j++) {
if (rules[j].selectorText === ".listMRDescriptionL" || rules[j].selectorText === ".listMRDescriptionR") {
rules[j].style.display = rules[j].style.display === "none" ? "table-cell" : "none";
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,336 +0,0 @@
/**
* An autosuggest textbox control.
* @class
* @scope public
*/
function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
oProvider /*:SuggestionProvider*/) {
/**
* The currently selected suggestions.
* @scope private
*/
this.cur /*:int*/ = -1;
/**
* The dropdown list layer.
* @scope private
*/
this.layer = null;
/**
* Suggestion provider for the autosuggest feature.
* @scope private.
*/
this.provider /*:SuggestionProvider*/ = oProvider;
/**
* The textbox to capture.
* @scope private
*/
this.textbox /*:HTMLInputElement*/ = oTextbox;
//initialize the control
this.init();
}
/**
* Autosuggests one or more suggestions for what the user has typed.
* If no suggestions are passed in, then no autosuggest occurs.
* @scope private
* @param aSuggestions An array of suggestion strings.
* @param bTypeAhead If the control should provide a type ahead suggestion.
*/
AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/,
bTypeAhead /*:boolean*/) {
//make sure there's at least one suggestion
if (aSuggestions.length > 0) {
if (bTypeAhead) {
this.typeAhead(aSuggestions[0]);
}
this.showSuggestions(aSuggestions);
} else {
this.hideSuggestions();
}
};
/**
* Creates the dropdown layer to display multiple suggestions.
* @scope private
*/
AutoSuggestControl.prototype.createDropDown = function () {
var oThis = this;
//create the layer and assign styles
this.layer = document.createElement("div");
this.layer.className = "suggestions";
this.layer.style.visibility = "hidden";
this.layer.style.width = this.textbox.offsetWidth;
//when the user clicks on the a suggestion, get the text (innerHTML)
//and place it into a textbox
this.layer.onmousedown =
this.layer.onmouseup =
this.layer.onmouseover = function (oEvent) {
oEvent = oEvent || window.event;
oTarget = oEvent.target || oEvent.srcElement;
if (oEvent.type == "mousedown") {
oThis.textbox.value = oTarget.firstChild.nodeValue;
oThis.hideSuggestions();
} else if (oEvent.type == "mouseover") {
oThis.highlightSuggestion(oTarget);
} else {
oThis.textbox.focus();
}
};
document.body.appendChild(this.layer);
};
/**
* Gets the left coordinate of the textbox.
* @scope private
* @return The left coordinate of the textbox in pixels.
*/
AutoSuggestControl.prototype.getLeft = function () /*:int*/ {
var oNode = this.textbox;
var iLeft = 0;
while(oNode.tagName != "BODY") {
iLeft += oNode.offsetLeft;
oNode = oNode.offsetParent;
}
return iLeft;
};
/**
* Gets the top coordinate of the textbox.
* @scope private
* @return The top coordinate of the textbox in pixels.
*/
AutoSuggestControl.prototype.getTop = function () /*:int*/ {
var oNode = this.textbox;
var iTop = 0;
while(oNode.tagName != "BODY") {
iTop += oNode.offsetTop;
oNode = oNode.offsetParent;
}
return iTop;
};
/**
* Handles three keydown events.
* @scope private
* @param oEvent The event object for the keydown event.
*/
AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) {
switch(oEvent.keyCode) {
case 38: //up arrow
this.previousSuggestion();
break;
case 40: //down arrow
this.nextSuggestion();
break;
case 13: //enter
this.hideSuggestions();
break;
}
};
/**
* Handles keyup events.
* @scope private
* @param oEvent The event object for the keyup event.
*/
AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) {
var iKeyCode = oEvent.keyCode;
//for backspace (8) and delete (46), shows suggestions without typeahead
if (iKeyCode == 8 || iKeyCode == 46) {
this.provider.requestSuggestions(this, false);
//make sure not to interfere with non-character keys
} else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) {
//ignore
} else {
//request suggestions from the suggestion provider with typeahead
this.provider.requestSuggestions(this, true);
}
};
/**
* Hides the suggestion dropdown.
* @scope private
*/
AutoSuggestControl.prototype.hideSuggestions = function () {
this.layer.style.visibility = "hidden";
};
/**
* Highlights the given node in the suggestions dropdown.
* @scope private
* @param oSuggestionNode The node representing a suggestion in the dropdown.
*/
AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) {
for (var i=0; i < this.layer.childNodes.length; i++) {
var oNode = this.layer.childNodes[i];
if (oNode == oSuggestionNode) {
oNode.className = "current";
} else if (oNode.className == "current") {
oNode.className = "";
}
}
};
/**
* Initializes the textbox with event handlers for
* auto suggest functionality.
* @scope private
*/
AutoSuggestControl.prototype.init = function () {
//save a reference to this object
var oThis = this;
//assign the onkeyup event handler
this.textbox.onkeyup = function (oEvent) {
//check for the proper location of the event object
if (!oEvent) {
oEvent = window.event;
}
//call the handleKeyUp() method with the event object
oThis.handleKeyUp(oEvent);
};
//assign onkeydown event handler
this.textbox.onkeydown = function (oEvent) {
//check for the proper location of the event object
if (!oEvent) {
oEvent = window.event;
}
//call the handleKeyDown() method with the event object
oThis.handleKeyDown(oEvent);
};
//assign onblur event handler (hides suggestions)
this.textbox.onblur = function () {
oThis.hideSuggestions();
};
//create the suggestions dropdown
this.createDropDown();
};
/**
* Highlights the next suggestion in the dropdown and
* places the suggestion into the textbox.
* @scope private
*/
AutoSuggestControl.prototype.nextSuggestion = function () {
var cSuggestionNodes = this.layer.childNodes;
if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) {
var oNode = cSuggestionNodes[++this.cur];
this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue;
}
};
/**
* Highlights the previous suggestion in the dropdown and
* places the suggestion into the textbox.
* @scope private
*/
AutoSuggestControl.prototype.previousSuggestion = function () {
var cSuggestionNodes = this.layer.childNodes;
if (cSuggestionNodes.length > 0 && this.cur > 0) {
var oNode = cSuggestionNodes[--this.cur];
this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue;
}
};
/**
* Selects a range of text in the textbox.
* @scope public
* @param iStart The start index (base 0) of the selection.
* @param iLength The number of characters to select.
*/
AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*:int*/) {
//use text ranges for Internet Explorer
if (this.textbox.createTextRange) {
var oRange = this.textbox.createTextRange();
oRange.moveStart("character", iStart);
oRange.moveEnd("character", iLength - this.textbox.value.length);
oRange.select();
//use setSelectionRange() for Mozilla
} else if (this.textbox.setSelectionRange) {
this.textbox.setSelectionRange(iStart, iLength);
}
//set focus back to the textbox
this.textbox.focus();
};
/**
* Builds the suggestion layer contents, moves it into position,
* and displays the layer.
* @scope private
* @param aSuggestions An array of suggestions for the control.
*/
AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) {
var oDiv = null;
this.layer.innerHTML = ""; //clear contents of the layer
for (var i=0; i < aSuggestions.length; i++) {
oDiv = document.createElement("div");
oDiv.appendChild(document.createTextNode(aSuggestions[i]));
this.layer.appendChild(oDiv);
}
this.layer.style.left = this.getLeft() + "px";
this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px";
this.layer.style.visibility = "visible";
};
/**
* Inserts a suggestion into the textbox, highlighting the
* suggested part of the text.
* @scope private
* @param sSuggestion The suggestion for the textbox.
*/
AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) {
//check for support of typeahead functionality
if (this.textbox.createTextRange || this.textbox.setSelectionRange){
var iLen = this.textbox.value.length;
this.textbox.value = sSuggestion;
this.selectRange(iLen, sSuggestion.length);
}
};

View File

@ -1,6 +0,0 @@
function kH(e) {
var pK = document.all? window.event.keyCode:e.which;
return pK != 13;
}
document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS);

View File

@ -1,203 +0,0 @@
//<![CDATA[
var portsenabled = 1;
var dstenabled = 1;
var showsource = 0;
function ext_change() {
if ((document.iform.srcbeginport.selectedIndex == 0) && portsenabled) {
document.iform.srcbeginport_cust.disabled = 0;
} else {
document.iform.srcbeginport_cust.value = "";
document.iform.srcbeginport_cust.disabled = 1;
}
if ((document.iform.srcendport.selectedIndex == 0) && portsenabled) {
document.iform.srcendport_cust.disabled = 0;
} else {
document.iform.srcendport_cust.value = "";
document.iform.srcendport_cust.disabled = 1;
}
if ((document.iform.dstbeginport.selectedIndex == 0) && portsenabled && dstenabled) {
document.iform.dstbeginport_cust.disabled = 0;
} else {
document.iform.dstbeginport_cust.value = "";
document.iform.dstbeginport_cust.disabled = 1;
}
if ((document.iform.dstendport.selectedIndex == 0) && portsenabled && dstenabled) {
document.iform.dstendport_cust.disabled = 0;
} else {
document.iform.dstendport_cust.value = "";
document.iform.dstendport_cust.disabled = 1;
}
if ((document.iform.localbeginport.selectedIndex == 0) && portsenabled) {
document.iform.localbeginport_cust.disabled = 0;
} else {
document.iform.localbeginport_cust.value = "";
document.iform.localbeginport_cust.disabled = 1;
}
if (!portsenabled) {
document.iform.srcbeginport.disabled = 1;
document.iform.srcendport.disabled = 1;
document.iform.dstbeginport.disabled = 1;
document.iform.dstendport.disabled = 1;
document.iform.localbeginport_cust.disabled = 1;
} else {
document.iform.srcbeginport.disabled = 0;
document.iform.srcendport.disabled = 0;
document.iform.localbeginport_cust.disabled = 0;
if( dstenabled ) {
document.iform.dstbeginport.disabled = 0;
document.iform.dstendport.disabled = 0;
}
}
}
function nordr_change() {
if (document.iform.nordr.checked) {
document.getElementById("localiptable").style.display = 'none';
document.getElementById("lprtr").style.display = 'none';
document.getElementById("assoctable").style.display = 'none';
} else {
document.getElementById("localiptable").style.display = '';
document.getElementById("lprtr").style.display = portsenabled ? '' : 'none';
document.getElementById("assoctable").style.display = '';
}
}
function show_source() {
if(portsenabled)
document.getElementById("sprtable").style.display = '';
document.getElementById("srctable").style.display = '';
document.getElementById("showadvancedboxsrc").style.display = 'none';
showsource = 1;
}
function check_for_aliases() {
/* if External port range is an alias, then disallow
* entry of Local port
*/
for(i=0; i<customarray.length; i++) {
if(document.iform.dstbeginport_cust.value == customarray[i]) {
document.iform.dstendport_cust.value = customarray[i];
document.iform.localbeginport_cust.value = customarray[i];
document.iform.dstendport_cust.disabled = 1;
document.iform.localbeginport.disabled = 1;
document.iform.localbeginport_cust.disabled = 1;
document.iform.dstendport_cust.disabled = 0;
document.iform.localbeginport.disabled = 0;
document.iform.localbeginport_cust.disabled = 0;
}
if(document.iform.dstbeginport.value == customarray[i]) {
document.iform.dstendport_cust.value = customarray[i];
document.iform.localbeginport_cust.value = customarray[i];
document.iform.dstendport_cust.disabled = 1;
document.iform.localbeginport.disabled = 1;
document.iform.localbeginport_cust.disabled = 1;
document.iform.dstendport_cust.disabled = 0;
document.iform.localbeginport.disabled = 0;
document.iform.localbeginport_cust.disabled = 0;
}
if(document.iform.dstendport_cust.value == customarray[i]) {
document.iform.dstendport_cust.value = customarray[i];
document.iform.localbeginport_cust.value = customarray[i];
document.iform.dstendport_cust.disabled = 1;
document.iform.localbeginport.disabled = 1;
document.iform.localbeginport_cust.disabled = 1;
document.iform.dstendport_cust.disabled = 0;
document.iform.localbeginport.disabled = 0;
document.iform.localbeginport_cust.disabled = 0;
}
if(document.iform.dstendport.value == customarray[i]) {
document.iform.dstendport_cust.value = customarray[i];
document.iform.localbeginport_cust.value = customarray[i];
document.iform.dstendport_cust.disabled = 1;
document.iform.localbeginport.disabled = 1;
document.iform.localbeginport_cust.disabled = 1;
document.iform.dstendport_cust.disabled = 0;
document.iform.localbeginport.disabled = 0;
document.iform.localbeginport_cust.disabled = 0;
}
}
}
function proto_change() {
if (document.iform.proto.selectedIndex >= 0 && document.iform.proto.selectedIndex <= 2) {
portsenabled = 1;
} else {
portsenabled = 0;
}
if (portsenabled) {
document.getElementById("sprtable").style.display = showsource == 1 ? '':'none';
document.getElementById("dprtr").style.display = '';
document.getElementById("lprtr").style.display = document.iform.nordr.checked ? 'none' : '';
} else {
document.getElementById("sprtable").style.display = 'none';
document.getElementById("dprtr").style.display = 'none';
document.getElementById("lprtr").style.display = 'none';
document.getElementById("dstbeginport").selectedIndex = 0;
document.getElementById("dstbeginport_cust").value = "";
document.getElementById("dstendport").selectedIndex = 0;
document.getElementById("dstendport_cust").value = "";
document.getElementById("localbeginport").selectedIndex = 0;
document.getElementById("localbeginport_cust").value = "";
}
}
function typesel_change() {
switch (document.iform.srctype.selectedIndex) {
case 1: /* single */
document.iform.src.disabled = 0;
document.iform.srcmask.value = "";
document.iform.srcmask.disabled = 1;
break;
case 2: /* network */
document.iform.src.disabled = 0;
document.iform.srcmask.disabled = 0;
break;
default:
document.iform.src.value = "";
document.iform.src.disabled = 1;
document.iform.srcmask.value = "";
document.iform.srcmask.disabled = 1;
break;
}
if( dstenabled )
{
switch (document.iform.dsttype.selectedIndex) {
case 1: /* single */
document.iform.dst.disabled = 0;
document.iform.dstmask.value = "";
document.iform.dstmask.disabled = 1;
break;
case 2: /* network */
document.iform.dst.disabled = 0;
document.iform.dstmask.disabled = 0;
break;
default:
document.iform.dst.value = "";
document.iform.dst.disabled = 1;
document.iform.dstmask.value = "";
document.iform.dstmask.disabled = 1;
break;
}
}
}
function src_rep_change() {
document.iform.srcendport.selectedIndex = document.iform.srcbeginport.selectedIndex;
}
function dst_rep_change() {
document.iform.dstendport.selectedIndex = document.iform.dstbeginport.selectedIndex;
}
function dst_change( iface, old_iface, old_dst ) {
if ( ( old_dst == "" ) || ( old_iface.concat("ip") == old_dst ) ) {
document.iform.dsttype.value = iface.concat("ip");
}
}
//]]>

View File

@ -1,33 +0,0 @@
/**
* Provides suggestions for state names (USA).
* @class
* @scope public
*/
function StateSuggestions(text) {
this.states = text;
}
/**
* Request suggestions for the given autosuggest control.
* @scope protected
* @param oAutoSuggestControl The autosuggest control to provide suggestions for.
*/
StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
bTypeAhead /*:boolean*/) {
var aSuggestions = [];
var sTextboxValue = oAutoSuggestControl.textbox.value;
if (sTextboxValue.length > 0){
//search for matching states
for (var i=0; i < this.states.length; i++) {
if (this.states[i].toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0) {
aSuggestions.push(this.states[i]);
}
}
}
//provide suggestions to the control
oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
};

View File

@ -1,336 +0,0 @@
/**
* An autosuggest textbox control.
* @class
* @scope public
*/
function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
oProvider /*:SuggestionProvider*/) {
/**
* The currently selected suggestions.
* @scope private
*/
this.cur /*:int*/ = -1;
/**
* The dropdown list layer.
* @scope private
*/
this.layer = null;
/**
* Suggestion provider for the autosuggest feature.
* @scope private.
*/
this.provider /*:SuggestionProvider*/ = oProvider;
/**
* The textbox to capture.
* @scope private
*/
this.textbox /*:HTMLInputElement*/ = oTextbox;
//initialize the control
this.init();
}
/**
* Autosuggests one or more suggestions for what the user has typed.
* If no suggestions are passed in, then no autosuggest occurs.
* @scope private
* @param aSuggestions An array of suggestion strings.
* @param bTypeAhead If the control should provide a type ahead suggestion.
*/
AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/,
bTypeAhead /*:boolean*/) {
//make sure there's at least one suggestion
if (aSuggestions.length > 0) {
if (bTypeAhead) {
this.typeAhead(aSuggestions[0]);
}
this.showSuggestions(aSuggestions);
} else {
this.hideSuggestions();
}
};
/**
* Creates the dropdown layer to display multiple suggestions.
* @scope private
*/
AutoSuggestControl.prototype.createDropDown = function () {
var oThis = this;
//create the layer and assign styles
this.layer = document.createElement("div");
this.layer.className = "suggestions";
this.layer.style.visibility = "hidden";
this.layer.style.width = this.textbox.offsetWidth;
//when the user clicks on the a suggestion, get the text (innerHTML)
//and place it into a textbox
this.layer.onmousedown =
this.layer.onmouseup =
this.layer.onmouseover = function (oEvent) {
oEvent = oEvent || window.event;
oTarget = oEvent.target || oEvent.srcElement;
if (oEvent.type == "mousedown") {
oThis.textbox.value = oTarget.firstChild.nodeValue;
oThis.hideSuggestions();
} else if (oEvent.type == "mouseover") {
oThis.highlightSuggestion(oTarget);
} else {
oThis.textbox.focus();
}
};
document.body.appendChild(this.layer);
};
/**
* Gets the left coordinate of the textbox.
* @scope private
* @return The left coordinate of the textbox in pixels.
*/
AutoSuggestControl.prototype.getLeft = function () /*:int*/ {
var oNode = this.textbox;
var iLeft = 0;
while(oNode.tagName != "BODY") {
iLeft += oNode.offsetLeft;
oNode = oNode.offsetParent;
}
return iLeft;
};
/**
* Gets the top coordinate of the textbox.
* @scope private
* @return The top coordinate of the textbox in pixels.
*/
AutoSuggestControl.prototype.getTop = function () /*:int*/ {
var oNode = this.textbox;
var iTop = 0;
while(oNode.tagName != "BODY") {
iTop += oNode.offsetTop;
oNode = oNode.offsetParent;
}
return iTop;
};
/**
* Handles three keydown events.
* @scope private
* @param oEvent The event object for the keydown event.
*/
AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) {
switch(oEvent.keyCode) {
case 38: //up arrow
this.previousSuggestion();
break;
case 40: //down arrow
this.nextSuggestion();
break;
case 13: //enter
this.hideSuggestions();
break;
}
};
/**
* Handles keyup events.
* @scope private
* @param oEvent The event object for the keyup event.
*/
AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) {
var iKeyCode = oEvent.keyCode;
//for backspace (8) and delete (46), shows suggestions without typeahead
if (iKeyCode == 8 || iKeyCode == 46) {
this.provider.requestSuggestions(this, false);
//make sure not to interfere with non-character keys
} else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) {
//ignore
} else {
//request suggestions from the suggestion provider with typeahead
this.provider.requestSuggestions(this, true);
}
};
/**
* Hides the suggestion dropdown.
* @scope private
*/
AutoSuggestControl.prototype.hideSuggestions = function () {
this.layer.style.visibility = "hidden";
};
/**
* Highlights the given node in the suggestions dropdown.
* @scope private
* @param oSuggestionNode The node representing a suggestion in the dropdown.
*/
AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) {
for (var i=0; i < this.layer.childNodes.length; i++) {
var oNode = this.layer.childNodes[i];
if (oNode == oSuggestionNode) {
oNode.className = "current";
} else if (oNode.className == "current") {
oNode.className = "";
}
}
};
/**
* Initializes the textbox with event handlers for
* auto suggest functionality.
* @scope private
*/
AutoSuggestControl.prototype.init = function () {
//save a reference to this object
var oThis = this;
//assign the onkeyup event handler
this.textbox.onkeyup = function (oEvent) {
//check for the proper location of the event object
if (!oEvent) {
oEvent = window.event;
}
//call the handleKeyUp() method with the event object
oThis.handleKeyUp(oEvent);
};
//assign onkeydown event handler
this.textbox.onkeydown = function (oEvent) {
//check for the proper location of the event object
if (!oEvent) {
oEvent = window.event;
}
//call the handleKeyDown() method with the event object
oThis.handleKeyDown(oEvent);
};
//assign onblur event handler (hides suggestions)
this.textbox.onblur = function () {
oThis.hideSuggestions();
};
//create the suggestions dropdown
this.createDropDown();
};
/**
* Highlights the next suggestion in the dropdown and
* places the suggestion into the textbox.
* @scope private
*/
AutoSuggestControl.prototype.nextSuggestion = function () {
var cSuggestionNodes = this.layer.childNodes;
if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) {
var oNode = cSuggestionNodes[++this.cur];
this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue;
}
};
/**
* Highlights the previous suggestion in the dropdown and
* places the suggestion into the textbox.
* @scope private
*/
AutoSuggestControl.prototype.previousSuggestion = function () {
var cSuggestionNodes = this.layer.childNodes;
if (cSuggestionNodes.length > 0 && this.cur > 0) {
var oNode = cSuggestionNodes[--this.cur];
this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue;
}
};
/**
* Selects a range of text in the textbox.
* @scope public
* @param iStart The start index (base 0) of the selection.
* @param iLength The number of characters to select.
*/
AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*:int*/) {
//use text ranges for Internet Explorer
if (this.textbox.createTextRange) {
var oRange = this.textbox.createTextRange();
oRange.moveStart("character", iStart);
oRange.moveEnd("character", iLength - this.textbox.value.length);
oRange.select();
//use setSelectionRange() for Mozilla
} else if (this.textbox.setSelectionRange) {
this.textbox.setSelectionRange(iStart, iLength);
}
//set focus back to the textbox
this.textbox.focus();
};
/**
* Builds the suggestion layer contents, moves it into position,
* and displays the layer.
* @scope private
* @param aSuggestions An array of suggestions for the control.
*/
AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) {
var oDiv = null;
this.layer.innerHTML = ""; //clear contents of the layer
for (var i=0; i < aSuggestions.length; i++) {
oDiv = document.createElement("div");
oDiv.appendChild(document.createTextNode(aSuggestions[i]));
this.layer.appendChild(oDiv);
}
this.layer.style.left = this.getLeft() + "px";
this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px";
this.layer.style.visibility = "visible";
};
/**
* Inserts a suggestion into the textbox, highlighting the
* suggested part of the text.
* @scope private
* @param sSuggestion The suggestion for the textbox.
*/
AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) {
//check for support of typeahead functionality
if (this.textbox.createTextRange || this.textbox.setSelectionRange){
var iLen = this.textbox.value.length;
this.textbox.value = sSuggestion;
this.selectRange(iLen, sSuggestion.length);
}
};

View File

@ -1,6 +0,0 @@
function kH(e) {
var pK = document.all? window.event.keyCode:e.which;
return pK != 13;
}
document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS);

View File

@ -1,237 +0,0 @@
//<![CDATA[
var portsenabled = 1;
var editenabled = 1;
function ext_change() {
if ((document.iform.srcbeginport.selectedIndex == 0) && portsenabled && editenabled) {
document.iform.srcbeginport_cust.disabled = 0;
} else {
if (editenabled)
document.iform.srcbeginport_cust.value = "";
document.iform.srcbeginport_cust.disabled = 1;
}
if ((document.iform.srcendport.selectedIndex == 0) && portsenabled && editenabled) {
document.iform.srcendport_cust.disabled = 0;
} else {
if (editenabled)
document.iform.srcendport_cust.value = "";
document.iform.srcendport_cust.disabled = 1;
}
if ((document.iform.dstbeginport.selectedIndex == 0) && portsenabled && editenabled) {
document.iform.dstbeginport_cust.disabled = 0;
} else {
if (editenabled)
document.iform.dstbeginport_cust.value = "";
document.iform.dstbeginport_cust.disabled = 1;
}
if ((document.iform.dstendport.selectedIndex == 0) && portsenabled && editenabled) {
document.iform.dstendport_cust.disabled = 0;
} else {
if (editenabled)
document.iform.dstendport_cust.value = "";
document.iform.dstendport_cust.disabled = 1;
}
if (!portsenabled) {
document.iform.srcbeginport.disabled = 1;
document.iform.srcendport.disabled = 1;
document.iform.dstbeginport.disabled = 1;
document.iform.dstendport.disabled = 1;
} else {
if( editenabled ) {
document.iform.srcbeginport.disabled = 0;
document.iform.srcendport.disabled = 0;
document.iform.dstbeginport.disabled = 0;
document.iform.dstendport.disabled = 0;
}
}
}
function show_source_port_range() {
if (portsenabled) {
document.getElementById("sprtable").style.display = '';
document.getElementById("showadvancedboxspr").style.display = 'none';
}
}
function typesel_change() {
if( editenabled ) {
switch (document.iform.srctype.selectedIndex) {
case 1: /* single */
document.iform.src.disabled = 0;
document.iform.srcmask.value = "";
document.iform.srcmask.disabled = 1;
break;
case 2: /* network */
document.iform.src.disabled = 0;
document.iform.srcmask.disabled = 0;
break;
default:
document.iform.src.value = "";
document.iform.src.disabled = 1;
document.iform.srcmask.value = "";
document.iform.srcmask.disabled = 1;
break;
}
switch (document.iform.dsttype.selectedIndex) {
case 1: /* single */
document.iform.dst.disabled = 0;
document.iform.dstmask.value = "";
document.iform.dstmask.disabled = 1;
break;
case 2: /* network */
document.iform.dst.disabled = 0;
document.iform.dstmask.disabled = 0;
break;
default:
document.iform.dst.value = "";
document.iform.dst.disabled = 1;
document.iform.dstmask.value = "";
document.iform.dstmask.disabled = 1;
break;
}
}
}
function proto_change() {
if (document.iform.proto.selectedIndex < 3) {
portsenabled = 1;
document.getElementById("tcpflags").style.display = '';
} else {
portsenabled = 0;
document.getElementById("tcpflags").style.display = 'none';
}
/* Disable OS knob if the proto is not TCP. */
if (document.iform.proto.selectedIndex < 1) {
document.forms[0].os.disabled = 0;
} else {
document.forms[0].os.disabled = 1;
}
if (document.iform.proto.selectedIndex == 3) {
document.iform.icmptype.disabled = 0;
document.iform.icmp6type.disabled = 0;
} else {
document.iform.icmptype.disabled = 1;
document.iform.icmp6type.disabled = 1;
}
ext_change();
if(document.iform.proto.selectedIndex == 3 || document.iform.proto.selectedIndex == 4) {
if(document.iform.ipprotocol.selectedIndex == 0) { // IPv4
document.getElementById("icmpbox").style.display = '';
document.getElementById("icmp6box").style.display = 'none';
} else if(document.iform.ipprotocol.selectedIndex == 1) { // IPv6
document.getElementById("icmpbox").style.display = 'none';
document.getElementById("icmp6box").style.display = '';
} else { // IPv4 + IPv6
document.getElementById("icmpbox").style.display = 'none';
document.getElementById("icmp6box").style.display = 'none';
}
} else {
document.getElementById("icmpbox").style.display = 'none';
document.getElementById("icmp6box").style.display = 'none';
}
if(document.iform.proto.selectedIndex >= 0 && document.iform.proto.selectedIndex <= 2) {
document.getElementById("dprtr").style.display = '';
if (editenabled) {
document.getElementById("showadvancedboxspr").style.display = 'table-row';
}
} else {
document.getElementById("sprtable").style.display = 'none';
document.getElementById("dprtr").style.display = 'none';
document.getElementById("showadvancedboxspr").style.display = 'none';
}
}
function show_aodiv() {
document.getElementById("aoadv").innerHTML='';
aodiv = document.getElementById('aodivmain');
aodiv.style.display = "block";
}
function show_dsdiv() {
document.getElementById("dsadv").innerHTML='';
dsdiv = document.getElementById('dsdivmain');
dsdiv.style.display = "block";
}
function show_advanced_noxmlrpc() {
document.getElementById("showadvnoxmlrpcsyncbox").innerHTML='';
aodiv = document.getElementById('shownoxmlrpcadv');
aodiv.style.display = "block";
}
function show_advanced_vlanprio() {
document.getElementById("showadvvlanpriobox").innerHTML='';
aodiv = document.getElementById('showvlanprioadv');
aodiv.style.display = "block";
}
function show_advanced_schedule() {
document.getElementById("showadvschedulebox").innerHTML='';
aodiv = document.getElementById('showscheduleadv');
aodiv.style.display = "block";
}
function show_advanced_gateway() {
document.getElementById("showadvgatewaybox").innerHTML='';
aodiv = document.getElementById('showgatewayadv');
aodiv.style.display = "block";
}
function show_advanced_sourceos() {
document.getElementById("showadvsourceosbox").innerHTML='';
aodiv = document.getElementById('showsourceosadv');
aodiv.style.display = "block";
}
function show_advanced_ackqueue() {
document.getElementById("showadvackqueuebox").innerHTML='';
aodiv = document.getElementById('showackqueueadv');
aodiv.style.display = "block";
}
function show_advanced_inout() {
document.getElementById("showadvinoutbox").innerHTML='';
aodiv = document.getElementById('showinoutadv');
aodiv.style.display = "block";
}
function show_advanced_state() {
document.getElementById("showadvstatebox").innerHTML='';
aodiv = document.getElementById('showstateadv');
aodiv.style.display = "block";
}
function show_advanced_tcpflags() {
document.getElementById("showtcpflagsbox").innerHTML='';
aodiv = document.getElementById('showtcpflagsadv');
aodiv.style.display = "block";
}
function show_advanced_layer7() {
document.getElementById("showadvlayer7box").innerHTML='';
aodiv = document.getElementById('showlayer7adv');
aodiv.style.display = "block";
}
function src_rep_change() {
document.iform.srcendport.selectedIndex = document.iform.srcbeginport.selectedIndex;
}
function dst_rep_change() {
document.iform.dstendport.selectedIndex = document.iform.dstbeginport.selectedIndex;
}
function tcpflags_anyclick(obj) {
if (obj.checked) {
document.getElementById('tcpheader').style.display= 'none';
} else {
document.getElementById('tcpheader').style.display= "";
}
}
//]]>

View File

@ -1,33 +0,0 @@
/**
* Provides suggestions for state names (USA).
* @class
* @scope public
*/
function StateSuggestions(text) {
this.states = text;
}
/**
* Request suggestions for the given autosuggest control.
* @scope protected
* @param oAutoSuggestControl The autosuggest control to provide suggestions for.
*/
StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
bTypeAhead /*:boolean*/) {
var aSuggestions = [];
var sTextboxValue = oAutoSuggestControl.textbox.value;
if (sTextboxValue.length > 0){
//search for matching states
for (var i=0; i < this.states.length; i++) {
if (this.states[i].toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0) {
aSuggestions.push(this.states[i]);
}
}
}
//provide suggestions to the control
oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
};

View File

@ -1,336 +0,0 @@
/**
* An autosuggest textbox control.
* @class
* @scope public
*/
function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
oProvider /*:SuggestionProvider*/) {
/**
* The currently selected suggestions.
* @scope private
*/
this.cur /*:int*/ = -1;
/**
* The dropdown list layer.
* @scope private
*/
this.layer = null;
/**
* Suggestion provider for the autosuggest feature.
* @scope private.
*/
this.provider /*:SuggestionProvider*/ = oProvider;
/**
* The textbox to capture.
* @scope private
*/
this.textbox /*:HTMLInputElement*/ = oTextbox;
//initialize the control
this.init();
}
/**
* Autosuggests one or more suggestions for what the user has typed.
* If no suggestions are passed in, then no autosuggest occurs.
* @scope private
* @param aSuggestions An array of suggestion strings.
* @param bTypeAhead If the control should provide a type ahead suggestion.
*/
AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/,
bTypeAhead /*:boolean*/) {
//make sure there's at least one suggestion
if (aSuggestions.length > 0) {
if (bTypeAhead) {
this.typeAhead(aSuggestions[0]);
}
this.showSuggestions(aSuggestions);
} else {
this.hideSuggestions();
}
};
/**
* Creates the dropdown layer to display multiple suggestions.
* @scope private
*/
AutoSuggestControl.prototype.createDropDown = function () {
var oThis = this;
//create the layer and assign styles
this.layer = document.createElement("div");
this.layer.className = "suggestions";
this.layer.style.visibility = "hidden";
this.layer.style.width = this.textbox.offsetWidth;
//when the user clicks on the a suggestion, get the text (innerHTML)
//and place it into a textbox
this.layer.onmousedown =
this.layer.onmouseup =
this.layer.onmouseover = function (oEvent) {
oEvent = oEvent || window.event;
oTarget = oEvent.target || oEvent.srcElement;
if (oEvent.type == "mousedown") {
oThis.textbox.value = oTarget.firstChild.nodeValue;
oThis.hideSuggestions();
} else if (oEvent.type == "mouseover") {
oThis.highlightSuggestion(oTarget);
} else {
oThis.textbox.focus();
}
};
document.body.appendChild(this.layer);
};
/**
* Gets the left coordinate of the textbox.
* @scope private
* @return The left coordinate of the textbox in pixels.
*/
AutoSuggestControl.prototype.getLeft = function () /*:int*/ {
var oNode = this.textbox;
var iLeft = 0;
while(oNode.tagName != "BODY") {
iLeft += oNode.offsetLeft;
oNode = oNode.offsetParent;
}
return iLeft;
};
/**
* Gets the top coordinate of the textbox.
* @scope private
* @return The top coordinate of the textbox in pixels.
*/
AutoSuggestControl.prototype.getTop = function () /*:int*/ {
var oNode = this.textbox;
var iTop = 0;
while(oNode.tagName != "BODY") {
iTop += oNode.offsetTop;
oNode = oNode.offsetParent;
}
return iTop;
};
/**
* Handles three keydown events.
* @scope private
* @param oEvent The event object for the keydown event.
*/
AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) {
switch(oEvent.keyCode) {
case 38: //up arrow
this.previousSuggestion();
break;
case 40: //down arrow
this.nextSuggestion();
break;
case 13: //enter
this.hideSuggestions();
break;
}
};
/**
* Handles keyup events.
* @scope private
* @param oEvent The event object for the keyup event.
*/
AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) {
var iKeyCode = oEvent.keyCode;
//for backspace (8) and delete (46), shows suggestions without typeahead
if (iKeyCode == 8 || iKeyCode == 46) {
this.provider.requestSuggestions(this, false);
//make sure not to interfere with non-character keys
} else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) {
//ignore
} else {
//request suggestions from the suggestion provider with typeahead
this.provider.requestSuggestions(this, true);
}
};
/**
* Hides the suggestion dropdown.
* @scope private
*/
AutoSuggestControl.prototype.hideSuggestions = function () {
this.layer.style.visibility = "hidden";
};
/**
* Highlights the given node in the suggestions dropdown.
* @scope private
* @param oSuggestionNode The node representing a suggestion in the dropdown.
*/
AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) {
for (var i=0; i < this.layer.childNodes.length; i++) {
var oNode = this.layer.childNodes[i];
if (oNode == oSuggestionNode) {
oNode.className = "current";
} else if (oNode.className == "current") {
oNode.className = "";
}
}
};
/**
* Initializes the textbox with event handlers for
* auto suggest functionality.
* @scope private
*/
AutoSuggestControl.prototype.init = function () {
//save a reference to this object
var oThis = this;
//assign the onkeyup event handler
this.textbox.onkeyup = function (oEvent) {
//check for the proper location of the event object
if (!oEvent) {
oEvent = window.event;
}
//call the handleKeyUp() method with the event object
oThis.handleKeyUp(oEvent);
};
//assign onkeydown event handler
this.textbox.onkeydown = function (oEvent) {
//check for the proper location of the event object
if (!oEvent) {
oEvent = window.event;
}
//call the handleKeyDown() method with the event object
oThis.handleKeyDown(oEvent);
};
//assign onblur event handler (hides suggestions)
this.textbox.onblur = function () {
oThis.hideSuggestions();
};
//create the suggestions dropdown
this.createDropDown();
};
/**
* Highlights the next suggestion in the dropdown and
* places the suggestion into the textbox.
* @scope private
*/
AutoSuggestControl.prototype.nextSuggestion = function () {
var cSuggestionNodes = this.layer.childNodes;
if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) {
var oNode = cSuggestionNodes[++this.cur];
this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue;
}
};
/**
* Highlights the previous suggestion in the dropdown and
* places the suggestion into the textbox.
* @scope private
*/
AutoSuggestControl.prototype.previousSuggestion = function () {
var cSuggestionNodes = this.layer.childNodes;
if (cSuggestionNodes.length > 0 && this.cur > 0) {
var oNode = cSuggestionNodes[--this.cur];
this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue;
}
};
/**
* Selects a range of text in the textbox.
* @scope public
* @param iStart The start index (base 0) of the selection.
* @param iLength The number of characters to select.
*/
AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*:int*/) {
//use text ranges for Internet Explorer
if (this.textbox.createTextRange) {
var oRange = this.textbox.createTextRange();
oRange.moveStart("character", iStart);
oRange.moveEnd("character", iLength - this.textbox.value.length);
oRange.select();
//use setSelectionRange() for Mozilla
} else if (this.textbox.setSelectionRange) {
this.textbox.setSelectionRange(iStart, iLength);
}
//set focus back to the textbox
this.textbox.focus();
};
/**
* Builds the suggestion layer contents, moves it into position,
* and displays the layer.
* @scope private
* @param aSuggestions An array of suggestions for the control.
*/
AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) {
var oDiv = null;
this.layer.innerHTML = ""; //clear contents of the layer
for (var i=0; i < aSuggestions.length; i++) {
oDiv = document.createElement("div");
oDiv.appendChild(document.createTextNode(aSuggestions[i]));
this.layer.appendChild(oDiv);
}
this.layer.style.left = this.getLeft() + "px";
this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px";
this.layer.style.visibility = "visible";
};
/**
* Inserts a suggestion into the textbox, highlighting the
* suggested part of the text.
* @scope private
* @param sSuggestion The suggestion for the textbox.
*/
AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) {
//check for support of typeahead functionality
if (this.textbox.createTextRange || this.textbox.setSelectionRange){
var iLen = this.textbox.value.length;
this.textbox.value = sSuggestion;
this.selectRange(iLen, sSuggestion.length);
}
};

View File

@ -1,6 +0,0 @@
function kH(e) {
var pK = document.all? window.event.keyCode:e.which;
return pK != 13;
}
document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS);

View File

@ -1,37 +0,0 @@
//<![CDATA[
function ext_change() {
if (document.iform.beginport.selectedIndex == 0) {
document.iform.beginport_cust.disabled = 0;
} else {
document.iform.beginport_cust.value = "";
document.iform.beginport_cust.disabled = 1;
}
if (document.iform.endport.selectedIndex == 0) {
document.iform.endport_cust.disabled = 0;
} else {
document.iform.endport_cust.value = "";
document.iform.endport_cust.disabled = 1;
}
if (document.iform.localbeginport.selectedIndex == 0) {
document.iform.localbeginport_cust.disabled = 0;
} else {
document.iform.localbeginport_cust.value = "";
document.iform.localbeginport_cust.disabled = 1;
}
};
function ext_rep_change() {
document.iform.endport.selectedIndex = document.iform.beginport.selectedIndex;
document.iform.localbeginport.selectedIndex = document.iform.beginport.selectedIndex;
}
window.onload = function () {
var oTextbox1 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
var oTextbox2 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
var oTextbox3 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
var oTextbox1 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
var oTextbox2 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
var oTextbox3 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
};
//]]>

View File

@ -1,33 +0,0 @@
/**
* Provides suggestions for state names (USA).
* @class
* @scope public
*/
function StateSuggestions(text) {
this.states = text;
}
/**
* Request suggestions for the given autosuggest control.
* @scope protected
* @param oAutoSuggestControl The autosuggest control to provide suggestions for.
*/
StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
bTypeAhead /*:boolean*/) {
var aSuggestions = [];
var sTextboxValue = oAutoSuggestControl.textbox.value;
if (sTextboxValue.length > 0){
//search for matching states
for (var i=0; i < this.states.length; i++) {
if (this.states[i].toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0) {
aSuggestions.push(this.states[i]);
}
}
}
//provide suggestions to the control
oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
};

View File

@ -1,43 +0,0 @@
var AjaxQueue = {
batchSize: 1, //No.of simultaneous AJAX requests allowed, Default : 1
urlQueue: [], //Request URLs will be pushed into this array
elementsQueue: [], //Element IDs of elements to be updated on completion of a request
optionsQueue: [], //Request options will be pushed into this array
currentRequest: null,
setBatchSize: function(bSize){ //Method to set a different batch size. Recommended: Set batchSize before making requests
this.batchSize = bSize;
},
push: function(url, options, elementID){ //Push the request in the queue. elementID is optional and required only for Ajax requests that updates the element
this.urlQueue.push(url);
this.optionsQueue.push(options);
if(elementID!=null){
this.elementsQueue.push(elementID);
} else {
this.elementsQueue.push("NOTSPECIFIED");
}
this._processNext();
},
_processNext: function() { // Method for processing the requests in the queue. Private method. Don't call it explicitly
if(this.currentRequest == null && this.urlQueue.length > 0) // Check if the currently processing request count is less than batch size
{
// Call jQuery.ajax on the first item in the queue and remove it from the queue
AjaxQueue.currentRequest = jQuery.ajax(AjaxQueue.urlQueue.shift(), AjaxQueue.optionsQueue.shift());
AjaxQueue.currentRequest.complete( function() {
//Call AjaxQueue._processNext on completion ( success / failure) of this AJAX request.
AjaxQueue.currentRequest = null;
AjaxQueue._processNext();
});
if(this.elementsQueue[0]=="NOTSPECIFIED") { //Check if an elementID was specified
// If no ElementID was specified remove the first item from the queue
var junk = AjaxQueue.elementsQueue.shift();
} else {
// If ElementID was specified update the first item in the queue and remove it from the queue
AjaxQueue.currentRequest.success( function(data) {
jQuery(AjaxQueue.elementsQueue.shift()).html(data);
});
}
}
}
};

View File

@ -1,196 +0,0 @@
/* Most widgets update their backend data every 10 seconds. 11 seconds
* will ensure that we update the GUI right after the stats are updated.
* Seconds * 1000 = value
*/
var Seconds = 11;
var update_interval = (Math.abs(Math.ceil(Seconds))-1)*1000 + 990;
function updateMeters() {
url = '/getstats.php';
jQuery.ajax(url, {
type: 'get',
success: function(data) {
response = data || "";
if (response != "")
stats(data);
}
});
setTimer();
}
function setTimer() {
timeout = window.setTimeout('updateMeters()', update_interval);
}
function stats(x) {
var values = x.split("|");
if (jQuery.each(values,function(key,value){
if (value == 'undefined' || value == null)
return true;
else
return false;
}))
updateUptime(values[2]);
updateDateTime(values[5]);
updateCPU(values[0]);
updateMemory(values[1]);
updateState(values[3]);
updateTemp(values[4]);
updateInterfaceStats(values[6]);
updateInterfaces(values[7]);
updateGatewayStats(values[8]);
updateCpuFreq(values[9]);
updateLoadAverage(values[10]);
updateMbuf(values[11]);
updateMbufMeter(values[12]);
updateStateMeter(values[13]);
}
function updateMemory(x) {
if(jQuery('#memusagemeter'))
jQuery("#memusagemeter").html(x + '%');
if(jQuery('#memUsagePB'))
jQuery('#memUsagePB').progressbar( { value: parseInt(x) } );
}
function updateMbuf(x) {
if(jQuery('#mbuf'))
jQuery("#mbuf").html(x);
}
function updateMbufMeter(x) {
if(jQuery('#mbufusagemeter'))
jQuery("#mbufusagemeter").html(x + '%');
if(jQuery('#mbufPB'))
jQuery('#mbufPB').progressbar( { value: parseInt(x) } );
}
function updateCPU(x) {
if(jQuery('#cpumeter'))
jQuery("#cpumeter").html(x + '%');
if(jQuery('#cpuPB'))
jQuery('#cpuPB').progressbar( { value: parseInt(x) } );
/* Load CPU Graph widget if enabled */
if(widgetActive('cpu_graphs')) {
GraphValue(graph[0], x);
}
}
function updateTemp(x) {
if(jQuery("#tempmeter"))
jQuery("#tempmeter").html(x + '\u00B0' + 'C');
if(jQuery('#tempPB'))
jQuery("#tempPB").progressbar( { value: parseInt(x) } );
}
function updateDateTime(x) {
if(jQuery('#datetime'))
jQuery("#datetime").html(x);
}
function updateUptime(x) {
if(jQuery('#uptime'))
jQuery("#uptime").html(x);
}
function updateState(x) {
if(jQuery('#pfstate'))
jQuery("#pfstate").html(x);
}
function updateStateMeter(x) {
if(jQuery('#pfstateusagemeter'))
jQuery("#pfstateusagemeter").html(x + '%');
if(jQuery('#statePB'))
jQuery('#statePB').progressbar( { value: parseInt(x) } );
}
function updateGatewayStats(x){
if (widgetActive("gateways")){
gateways_split = x.split(",");
for (var y=0; y<gateways_split.length; y++){
gateways_field_split = gateways_split[y].split("^");
if(jQuery('#gateway' + (y + 1))) {
jQuery('#gateway' + (y + 1)).html(gateways_field_split[0]);
if(gateways_field_split[1]) {
jQuery('#gateway' + (y + 1)).css('background-color',gateways_field_split[1]);
}
}
}
}
}
function updateCpuFreq(x) {
if(jQuery('#cpufreq'))
jQuery("#cpufreq").html(x);
}
function updateLoadAverage(x) {
if(jQuery('#load_average'))
jQuery("#load_average").html(x);
}
function updateInterfaceStats(x){
if (widgetActive("interface_statistics")){
statistics_split = x.split(",");
var counter = 1;
for (var y=0; y<statistics_split.length-1; y++){
if(jQuery('#stat' + counter)) {
jQuery('#stat' + counter).html(statistics_split[y]);
counter++;
}
}
}
}
function updateInterfaces(x){
if (widgetActive("interfaces")){
interfaces_split = x.split("~");
interfaces_split.each(function(iface){
details = iface.split(",");
if (details[2] == '')
ipv4_details = '';
else
ipv4_details = details[2] + '<br />';
switch(details[1]) {
case "up":
jQuery('#' + details[0] + '-up').css("display","inline");
jQuery('#' + details[0] + '-down').css("display","none");
jQuery('#' + details[0] + '-block').css("display","none");
jQuery('#' + details[0] + '-ip').html(ipv4_details);
jQuery('#' + details[0] + '-ipv6').html(details[3]);
jQuery('#' + details[0] + '-media').html(details[4]);
break;
case "down":
jQuery('#' + details[0] + '-down').css("display","inline");
jQuery('#' + details[0] + '-up').css("display","none");
jQuery('#' + details[0] + '-block').css("display","none");
jQuery('#' + details[0] + '-ip').html(ipv4_details);
jQuery('#' + details[0] + '-ipv6').html(details[3]);
jQuery('#' + details[0] + '-media').html(details[4]);
break;
case "block":
jQuery('#' + details[0] + '-block').css("display","inline");
jQuery('#' + details[0] + '-down').css("display","none");
jQuery('#' + details[0] + '-up').css("display","none");
break;
}
});
}
}
function widgetActive(x) {
var widget = jQuery('#' + x + '-container');
if ((widget != null) && (widget.css('display') != null) && (widget.css('display') != "none"))
return true;
else
return false;
}
/* start updater */
jQuery(document).ready(function(){
setTimer();
});

View File

@ -1,253 +0,0 @@
/*jslint white: true, sloppy: true, vars: true, eqeq: true */
/*jslint browser: true, devel: true */
/*global show_hide_linkfields, jQuery, country_list */
function update_select_list(new_options, select_list){
var option_array = new_options.split("|");
var i = 0;
var j;
select_list.length = 0;
for(j=0; j < option_array.length-1; j++){
var option = option_array[j].split(",");
var selected = Boolean(parseInt(option[2], 10));
select_list[j] = new Option(option[0], option[1], false, selected);
//for testing and debugging
//select_list.options[option_array.length-1+j] = new Option(option[2].toString() +" "+ selected.toString());
//select_list.options[option_array.length-1+j] = new Option("Link Label: " + linklabel + " Label Text:" + label_text);
}
show_hide_linkfields(select_list);
}
function show_advanced(hide){
var select_list = document.iform["interfaces[]"].options;
var adv_rows = parseInt(jQuery('#adv_rows').html(), 10);
var adv_show = Boolean(parseInt(jQuery('#adv_show').html(), 10));
var status = Boolean(parseInt(hide, 10));
var j, advanced;
if (status){
jQuery('#advanced_').hide();
for(j=0; j < adv_rows; j++){
advanced = "#advanced_" + j.toString();
jQuery(advanced).show();
}
jQuery('#adv_show').html("1");
show_hide_linkfields(select_list);
} else {
jQuery('#advanced_').show();
for(j=0; j < adv_rows; j++){
advanced = "#advanced_" + j.toString();
jQuery(advanced).hide();
}
jQuery('#adv_show').html("0");
show_hide_linkfields(select_list);
}
}
function show_hide_linkfields(options){
var i = 0;
var port_count = parseInt(jQuery('#port_count').html(), 10);
var adv_show = Boolean(parseInt(jQuery('#adv_show').html(), 10));
var j, count, type, link, lnklabel, bw, bwlabel, mtu, mru, mrru, ipfields, gwfields, localip,
localiplabel, subnet, gateway, gatewaylabel;
for(j=0; j < port_count; j++){
count = j.toString();
type = jQuery('#type').val();
link = "#link" + count;
lnklabel = "#linklabel" + count;
bw = "#bandwidth" + count;
bwlabel = "#bwlabel" + count;
mtu = "#mtu" + count;
mru = "#mru" + count;
mrru = "#mrru" + count;
ipfields = "#ip_fields" + count;
gwfields = "#gw_fields" + count;
localip = "#localip" + count;
localiplabel = "#localiplabel" + count;
subnet = "#subnet" + count;
gateway = "#gateway" + count;
gatewaylabel = "#gatewaylabel" + count;
jQuery(ipfields + ',' + gwfields + ',' + link).hide();
jQuery(subnet).prop('disabled',true);
jQuery(bw).attr("name","bandwidth[]");
jQuery(mtu).attr("name","mtu[]");
jQuery(mru).attr("name","mru[]");
jQuery(mrru).attr("name","mrru[]");
jQuery(localip).attr("name","localip[]");
jQuery(subnet).attr("name","subnet[]");
jQuery(gateway).attr("name","gateway[]");
while(i < options.length){
if (options[i].selected ){
jQuery(lnklabel).html("Link Parameters (" + options[i].value + ")");
jQuery(bwlabel).html("Bandwidth (" + options[i].value + ")");
jQuery(bw).attr("name","bandwidth[" + options[i].value + "]");
jQuery(mtu).attr("name","mtu[" + options[i].value + "]");
jQuery(mru).attr("name","mru[" + options[i].value + "]");
jQuery(mrru).attr("name","mrru[" + options[i].value + "]");
jQuery(localiplabel).html("Local IP (" + options[i].value + ")");
jQuery(gatewaylabel).html("Gateway (" + options[i].value + ")");
jQuery(localip).attr("name","localip[" + options[i].value + "]");
jQuery(subnet).attr("name","subnet[" + options[i].value + "]");
jQuery(gateway).attr("name","gateway[" + options[i].value + "]");
if (type == 'ppp' && adv_show){
jQuery(ipfields + ',' + gwfields).show();
}
if (type == 'pptp' || type == 'l2tp'){
jQuery(subnet).prop("disabled",false);
jQuery(ipfields + ',' + gwfields).show();
}
if (adv_show){
jQuery(link).show();
}
i++;
break;
}
i++;
}
}
}
function updateType(t){
var serialports = jQuery('#serialports').html();
var ports = jQuery('#ports').html();
var select_list = document.iform["interfaces[]"].options;
jQuery('#adv_show').html("0");
show_advanced('0');
jQuery("#select").show();
switch(t) {
case "select":
jQuery('#ppp,#pppoe,#ppp_provider,#phone_num,#apn_').hide();
select_list.length = 0;
select_list[0] = new Option("Select Link Type First","");
break;
case "ppp":
update_select_list(serialports, select_list);
jQuery('#select,#pppoe').hide();
jQuery('#ppp_provider,#phone_num,#apn_').show();
country_list();
break;
case "pppoe":
update_select_list(ports, select_list);
jQuery('#select,#ppp,#ppp_provider,#phone_num,#apn_').hide();
break;
case "l2tp":
case "pptp":
update_select_list(ports, select_list);
jQuery('#select,#ppp,#pppoe,#ppp_provider,#phone_num,#apn_').hide();
break;
default:
select_list.length = 0;
select_list[0] = new Option("Select Link Type First","");
break;
}
if (t == "pppoe" || t == "ppp"){
jQuery("#" + t).show();
}
}
function show_reset_settings(reset_type) {
if (reset_type == 'preset') {
jQuery('#pppoepresetwrap').show(0);
jQuery('#pppoecustomwrap').hide(0);
}
else if (reset_type == 'custom') {
jQuery('#pppoecustomwrap').show(0);
jQuery('#pppoepresetwrap').hide(0);
} else {
jQuery('#pppoecustomwrap').hide(0);
jQuery('#pppoepresetwrap').hide(0);
}
}
function country_list() {
jQuery('#country option').remove();
jQuery('#provider option').remove();
jQuery('#providerplan option').remove();
jQuery('#country').append(new Option('', ''));
jQuery.ajax("getserviceproviders.php",{
success: function(responseText) {
var responseTextArr = responseText.split("\n");
var value, i, country;
responseTextArr.sort();
for (i = 0; i < responseTextArr.length; i += 1) {
value = responseTextArr[i];
if (/\S/.test(value)) {
country = value.split(":");
jQuery('#country').append(new Option(country[0],country[1]));
}
}
}
});
jQuery('#trcountry').css("display","table-row");
}
function providers_list() {
jQuery('#provider option').remove();
jQuery('#providerplan option').remove();
jQuery('#provider').append(new Option('', ''));
jQuery.ajax("getserviceproviders.php",{
type: 'POST',
data: {country : jQuery('#country').val()},
success: function(responseText) {
var responseTextArr = responseText.split("\n");
var value, i;
responseTextArr.sort();
for (i = 0; i < responseTextArr.length; i += 1) {
value = responseTextArr[i];
if (/\S/.test(value)) {
jQuery('#provider').append(new Option(value, value));
}
}
}
});
jQuery('#trprovider').css("display","table-row");
jQuery('#trproviderplan').css("display","none");
}
function providerplan_list() {
jQuery('#providerplan option').remove();
jQuery('#providerplan').append( new Option('','') );
jQuery.ajax("getserviceproviders.php",{
type: 'POST',
data: {country : jQuery('#country').val(), provider : jQuery('#provider').val()},
success: function(responseText) {
var responseTextArr = responseText.split("\n");
var value, providerplan, i;
responseTextArr.sort();
for (i = 0; i < responseTextArr.length; i += 1) {
value = responseTextArr[i];
if (/\S/.test(value)) {
providerplan = value.split(":");
jQuery('#providerplan').append(new Option(providerplan[0] + " - " + providerplan[1],
providerplan[1]));
}
}
}
});
jQuery('#trproviderplan').css("display","table-row");
}
function prefill_provider() {
jQuery.ajax("getserviceproviders.php",{
type: "POST",
data: {country : jQuery('#country').val(), provider : jQuery('#provider').val(), plan : jQuery('#providerplan').val()},
success: function(responseXML) {
var xmldoc = responseXML;
var provider = xmldoc.getElementsByTagName('connection')[0];
jQuery('#username').val('');
jQuery('#password').val('');
if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
jQuery('#phone').val('#777');
jQuery('#apn').val('');
} else {
jQuery('#phone').val('*99#');
jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
}
jQuery('#username').val(provider.getElementsByTagName('username')[0].firstChild.data);
jQuery('#password').val(provider.getElementsByTagName('password')[0].firstChild.data);
}
});
}

File diff suppressed because one or more lines are too long

View File

@ -1,7 +0,0 @@
/* css for timepicker */
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }

View File

@ -1,140 +0,0 @@
/*jslint browser: true, eqeqeq: true, undef: true */
/*global jQuery */
/******************************************************************************
Lines above are for jslint, the JavaScript verifier. http://www.jslint.com/
******************************************************************************/
/* MIT-licensed code from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some */
/* (C) 2007 Mozilla Developer Network and/or Jeff Walden */
if (!Array.prototype.some) {
Array.prototype.some = function(fun /*, thisp */) {
"use strict";
if (!this) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function") {
throw new TypeError();
}
var thisp = arguments[1];
for (var i = 0; i < len; i++) {
if (i in t && fun.call(thisp, t[i], i, t)) {
return true;
}
}
return false;
};
}
(function ($) {
// --------------------------------------------------------------------
// find pairs of <input class='ipv4v6'> (textbox for IPv4 or IPv6 addr)
// and <select class='ipv4v6'> (dropdown for # bits in CIDR) and
// activate behavior that restricts options in the <select> when an
// ipv4 address is typed in the <input>.
// --------------------------------------------------------------------
var _ipv4v6ify = function (input1, input2) {
var options = Array.prototype.slice.call(input2.options, 0);
var has_128 = options.some(function (x) { return parseInt(x.value, 10) === 128; });
var has_0 = options.some(function (x) { return parseInt(x.value, 10) === 0; });
var max_ipv6 = has_128 ? 128 : 127;
var min_ipv6 = has_0 ? 0 : 1;
var max_ipv4 = has_128 ? 32 : 31;
var min_ipv4 = has_0 ? 0 : 1;
var was_ipv4 = undefined;
var is_ipv4 = undefined;
var restrict_bits_to_ipv4 = function () {
input2.options.length = 0;
for (var i = 0; i < options.length; i += 1) {
var val = parseInt(options[i].value, 10);
if (val >= min_ipv4 && val <= max_ipv4) {
input2.options.add(options[i]);
}
}
};
var unrestrict_bits = function () {
input2.options.length = 0;
for (var i = 0; i < options.length; i += 1) {
input2.options.add(options[i]);
}
};
var onchange_handler = function () {
was_ipv4 = is_ipv4;
is_ipv4 = /\./.test(input1.value) && !/\:/.test(input1.value);
// handle state transitions to gracefully change the
// value in the dropdown.
var bits = parseInt($(input2).val(), 10);
if (was_ipv4 === false && is_ipv4 === true) {
restrict_bits_to_ipv4();
/* min_ipv4 -> min_ipv4 */
/* ... -> ... */
/* max_ipv4 -> max_ipv4 */
/* ... -> ... */
/* max_ipv6 -> max_ipv4 */
if (bits < min_ipv4) {
$(input2).val(min_ipv4);
}
else if (bits < max_ipv4) {
$(input2).val(bits);
}
else {
$(input2).val(max_ipv4);
}
}
else if (was_ipv4 === true && is_ipv4 === false) {
unrestrict_bits();
/* min_ipv4 -> min_ipv4 */
/* ... -> ... */
/* max_ipv4 -> max_ipv4 */
if (bits < min_ipv4) {
$(input2).val(min_ipv6);
}
else if (bits < max_ipv4) {
$(input2).val(bits);
}
else {
$(input2).val(max_ipv6);
}
}
else if (was_ipv4 === undefined && is_ipv4 === true) {
// initial value is an ipv4 address
restrict_bits_to_ipv4();
/* min_ipv4 -> min_ipv4 */
/* ... -> ... */
/* max_ipv4 -> max_ipv4 */
/* ... -> ... */
/* max_ipv6 -> max_ipv4 */
if (bits < min_ipv4) {
$(input2).val(min_ipv4);
}
else if (bits < max_ipv4) {
$(input2).val(bits);
}
else {
$(input2).val(max_ipv4);
}
}
};
$(input1).unbind("change").bind("change", onchange_handler).trigger("change");
};
$.fn.extend({
"ipv4v6ify": function () {
return this.each(function () {
var inputs, i, input1, input2;
inputs = $(this).find(":input.ipv4v6").toArray();
for (i = 0; i < inputs.length - 1; i += 1) {
input1 = inputs[i];
input2 = inputs[i + 1];
if (input1.type === "text" && input2.type === "select-one") {
_ipv4v6ify(input1, input2);
}
}
});
}
});
$(function () {
$(document).ipv4v6ify();
});
})(jQuery);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More