Make a new REST service for the autocomplete plugin, significantly reducing the size of the responses. Also enables caching in the browser.
This commit is contained in:
@@ -31,6 +31,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once(INSTALLDIR.'/plugins/Autocomplete/autocomplete.php');
|
||||
|
||||
class AutocompletePlugin extends Plugin
|
||||
{
|
||||
function __construct()
|
||||
@@ -40,13 +42,6 @@ class AutocompletePlugin extends Plugin
|
||||
|
||||
function onEndShowScripts($action){
|
||||
if (common_logged_in()) {
|
||||
$current_user = common_current_user();
|
||||
$js_string = <<<EOT
|
||||
<script type="text/javascript">
|
||||
var current_user = { id: '$current_user->id' };
|
||||
</script>
|
||||
EOT;
|
||||
$action->raw($js_string);
|
||||
$action->script('plugins/Autocomplete/jquery-autocomplete/jquery.autocomplete.pack.js');
|
||||
$action->script('plugins/Autocomplete/Autocomplete.js');
|
||||
}
|
||||
@@ -59,5 +54,12 @@ EOT;
|
||||
}
|
||||
}
|
||||
|
||||
function onRouterInitialized($m)
|
||||
{
|
||||
if (common_logged_in()) {
|
||||
$m->connect('plugins/Autocomplete/autocomplete.json', array('action'=>'autocomplete'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user