the bulk of theme engine 2.0; it's still rough, but it works

git-svn-id: file:///home/shish/svn/shimmie2/trunk@201 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish
2007-06-30 01:19:11 +00:00
parent d06f0ef30f
commit a625fcd787
58 changed files with 1198 additions and 891 deletions

View File

@@ -5,7 +5,7 @@ class AutoComplete extends Extension {
public function receive_event($event) {
if(is_a($event, 'PageRequestEvent') && ($event->page == "index" || $event->page == "view")) {
global $page;
$page->add_side_block(new Block(null, $this->build_autocomplete_script()));
$page->add_header("<script>autocomplete_url='".html_escape(make_link("autocomplete"))."';</script>");
}
if(is_a($event, 'PageRequestEvent') && ($event->page == "autocomplete")) {
global $page;
@@ -22,52 +22,6 @@ class AutoComplete extends Extension {
return implode("\n", $tags);
}
// }}}
// html {{{
private function build_autocomplete_script() {
global $database;
$ac_url = html_escape(make_link("autocomplete"));
return <<<EOD
<script>
//completion_cache = new array();
input = byId("search_input");
output = byId("search_completions");
function get_cached_completions(start) {
// if(completion_cache[start]) {
// return completion_cache[start];
// }
// else {
return null;
// }
}
function get_completions(start) {
cached = get_cached_completions(start);
if(cached) {
output.innerHTML = cached;
}
else {
ajaxRequest("$ac_url/"+start, function(data) {set_completions(start, data);});
}
}
function set_completions(start, data) {
// completion_cache[start] = data;
output.innerHTML = data;
}
input.onkeyup = function() {
if(input.value.length < 3) {
output.innerHTML = "";
}
else {
get_completions(input.value);
}
};
</script>
EOD;
}
// }}}
}
add_event_listener(new AutoComplete());
?>