diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-03-18 02:19:58 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-03-18 02:19:58 +0000 |
commit | 6e23458ab0bdfd415b2de38a1ad03dbb03644410 (patch) | |
tree | a83467b3cc6eb1977b6f680e8200b40bdee1ff3c | |
parent | 179b7dab439f4993b6de0f95ef130b1dbf4d4acf (diff) | |
download | ampache-6e23458ab0bdfd415b2de38a1ad03dbb03644410.tar.gz ampache-6e23458ab0bdfd415b2de38a1ad03dbb03644410.tar.bz2 ampache-6e23458ab0bdfd415b2de38a1ad03dbb03644410.zip |
slight tweak to the hotness added by spocky, added in a slight delay on the onKeyUp removed the alpha list
-rw-r--r-- | lib/javascript-base.js | 24 | ||||
-rw-r--r-- | modules/kajax/ajax.js | 34 | ||||
-rw-r--r-- | server/browse.ajax.php | 21 | ||||
-rw-r--r-- | templates/sidebar_browse.inc.php | 3 |
4 files changed, 67 insertions, 15 deletions
diff --git a/lib/javascript-base.js b/lib/javascript-base.js index a89f06d7..15587961 100644 --- a/lib/javascript-base.js +++ b/lib/javascript-base.js @@ -1,6 +1,6 @@ // // -// Copyright (c) 2001 - 2006 Ampache.org +// Copyright (c) 2001 - 2008 Ampache.org // All rights reserved. // // This program is free software; you can redistribute it and/or @@ -38,8 +38,8 @@ function flipField(element) { element_id.disabled=false; } } -function selectField(element) -{ + +function selectField(element) { var element_id = document.getElementById(element); element_id.focus(); } @@ -49,6 +49,24 @@ function update_txt(value,field) { document.getElementById(field).innerHTML=value; } +/// +// DelayRun +// This function delays the run of another function by X milliseconds +function DelayRun(element,time,method,page,source) { + + var function_string = method + '(\'' + page + '\',\'' + source + '\')'; + + var action = function () { eval(function_string); }; + + if (element.zid) { + clearTimeout(element.zid); + } + + element.zid = setTimeout(action,time); + +} // DelayRun + + // Reload our util frame // IE issue fixed by Spocky, we have to use the iframe for Democratic Play & Localplay // which don't actually prompt for a new file diff --git a/modules/kajax/ajax.js b/modules/kajax/ajax.js index 4d7a04b1..2c1461dd 100644 --- a/modules/kajax/ajax.js +++ b/modules/kajax/ajax.js @@ -44,7 +44,41 @@ function ajaxPut(url,source) { http_request.send(null);
}
+// uid is an array of uids that need to be replaced
+function ajaxState(url,input) {
+ var data = document.getElementById(input).value
+
+ var post_data = input + '=' + encodeURI(data);
+
+ var http_request = false;
+ if (window.XMLHttpRequest) { // Mozilla, Safari,...
+ http_request = new XMLHttpRequest();
+ } else if (window.ActiveXObject) { // IE
+ try {
+ http_request = new ActiveXObject("Msxml2.XMLHTTP");
+ } catch (e) {
+ try {
+ http_request = new ActiveXObject("Microsoft.XMLHTTP");
+ } catch (e) {}
+ }
+ }
+ if (!http_request) {
+ return false;
+ }
+ http_request.onreadystatechange = function() { getContents(http_request); };
+ http_request.open('POST', url, true);
+ http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ http_request.setRequestHeader("Content-length", post_data.length);
+ http_request.setRequestHeader("Connection", "close");
+ http_request.send(post_data);
+
+} // ajaxState
+
+
+///
+// getContents
+// This is the nitty gritty wait for a good xml document and then decode it
function getContents(http_request) {
// Display the loading doodly
diff --git a/server/browse.ajax.php b/server/browse.ajax.php index 6da77e66..35a90d81 100644 --- a/server/browse.ajax.php +++ b/server/browse.ajax.php @@ -29,16 +29,17 @@ switch ($_REQUEST['action']) { $object_ids = array(); - // Check 'value' with isset because it can null - //(user type a "start with" word and deletes it) - if ($_REQUEST['key'] && isset($_REQUEST['value'])) { - // Set any new filters we've just added - Browse::set_filter($_REQUEST['key'],$_REQUEST['value']); - } - if ($_REQUEST['sort']) { - // Set the new sort value - Browse::set_sort($_REQUEST['sort']); - } + // Check 'value' with isset because it can null + //(user type a "start with" word and deletes it) + if ($_REQUEST['key'] && isset($_REQUEST['multi_alpha_filter'])) { + // Set any new filters we've just added + Browse::set_filter($_REQUEST['key'],$_REQUEST['multi_alpha_filter']); + } + + if ($_REQUEST['sort']) { + // Set the new sort value + Browse::set_sort($_REQUEST['sort']); + } // Refresh the browse div with our new filter options if we're not static if (!Browse::$static_content) { diff --git a/templates/sidebar_browse.inc.php b/templates/sidebar_browse.inc.php index 1089bd8b..936e847c 100644 --- a/templates/sidebar_browse.inc.php +++ b/templates/sidebar_browse.inc.php @@ -42,9 +42,8 @@ $allowed_filters = Browse::get_allowed_filters(); <li><h4><?php echo _('Filters'); ?></h4> <div class="sb3"> <?php if (in_array('alpha_match',$allowed_filters)) { ?> - <?php show_alphabet_list($_REQUEST['alpha_match'],$_REQUEST['action']); ?> <form id="multi_alpha_filter_form" method="post" action="javascript:void(0);"> - <input type="textbox" id="multi_alpha_filter" name="value" value="<?php echo scrub_out($_REQUEST['alpha_match']); ?>" onKeyUp="<?php echo Ajax::action('?page=browse&action=browse&key=alpha_match','multi_alpha_filter','multi_alpha_filter_form'); ?>"> + <input type="textbox" id="multi_alpha_filter" name="multi_alpha_filter" value="<?php echo scrub_out($_REQUEST['alpha_match']); ?>" onKeyUp="DelayRun(this,'400','ajaxState','<?php echo Config::get('ajax_url'); ?>?page=browse&action=browse&key=alpha_match','multi_alpha_filter');"> <label id="multi_alpha_filterLabel" for="multi_alpha_filter"><?php echo _('Starts With'); ?></label> </form> <?php } // end if alpha_match ?> |