summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-admin/admin-functions.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-08-04 11:54:40 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-08-04 11:54:40 +0000
commitddaa11d747bfdb2a8f16a868ad400e1880dd3d6f (patch)
tree5171513705cc0141b87c1af96c19a167ae99bbd5 /wp-inst/wp-admin/admin-functions.php
parent44322dc10630292a50aced9edaa19bce583b9bad (diff)
downloadwordpress-mu-ddaa11d747bfdb2a8f16a868ad400e1880dd3d6f.tar.gz
wordpress-mu-ddaa11d747bfdb2a8f16a868ad400e1880dd3d6f.tar.xz
wordpress-mu-ddaa11d747bfdb2a8f16a868ad400e1880dd3d6f.zip
Move AJAX code into function so it can be used multiple times.
Add AJAX functionality to new category textbox on edit form and category page. AJAX code from: http://grebowiec.net/?p=77 / http://grebowiec.net/wp-content/searchboxcode.txt git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@124 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-admin/admin-functions.php')
-rw-r--r--wp-inst/wp-admin/admin-functions.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/wp-inst/wp-admin/admin-functions.php b/wp-inst/wp-admin/admin-functions.php
index 1be7991..ed85265 100644
--- a/wp-inst/wp-admin/admin-functions.php
+++ b/wp-inst/wp-admin/admin-functions.php
@@ -1380,4 +1380,76 @@ function documentation_link( $for ) {
return;
}
+function AJAX_search_box( $get_url, $search_field = 'newvalue', $search_results_field = 'searchresults' ) {
+ ?>
+ <script language="JavaScript">
+
+ function update_AJAX_search_box( username )
+ {
+ document.getElementById("<?php echo $search_field ?>").value=username;
+ document.getElementById("<?php echo $search_results_field ?>").innerHTML = "<?php _e( 'Search Results' ) ?>";
+ document.getElementById("<?php echo $search_results_field ?>").style.display = 'none';
+ return false;
+ }
+
+ // from js_util.js by scottandrew.com/junkyard/js/
+ function addEvent(elm, evType, fn, useCapture)
+ {
+ if (elm.addEventListener){
+ elm.addEventListener(evType, fn, useCapture);
+ return true;
+ } else if (elm.attachEvent){
+ var r = elm.attachEvent("on"+evType, fn);
+ return r;
+ } else {
+ alert("Handler could not be removed");
+ }
+ }
+ // end from scottandrew.com/junkyard/js/
+
+ var valBox = document.getElementById("<?php echo $search_field ?>");
+ var displayBox = document.getElementById("<?php echo $search_results_field ?>");
+ addEvent(valBox, 'keyup', doTest, false);
+ var keyPressDelay = '';
+
+ var xmlhttp=false;
+ try {
+ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
+ } catch (e) {
+ try {
+ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
+ } catch (E) {
+ xmlhttp = false;
+ }
+ }
+
+ if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
+ xmlhttp = new XMLHttpRequest();
+ }
+
+ function doTest() {
+ if (keyPressDelay) {
+ window.clearTimeout(keyPressDelay);
+ }
+
+ if(valBox.value != '') {
+ keyPressDelay = window.setTimeout('doSearch()',800);
+ }
+ }
+
+ function doSearch() {
+ displayBox.style.display = '';
+ displayBox.innerHTML = "Searching ...";
+ xmlhttp.open("GET","<?php echo $get_url ?>"+valBox.value,true);
+ xmlhttp.onreadystatechange=function() {
+ if (xmlhttp.readyState==4) {
+ displayBox.innerHTML = xmlhttp.responseText;
+ }
+ }
+ xmlhttp.send(null);
+ }
+ </script>
+ <?php
+}
+
?>