From 2b5da708c0f4b046171894bc49f4941e0bfe7f3f Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Tue, 13 Nov 2018 12:26:43 +0100
Subject: [PATCH] Searching for "instance X" now returns class results with all
information unfolded (resolves #216)
---
frontend/api.js | 20 +++++++++-----------
frontend/api.php | 2 ++
frontend/common.js | 4 ++--
frontend/index.php | 4 ++--
4 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/frontend/api.js b/frontend/api.js
index 9e9efa2..dc868cc 100644
--- a/frontend/api.js
+++ b/frontend/api.js
@@ -16,6 +16,7 @@ var old_libs = null;
var old_include_builtins = -1;
var old_include_core = -1;
var old_include_apps = -1;
+var unfold_more_information = false;
// https://stackoverflow.com/a/4812022/1544337
Element.prototype.getCaretPosition = function() {
@@ -752,6 +753,13 @@ function getResults(str, libs, include_builtins, include_core, include_apps, pag
responsedata['suggestions'].length > 0) {
par.insertBefore(makeSuggestions(responsedata['suggestions']), par.firstChild);
}
+
+ if (unfold_more_information) {
+ var togglers = elem.getElementsByClassName('toggler');
+ for (var i=0; i' +
- 'Cloogle does not accept spaces in the input. ' +
- 'Did you mean to search for ' +
- '' + sug[0][1] + '
or ' +
- '' + sug[1][1] + '
?
';
- return;
+ unfold_more_information = true;
}
var libs = getLibs();
diff --git a/frontend/api.php b/frontend/api.php
index fec4a9b..04b3c55 100644
--- a/frontend/api.php
+++ b/frontend/api.php
@@ -195,6 +195,8 @@ if ($_SERVER['REQUEST_METHOD'] !== 'GET'){
}
} elseif (substr($name, 0, 6) == 'class ') {
$command['className'] = substr($name, 6);
+ } elseif (substr($name, 0, 9) == 'instance ') {
+ $command['className'] = substr($name, 9);
} elseif (substr($name, 0, 5) == 'type ') {
$command['typeName'] = substr($name, 5);
} elseif ($name != '') {
diff --git a/frontend/common.js b/frontend/common.js
index 013ca01..ed9e16f 100644
--- a/frontend/common.js
+++ b/frontend/common.js
@@ -91,9 +91,9 @@ function highlightCallback(span, cls, str) {
function highlightQuery(query) {
var highlighter = highlightClean;
- if (query == 'class' || query == 'type' || query == 'using') {
+ if (query == 'class' || query == 'instance' || query == 'type' || query == 'using') {
return '' + query + '';
- } else if (query.match(/^class\s/)) {
+ } else if (query.match(/^class\s/) || query.match(/^instance\s/)) {
highlighter = highlightClean;
} else if (query.match(/^type\s/)) {
highlighter = function(q) {
diff --git a/frontend/index.php b/frontend/index.php
index 0f6213e..b3407e3 100644
--- a/frontend/index.php
+++ b/frontend/index.php
@@ -107,11 +107,11 @@
type Maybe |
- The type definition of Maybe x |
+ Types with the exact name Maybe |
class Text |
- The class definition of Text |
+ Classes with the exact name Text |
Besides this web app, there are other frontends available.
--
GitLab