From 6e23458ab0bdfd415b2de38a1ad03dbb03644410 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Tue, 18 Mar 2008 02:19:58 +0000 Subject: slight tweak to the hotness added by spocky, added in a slight delay on the onKeyUp removed the alpha list --- lib/javascript-base.js | 24 +++++++++++++++++++++--- modules/kajax/ajax.js | 34 ++++++++++++++++++++++++++++++++++ server/browse.ajax.php | 21 +++++++++++---------- 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();
  • -
    - +
    -- cgit