Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
MetaGer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
56
Issues
56
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
open-source
MetaGer
Commits
bc9854f7
Commit
bc9854f7
authored
Dec 05, 2017
by
Karl Hasselbring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring: Globales results objekt hunzugefügt
parent
aaceaa18
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
10 deletions
+28
-10
resources/assets/js/result-saver.js
resources/assets/js/result-saver.js
+28
-10
No files found.
resources/assets/js/result-saver.js
View file @
bc9854f7
/**
* Global Results type element
*/
RESULTS_GLOBAL
=
null
;
/**
* Returns the global results object,
* creates it if necessary
* @returns {Results} The global results object
*/
function
results
()
{
if
(
!
RESULTS_GLOBAL
)
{
RESULTS_GLOBAL
=
new
Results
();
}
return
RESULTS_GLOBAL
;
}
/**
* Load all saved results and sort them
* @param {String} sort The type of sorting function to call for these results
*/
function
Results
(
sort
)
{
if
(
!
localStorage
)
return
false
;
function
Results
(
)
{
//TODO remove sort
if
(
!
localStorage
)
return
;
this
.
prefix
=
'
result_
'
;
this
.
sort
=
sort
;
this
.
sort
=
'
chronological
'
;
this
.
results
=
[];
this
.
loadAllResults
();
this
.
length
=
this
.
results
.
length
;
this
.
sortResults
();
results
=
this
;
}
/**
...
...
@@ -113,8 +132,6 @@ Results.prototype.updateResultPageInterface = function () {
* @param {HTML-Element} container The element to add the saved-results to
*/
Results
.
prototype
.
addToContainer
=
function
(
container
)
{
var
results
=
this
;
// Create the saver-options element, which is a bar containing
// options for filtering, sorting and deleting all results
var
options
=
$
(
'
\
...
...
@@ -146,14 +163,14 @@ Results.prototype.addToContainer = function (container) {
// When the sorting select value is changed,
// Sort all results with the selected sorting function and update their appearance
$
(
options
).
find
(
'
select
'
).
change
(
function
()
{
results
.
sortResults
(
$
(
this
).
val
()).
updateResultPageInterface
();
results
()
.
sortResults
(
$
(
this
).
val
()).
updateResultPageInterface
();
});
// When the delete button is clicked,
// Delete all results and update their appearance
$
(
options
).
find
(
'
#saver-options-delete-btn
'
).
click
(
function
(
event
)
{
results
.
deleteAllResults
();
results
.
updateResultPageInterface
();
results
()
.
deleteAllResults
();
results
()
.
updateResultPageInterface
();
});
// When the user is done typing into the filter input field,
...
...
@@ -316,6 +333,7 @@ Result.prototype.remove = function () {
/**
* Converts this result object into an html element
* @returns {HTML-Element} The converted HTML-Element
*/
Result
.
prototype
.
toHtml
=
function
()
{
// Create the saved-result element
...
...
@@ -376,10 +394,10 @@ function resultSaver (index) {
var
description
=
$
(
'
.result[data-count=
'
+
index
+
'
] .result-description
'
).
html
();
// Create the result object
new
Result
(
title
,
link
,
anzeigeLink
,
gefVon
,
hoster
,
anonym
,
description
,
index
,
undefined
);
var
result
=
new
Result
(
title
,
link
,
anzeigeLink
,
gefVon
,
hoster
,
anonym
,
description
,
index
,
undefined
);
// Update the saved results
new
R
esults
().
updateResultPageInterface
();
r
esults
().
updateResultPageInterface
();
// Animate the result transfer to the saved results
var
transferTarget
=
$
(
'
.saved-result[data-count=
'
+
index
+
'
]
'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment