these are long dead...
This commit is contained in:
parent
e0d72d5795
commit
6f85628482
4 changed files with 0 additions and 194 deletions
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Name: Autocomplete
|
||||
* Author: Shish <webmaster@shishnet.org>
|
||||
* License: GPLv2
|
||||
* Description: Auto-complete for search and upload tags
|
||||
* Documentation:
|
||||
* Just enable and things should start autocompleting as if
|
||||
* by magic. That is, if this extension actually worked...
|
||||
*/
|
||||
|
||||
class AutoComplete implements Extension {
|
||||
public function receive_event(Event $event) {
|
||||
if(($event instanceof PageRequestEvent) && ($event->page_matches("index") || $event->page_matches("view"))) {
|
||||
$event->page->add_header("<script>autocomplete_url='".html_escape(make_link("autocomplete"))."';</script>");
|
||||
}
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("autocomplete")) {
|
||||
$event->page->set_mode("data");
|
||||
$event->page->set_type("text/plain");
|
||||
$event->page->set_data($this->get_completions($event->get_arg(0)));
|
||||
}
|
||||
}
|
||||
|
||||
private function get_completions($start) {
|
||||
global $database;
|
||||
$tags = $database->db->GetCol("SELECT tag,count FROM tags WHERE tag LIKE ? ORDER BY count DESC", array($start.'%'));
|
||||
return implode("\n", $tags);
|
||||
}
|
||||
}
|
||||
add_event_listener(new AutoComplete());
|
||||
?>
|
|
@ -1,98 +0,0 @@
|
|||
|
||||
// addEvent(window, "load", function() {
|
||||
// initAjax("searchBox", "search_completions");
|
||||
// initAjax("tagBox", "upload_completions");
|
||||
// });
|
||||
|
||||
function endWord(sentance) {
|
||||
words = sentance.split(" ");
|
||||
return words[words.length-1];
|
||||
}
|
||||
|
||||
var resultCache = new Array();
|
||||
resultCache[""] = new Array();
|
||||
|
||||
function complete(boxname, text) {
|
||||
box = byId(boxname);
|
||||
words = box.value.split(" ");
|
||||
box.value = "";
|
||||
for(n=0; n<words.length-1; n++) {
|
||||
box.value += words[n]+" ";
|
||||
}
|
||||
box.value += text+" ";
|
||||
box.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
function fillCompletionZone(boxname, areaname, results) {
|
||||
byId(areaname).innerHTML = "";
|
||||
for(i=0; i<results.length; i++) {
|
||||
byId(areaname).innerHTML += "<br><a href=\"#\" onclick=\"complete('"+boxname+"', '"+results[i]+"');\">"+results[i]+"</a>";
|
||||
}
|
||||
}
|
||||
|
||||
function initAjax(boxname, areaname) {
|
||||
var box = byId(boxname);
|
||||
if(!box) return;
|
||||
|
||||
addEvent(
|
||||
box,
|
||||
"keyup",
|
||||
function f() {
|
||||
starter = endWord(box.value);
|
||||
|
||||
if(resultCache[starter]) {
|
||||
fillCompletionZone(boxname, areaname, resultCache[starter]);
|
||||
}
|
||||
else {
|
||||
ajaxRequest(
|
||||
"ajax.php?start="+starter,
|
||||
function g(text) {
|
||||
resultCache[starter] = text.split("\n");
|
||||
fillCompletionZone(boxname, areaname, resultCache[starter]);
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//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(autocomplete_url+"/"+start, function(data) {set_completions(start, data);});
|
||||
}
|
||||
}
|
||||
function set_completions(start, data) {
|
||||
// completion_cache[start] = data;
|
||||
output.innerHTML = data;
|
||||
}
|
||||
|
||||
if(input) {
|
||||
input.onkeyup = function() {
|
||||
if(input.value.length < 3) {
|
||||
output.innerHTML = "";
|
||||
}
|
||||
else {
|
||||
get_completions(input.value);
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Name: Image Notes
|
||||
* Author: Shish <webmaster@shishnet.org>
|
||||
* License: GPLv2
|
||||
* Description: Adds notes overlaid on the images
|
||||
* Documentation:
|
||||
* This is quite broken :(
|
||||
*/
|
||||
|
||||
class Notes implements Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
global $config, $database, $page, $user;
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if($event instanceof InitExtEvent) {
|
||||
if($config->get_int("ext_notes_version") < 1) {
|
||||
$this->install();
|
||||
}
|
||||
}
|
||||
|
||||
if($event instanceof DisplayingImageEvent) {
|
||||
$notes = $database->get_all("SELECT * FROM image_notes WHERE image_id = ?", array($event->image->id));
|
||||
$this->theme->display_notes($page, $notes);
|
||||
}
|
||||
}
|
||||
|
||||
protected function install() {
|
||||
global $database;
|
||||
global $config;
|
||||
$database->create_table("image_notes", "
|
||||
id SCORE_AIPK,
|
||||
image_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
owner_ip SCORE_INET NOT NULL,
|
||||
created_at DATETIME NOT NULL,
|
||||
updated_at DATETIME NOT NULL,
|
||||
version INTEGER DEFAULT 1 NOT NULL,
|
||||
is_active SCORE_BOOL DEFAULT SCORE_BOOL_Y NOT NULL,
|
||||
x INTEGER NOT NULL,
|
||||
y INTEGER NOT NULL,
|
||||
w INTEGER NOT NULL,
|
||||
h INTEGER NOT NULL,
|
||||
body TEXT NOT NULL
|
||||
");
|
||||
$config->set_int("ext_notes_version", 1);
|
||||
}
|
||||
}
|
||||
add_event_listener(new Notes());
|
||||
?>
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
|
||||
class NotesTheme extends Themelet {
|
||||
public function display_notes(Page $page, $notes) {
|
||||
$html = <<<EOD
|
||||
<script type="text/javascript">
|
||||
img = byId("main_image");
|
||||
</script>
|
||||
EOD;
|
||||
$page->add_block(new Block(null, $html));
|
||||
}
|
||||
}
|
||||
?>
|
Reference in a new issue