Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
d2d77b2a
Commit
d2d77b2a
authored
13 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
initial work on instant search
parent
aafd36e2
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/js/js.js
+60
-6
60 additions, 6 deletions
core/js/js.js
core/templates/part.searchbox.php
+1
-1
1 addition, 1 deletion
core/templates/part.searchbox.php
with
61 additions
and
7 deletions
core/js/js.js
+
60
−
6
View file @
d2d77b2a
...
@@ -47,17 +47,62 @@ OC={
...
@@ -47,17 +47,62 @@ OC={
},
},
addScript
:
function
(
app
,
script
,
ready
){
addScript
:
function
(
app
,
script
,
ready
){
var
path
=
OC
.
filePath
(
app
,
'
js
'
,
script
+
'
.js
'
);
var
path
=
OC
.
filePath
(
app
,
'
js
'
,
script
+
'
.js
'
);
if
(
OC
.
addStyle
.
loaded
.
indexOf
(
path
)
==-
1
){
OC
.
addStyle
.
loaded
.
push
(
path
);
if
(
ready
){
if
(
ready
){
$
.
getScript
(
path
,
ready
);
$
.
getScript
(
path
,
ready
);
}
else
{
}
else
{
$
.
getScript
(
path
);
$
.
getScript
(
path
);
}
}
}
},
},
addStyle
:
function
(
app
,
style
){
addStyle
:
function
(
app
,
style
){
var
path
=
OC
.
filePath
(
app
,
'
css
'
,
style
+
'
.css
'
);
var
path
=
OC
.
filePath
(
app
,
'
css
'
,
style
+
'
.css
'
);
if
(
OC
.
addScript
.
loaded
.
indexOf
(
path
)
==-
1
){
OC
.
addScript
.
loaded
.
push
(
path
);
var
style
=
$
(
'
<link rel="stylesheet" type="text/css" href="
'
+
path
+
'
"/>
'
);
var
style
=
$
(
'
<link rel="stylesheet" type="text/css" href="
'
+
path
+
'
"/>
'
);
$
(
'
head
'
).
append
(
style
);
$
(
'
head
'
).
append
(
style
);
}
}
},
search
:
function
(
query
){
if
(
query
){
OC
.
addStyle
(
'
search
'
,
'
results
'
);
$
.
getJSON
(
OC
.
filePath
(
'
search
'
,
'
ajax
'
,
'
search.php
'
)
+
'
?query=
'
+
encodeURIComponent
(
query
),
OC
.
search
.
showResults
);
}
}
}
OC
.
addStyle
.
loaded
=
[];
OC
.
addScript
.
loaded
=
[];
OC
.
search
.
catagorizeResults
=
function
(
results
){
var
types
=
{};
for
(
var
i
=
0
;
i
<
results
.
length
;
i
++
){
var
type
=
results
[
i
].
type
;
if
(
!
types
[
type
]){
types
[
type
]
=
[];
}
types
[
type
].
push
(
results
[
i
]);
}
return
types
;
}
OC
.
search
.
showResults
=
function
(
results
){
var
types
=
OC
.
search
.
catagorizeResults
(
results
);
$
(
'
#searchresults
'
).
remove
();
var
ul
=
$
(
'
<ul id="searchresults"><ul>
'
);
for
(
var
name
in
types
){
var
type
=
types
[
name
];
if
(
type
.
length
>
0
){
ul
.
append
(
$
(
'
<li class="type">
'
+
name
+
'
</li>
'
));
for
(
var
i
=
0
;
i
<
type
.
length
;
i
++
){
var
item
=
type
[
i
];
var
li
=
(
$
(
'
<li class="
'
+
name
+
'
"></li>
'
));
li
.
append
(
$
(
'
<a href="
'
+
item
.
link
+
'
">
'
+
item
.
name
+
'
</a>
'
));
li
.
append
(
$
(
'
<span class="text">
'
+
item
.
text
+
'
</span>
'
));
ul
.
append
(
li
);
}
}
}
$
(
'
body
'
).
append
(
ul
);
}
}
if
(
!
Array
.
prototype
.
filter
)
{
if
(
!
Array
.
prototype
.
filter
)
{
...
@@ -112,4 +157,13 @@ $(document).ready(function(){
...
@@ -112,4 +157,13 @@ $(document).ready(function(){
element
.
attr
(
'
src
'
,
src
.
substr
(
0
,
src
.
length
-
3
)
+
'
png
'
);
element
.
attr
(
'
src
'
,
src
.
substr
(
0
,
src
.
length
-
3
)
+
'
png
'
);
});
});
};
};
$
(
'
#searchbox
'
).
keyup
(
function
(){
var
query
=
$
(
'
#searchbox
'
).
val
();
if
(
query
.
length
>
2
){
OC
.
search
(
query
);
}
else
{
$
(
'
#searchresults
'
).
remove
();
}
});
$
(
'
#searchbox
'
).
click
(
function
(){
$
(
'
#searchbox
'
).
trigger
(
'
keyup
'
)});
});
});
This diff is collapsed.
Click to expand it.
core/templates/part.searchbox.php
+
1
−
1
View file @
d2d77b2a
<form
class=
"searchbox"
action=
"
<?php
echo
$_
[
'searchurl'
]
?>
"
method=
"post"
>
<form
class=
"searchbox"
action=
"
<?php
echo
$_
[
'searchurl'
]
?>
"
method=
"post"
>
<input
type=
"search"
name=
"query"
value=
"
<?php
if
(
isset
(
$_POST
[
'query'
])){
echo
$_POST
[
'query'
];};
?>
"
class=
"prettybutton"
/>
<input
id=
'searchbox'
type=
"search"
name=
"query"
value=
"
<?php
if
(
isset
(
$_POST
[
'query'
])){
echo
$_POST
[
'query'
];};
?>
"
class=
"prettybutton"
/>
</form>
</form>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment