Commit a1298f7a authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Gespeicherte Ergebnisse sind nun auch von der Startseite aus erreichbar

Filter funktioniert nun case-insensitiv
Sortieren nach Hostname ist nun aufsteigend.
parent c53edf9a
...@@ -24,7 +24,9 @@ elixir(function (mix) { ...@@ -24,7 +24,9 @@ elixir(function (mix) {
*/ */
mix.scripts(['lib/jquery.js', 'lib/jquery-ui.min.js', 'lib/bootstrap.js', 'lib/lightslider.js', 'lib/masonry.js', 'lib/imagesloaded.js', 'lib/openpgp.min.js', 'lib/iframeResizer.min.js', 'lib/md5.js'], 'public/js/lib.js') mix.scripts(['lib/jquery.js', 'lib/jquery-ui.min.js', 'lib/bootstrap.js', 'lib/lightslider.js', 'lib/masonry.js', 'lib/imagesloaded.js', 'lib/openpgp.min.js', 'lib/iframeResizer.min.js', 'lib/md5.js'], 'public/js/lib.js')
mix.scripts(['lib/jquery.js', 'lib/iframeResizer.contentWindow.min.js'], 'public/js/quicktips.js') mix.scripts(['lib/jquery.js', 'lib/iframeResizer.contentWindow.min.js'], 'public/js/quicktips.js')
mix.version(['css/themes/default.css', 'js/lib.js', 'js/quicktips.js']) mix.scripts(['scriptStartPage.js', 'results.js'], 'public/js/scriptStartPage.js');
mix.scripts(['scriptResultPage.js', 'results.js'], 'public/js/scriptResultPage.js');
mix.version(['css/themes/default.css', 'js/lib.js', 'js/quicktips.js']);
mix.less('metager/beitritt.less', 'public/css/beitritt.css') mix.less('metager/beitritt.less', 'public/css/beitritt.css')
mix.version(['css/beitritt.css']) mix.version(['css/beitritt.css'])
mix.version(['js/widgets.js', 'js/editLanguage.js', 'js/kontakt.js', 'js/scriptResultPage.js', 'js/scriptStartPage.js', 'js/settings.js']) mix.version(['js/widgets.js', 'js/editLanguage.js', 'js/kontakt.js', 'js/scriptResultPage.js', 'js/scriptStartPage.js', 'js/settings.js'])
......
This diff is collapsed.
...@@ -5,7 +5,10 @@ $(document).ready(function () { ...@@ -5,7 +5,10 @@ $(document).ready(function () {
var custom = $('#foki > li.active').hasClass('custom-focus-tab-selector'); var custom = $('#foki > li.active').hasClass('custom-focus-tab-selector');
getDocumentReadyForUse(focus, custom); getDocumentReadyForUse(focus, custom);
botProtection(); botProtection();
new Results(); // Adds the saved Results if they are present new Results().updateResultPageInterface(); // Adds the saved Results if they are present
if(document.location.href.indexOf("focus=container") !== -1){
$($("#foki > li#savedFokiTabSelector").get(0)).find(">a").tab("show");
}
}); });
function activateJSOnlyContent () { function activateJSOnlyContent () {
...@@ -517,6 +520,22 @@ function initialLoadContent (fokus) { ...@@ -517,6 +520,22 @@ function initialLoadContent (fokus) {
}); });
} }
function resultSaver(index) {
var title = $(".result[data-count=" + index + "] a.title").html();
var link = $(".result[data-count=" + index + "] a.title").attr("href");
var anzeigeLink = $(".result[data-count=" + index + "] div.link-link > a").html();
var gefVon = $(".result[data-count=" + index + "] span.hoster").html();
var hoster = $(".result[data-count=" + index + "] a.title").attr("data-hoster");
var anonym = $(".result[data-count=" + index + "] a.proxy").attr("href");
var description = $(".result[data-count=" + index + "] div.description").html();
var color = $(".result[data-count=" + index + "] div.number").css("color");
var rank = parseFloat($(".result[data-count=" + index + "]").attr("data-rank"));
new Result(title, link, anzeigeLink, gefVon, hoster, anonym, description, color, rank, undefined);
var to = $("#savedFokiTabSelector").length ? $("#savedFokiTabSelector") : $("#foki");
$(".result[data-count=" + index + "]").transfer({to: to, duration: 1000});
new Results().updateResultPageInterface();
}
/* /*
* This object gathers all stored Result Objects and can Update the Interface to show them. * This object gathers all stored Result Objects and can Update the Interface to show them.
*/ */
...@@ -525,13 +544,12 @@ function Results(sort){ ...@@ -525,13 +544,12 @@ function Results(sort){
this.prefix = "result_"; this.prefix = "result_";
this.results = []; this.results = [];
this.updateResults(); this.updateResults();
this.length = this.results.length;
this.sortResults(sort); this.sortResults(sort);
this.updateInterface(sort);
} }
Results.prototype.sortResults = function(sortType){ Results.prototype.sortResults = function(sortType){
if(sortType === undefined) sortType = "chronological"; if(sortType === undefined) sortType = "chronological";
console.log(this.results);
switch(sortType){ switch(sortType){
case "chronological": case "chronological":
this.results.sort(function(a,b){ this.results.sort(function(a,b){
...@@ -549,13 +567,12 @@ Results.prototype.sortResults = function(sortType){ ...@@ -549,13 +567,12 @@ Results.prototype.sortResults = function(sortType){
break; break;
case "alphabetical": case "alphabetical":
this.results.sort(function(a,b){ this.results.sort(function(a,b){
if(a.hostname > b.hostname) return -1; if(b.hostname > a.hostname) return -1;
if(a.hostname < b.hostname) return 1; if(b.hostname < a.hostname) return 1;
return 0; return 0;
}); });
break; break;
} }
console.log(this.results);
} }
Results.prototype.updateResults = function(){ Results.prototype.updateResults = function(){
...@@ -584,7 +601,7 @@ Results.prototype.deleteResults = function(){ ...@@ -584,7 +601,7 @@ Results.prototype.deleteResults = function(){
}); });
} }
Results.prototype.updateInterface = function(sortType){ Results.prototype.updateResultPageInterface = function(sortType){
if(this.results.length === 0){ if(this.results.length === 0){
$("#savedFokiTabSelector, #savedFoki").remove(); $("#savedFokiTabSelector, #savedFoki").remove();
$($("#foki > li[data-loaded=1]").get(0)).find(">a").tab("show"); $($("#foki > li[data-loaded=1]").get(0)).find(">a").tab("show");
...@@ -639,19 +656,19 @@ Results.prototype.addToContainer = function(container, sortType){ ...@@ -639,19 +656,19 @@ Results.prototype.addToContainer = function(container, sortType){
$(container).prepend(options); $(container).prepend(options);
$(options).find("select").change(function(){ $(options).find("select").change(function(){
new Results($(this).val()); new Results($(this).val()).updateResultPageInterface();
}); });
$(options).find("button").click({caller: this}, function(event){ $(options).find("button").click({caller: this}, function(event){
event.data.caller.deleteResults(); event.data.caller.deleteResults();
new Results(); new Results().updateResultPageInterface();
}); });
$(options).find("input").keyup(function(){ $(options).find("input").keyup(function(){
var search = $(this).val(); var search = $(this).val();
$("#savedFoki > div.result").each(function(index, value){ $("#savedFoki > div.result").each(function(index, value){
var html = $(this).html(); var html = $(this).html();
if(html.indexOf(search) === -1){ if(html.toLowerCase().indexOf(search.toLowerCase()) === -1){
$(value).addClass("hidden"); $(value).addClass("hidden");
}else{ }else{
$(value).removeClass("hidden"); $(value).removeClass("hidden");
...@@ -661,22 +678,6 @@ Results.prototype.addToContainer = function(container, sortType){ ...@@ -661,22 +678,6 @@ Results.prototype.addToContainer = function(container, sortType){
} }
function resultSaver(index) {
var title = $(".result[data-count=" + index + "] a.title").html();
var link = $(".result[data-count=" + index + "] a.title").attr("href");
var anzeigeLink = $(".result[data-count=" + index + "] div.link-link > a").html();
var gefVon = $(".result[data-count=" + index + "] span.hoster").html();
var hoster = $(".result[data-count=" + index + "] a.title").attr("data-hoster");
var anonym = $(".result[data-count=" + index + "] a.proxy").attr("href");
var description = $(".result[data-count=" + index + "] div.description").html();
var color = $(".result[data-count=" + index + "] div.number").css("color");
var rank = parseFloat($(".result[data-count=" + index + "]").attr("data-rank"));
new Result(title, link, anzeigeLink, gefVon, hoster, anonym, description, color, rank, undefined);
var to = $("#savedFokiTabSelector").length ? $("#savedFokiTabSelector") : $("#foki");
$(".result[data-count=" + index + "]").transfer({to: to, duration: 1000});
new Results();
}
function Result(title, link, anzeigeLink, gefVon, hoster, anonym, description, color, rank, hash){ function Result(title, link, anzeigeLink, gefVon, hoster, anonym, description, color, rank, hash){
this.prefix = "result_"; // Präfix for the localStorage so we can find all Items this.prefix = "result_"; // Präfix for the localStorage so we can find all Items
...@@ -776,7 +777,7 @@ Result.prototype.setIndex = function(index){ ...@@ -776,7 +777,7 @@ Result.prototype.setIndex = function(index){
Result.prototype.remove = function(){ Result.prototype.remove = function(){
localStorage.removeItem(this.prefix + this.hash); localStorage.removeItem(this.prefix + this.hash);
new Results(); new Results().updateResultPageInterface();
} }
Result.prototype.toHtml = function(){ Result.prototype.toHtml = function(){
...@@ -816,3 +817,4 @@ Result.prototype.toHtml = function(){ ...@@ -816,3 +817,4 @@ Result.prototype.toHtml = function(){
}); });
return result; return result;
} }
//# sourceMappingURL=scriptResultPage.js.map
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{ {
"js/editLanguage.js": "js/editLanguage-86f3614c41.js", "js/editLanguage.js": "js/editLanguage-86f3614c41.js",
"js/kontakt.js": "js/kontakt-31431155fb.js", "js/kontakt.js": "js/kontakt-31431155fb.js",
"js/scriptResultPage.js": "js/scriptResultPage-33313ea55e.js", "js/scriptResultPage.js": "js/scriptResultPage-68fe1b7f6e.js",
"js/scriptStartPage.js": "js/scriptStartPage-26e1d79535.js", "js/scriptStartPage.js": "js/scriptStartPage-5b6504d3a1.js",
"js/settings.js": "js/settings-e700ee9828.js", "js/settings.js": "js/settings-e700ee9828.js",
"js/widgets.js": "js/widgets-858904fda2.js" "js/widgets.js": "js/widgets-858904fda2.js"
} }
\ No newline at end of file
...@@ -7839,8 +7839,8 @@ footer a { ...@@ -7839,8 +7839,8 @@ footer a {
display: inline-block; display: inline-block;
border-radius: 0px 7px 7px 0px; border-radius: 0px 7px 7px 0px;
} }
.startpage-foki label span, .startpage-foki label span:not(.badge),
.foki label span { .foki label span:not(.badge) {
background-color: transparent; background-color: transparent;
} }
.focus { .focus {
......
This diff is collapsed.
...@@ -5,7 +5,10 @@ $(document).ready(function () { ...@@ -5,7 +5,10 @@ $(document).ready(function () {
var custom = $('#foki > li.active').hasClass('custom-focus-tab-selector'); var custom = $('#foki > li.active').hasClass('custom-focus-tab-selector');
getDocumentReadyForUse(focus, custom); getDocumentReadyForUse(focus, custom);
botProtection(); botProtection();
new Results(); // Adds the saved Results if they are present new Results().updateResultPageInterface(); // Adds the saved Results if they are present
if(document.location.href.indexOf("focus=container") !== -1){
$($("#foki > li#savedFokiTabSelector").get(0)).find(">a").tab("show");
}
}); });
function activateJSOnlyContent () { function activateJSOnlyContent () {
...@@ -517,6 +520,22 @@ function initialLoadContent (fokus) { ...@@ -517,6 +520,22 @@ function initialLoadContent (fokus) {
}); });
} }
function resultSaver(index) {
var title = $(".result[data-count=" + index + "] a.title").html();
var link = $(".result[data-count=" + index + "] a.title").attr("href");
var anzeigeLink = $(".result[data-count=" + index + "] div.link-link > a").html();
var gefVon = $(".result[data-count=" + index + "] span.hoster").html();
var hoster = $(".result[data-count=" + index + "] a.title").attr("data-hoster");
var anonym = $(".result[data-count=" + index + "] a.proxy").attr("href");
var description = $(".result[data-count=" + index + "] div.description").html();
var color = $(".result[data-count=" + index + "] div.number").css("color");
var rank = parseFloat($(".result[data-count=" + index + "]").attr("data-rank"));
new Result(title, link, anzeigeLink, gefVon, hoster, anonym, description, color, rank, undefined);
var to = $("#savedFokiTabSelector").length ? $("#savedFokiTabSelector") : $("#foki");
$(".result[data-count=" + index + "]").transfer({to: to, duration: 1000});
new Results().updateResultPageInterface();
}
/* /*
* This object gathers all stored Result Objects and can Update the Interface to show them. * This object gathers all stored Result Objects and can Update the Interface to show them.
*/ */
...@@ -525,13 +544,12 @@ function Results(sort){ ...@@ -525,13 +544,12 @@ function Results(sort){
this.prefix = "result_"; this.prefix = "result_";
this.results = []; this.results = [];
this.updateResults(); this.updateResults();
this.length = this.results.length;
this.sortResults(sort); this.sortResults(sort);
this.updateInterface(sort);
} }
Results.prototype.sortResults = function(sortType){ Results.prototype.sortResults = function(sortType){
if(sortType === undefined) sortType = "chronological"; if(sortType === undefined) sortType = "chronological";
console.log(this.results);
switch(sortType){ switch(sortType){
case "chronological": case "chronological":
this.results.sort(function(a,b){ this.results.sort(function(a,b){
...@@ -549,13 +567,12 @@ Results.prototype.sortResults = function(sortType){ ...@@ -549,13 +567,12 @@ Results.prototype.sortResults = function(sortType){
break; break;
case "alphabetical": case "alphabetical":
this.results.sort(function(a,b){ this.results.sort(function(a,b){
if(a.hostname > b.hostname) return -1; if(b.hostname > a.hostname) return -1;
if(a.hostname < b.hostname) return 1; if(b.hostname < a.hostname) return 1;
return 0; return 0;
}); });
break; break;
} }
console.log(this.results);
} }
Results.prototype.updateResults = function(){ Results.prototype.updateResults = function(){
...@@ -584,7 +601,7 @@ Results.prototype.deleteResults = function(){ ...@@ -584,7 +601,7 @@ Results.prototype.deleteResults = function(){
}); });
} }
Results.prototype.updateInterface = function(sortType){ Results.prototype.updateResultPageInterface = function(sortType){
if(this.results.length === 0){ if(this.results.length === 0){
$("#savedFokiTabSelector, #savedFoki").remove(); $("#savedFokiTabSelector, #savedFoki").remove();
$($("#foki > li[data-loaded=1]").get(0)).find(">a").tab("show"); $($("#foki > li[data-loaded=1]").get(0)).find(">a").tab("show");
...@@ -639,19 +656,19 @@ Results.prototype.addToContainer = function(container, sortType){ ...@@ -639,19 +656,19 @@ Results.prototype.addToContainer = function(container, sortType){
$(container).prepend(options); $(container).prepend(options);
$(options).find("select").change(function(){ $(options).find("select").change(function(){
new Results($(this).val()); new Results($(this).val()).updateResultPageInterface();
}); });
$(options).find("button").click({caller: this}, function(event){ $(options).find("button").click({caller: this}, function(event){
event.data.caller.deleteResults(); event.data.caller.deleteResults();
new Results(); new Results().updateResultPageInterface();
}); });
$(options).find("input").keyup(function(){ $(options).find("input").keyup(function(){
var search = $(this).val(); var search = $(this).val();
$("#savedFoki > div.result").each(function(index, value){ $("#savedFoki > div.result").each(function(index, value){
var html = $(this).html(); var html = $(this).html();
if(html.indexOf(search) === -1){ if(html.toLowerCase().indexOf(search.toLowerCase()) === -1){
$(value).addClass("hidden"); $(value).addClass("hidden");
}else{ }else{
$(value).removeClass("hidden"); $(value).removeClass("hidden");
...@@ -661,22 +678,6 @@ Results.prototype.addToContainer = function(container, sortType){ ...@@ -661,22 +678,6 @@ Results.prototype.addToContainer = function(container, sortType){
} }
function resultSaver(index) {
var title = $(".result[data-count=" + index + "] a.title").html();
var link = $(".result[data-count=" + index + "] a.title").attr("href");
var anzeigeLink = $(".result[data-count=" + index + "] div.link-link > a").html();
var gefVon = $(".result[data-count=" + index + "] span.hoster").html();
var hoster = $(".result[data-count=" + index + "] a.title").attr("data-hoster");
var anonym = $(".result[data-count=" + index + "] a.proxy").attr("href");
var description = $(".result[data-count=" + index + "] div.description").html();
var color = $(".result[data-count=" + index + "] div.number").css("color");
var rank = parseFloat($(".result[data-count=" + index + "]").attr("data-rank"));
new Result(title, link, anzeigeLink, gefVon, hoster, anonym, description, color, rank, undefined);
var to = $("#savedFokiTabSelector").length ? $("#savedFokiTabSelector") : $("#foki");
$(".result[data-count=" + index + "]").transfer({to: to, duration: 1000});
new Results();
}
function Result(title, link, anzeigeLink, gefVon, hoster, anonym, description, color, rank, hash){ function Result(title, link, anzeigeLink, gefVon, hoster, anonym, description, color, rank, hash){
this.prefix = "result_"; // Präfix for the localStorage so we can find all Items this.prefix = "result_"; // Präfix for the localStorage so we can find all Items
...@@ -776,7 +777,7 @@ Result.prototype.setIndex = function(index){ ...@@ -776,7 +777,7 @@ Result.prototype.setIndex = function(index){
Result.prototype.remove = function(){ Result.prototype.remove = function(){
localStorage.removeItem(this.prefix + this.hash); localStorage.removeItem(this.prefix + this.hash);
new Results(); new Results().updateResultPageInterface();
} }
Result.prototype.toHtml = function(){ Result.prototype.toHtml = function(){
...@@ -816,3 +817,4 @@ Result.prototype.toHtml = function(){ ...@@ -816,3 +817,4 @@ Result.prototype.toHtml = function(){
}); });
return result; return result;
} }
//# sourceMappingURL=scriptResultPage.js.map
This diff is collapsed.
...@@ -21,6 +21,7 @@ $(document).ready(function () { ...@@ -21,6 +21,7 @@ $(document).ready(function () {
} }
setActionListeners(); setActionListeners();
loadInitialCustomFocuses(); loadInitialCustomFocuses();
loadSavedResults();
}); });
function setActionListeners () { function setActionListeners () {
...@@ -428,3 +429,306 @@ function setFocusToDefault () { ...@@ -428,3 +429,306 @@ function setFocusToDefault () {
function setFocus (focusID) { function setFocus (focusID) {
$('#' + focusID).prop('checked', true); $('#' + focusID).prop('checked', true);
} }
function loadSavedResults() {
var results = new Results();
if(results.length > 0){
var html = $('\
<div class="focus">\
<input id="savedResults" class="focus-radio hide" name="focus" value="container" form="searchForm" type="radio" required="">\
<label id="saved-results-label" class="focus-label" for="savedResults">\
<span class="glyphicon glyphicon-floppy-disk"></span>\
<span class="content">gespeicherte Ergebnisse</span>\
<span class="badge">' + results.length + '</span>\
</label>\
</div>\
');
$("#addFocusBtnDiv").before(html);
$("#foki input#savedResults").change(function(){
if($(this).prop("checked")) $("#searchForm").submit();
});
}
}
/*
* This object gathers all stored Result Objects and can Update the Interface to show them.
*/
function Results(sort){
if(!localStorage) return;
this.prefix = "result_";
this.results = [];
this.updateResults();
this.length = this.results.length;
this.sortResults(sort);
}
Results.prototype.sortResults = function(sortType){
if(sortType === undefined) sortType = "chronological";
switch(sortType){
case "chronological":
this.results.sort(function(a,b){
if(a.added > b.added) return -1;
if(a.added < b.added) return 1;
return 0;
});
break;
case "rank":
this.results.sort(function(a,b){
if(a.rank > b.rank) return -1;
if(a.rank < b.rank) return 1;
return 0;
});
break;
case "alphabetical":
this.results.sort(function(a,b){
if(b.hostname > a.hostname) return -1;
if(b.hostname < a.hostname) return 1;
return 0;
});
break;
}
}
Results.prototype.updateResults = function(){
// Iterate over all Keys in the LocalStorage
for(var i = 0; i < localStorage.length; i++){
if(localStorage.key(i).indexOf(this.prefix) === 0){
var key = localStorage.key(i);
key = key.substr(this.prefix.length);
var tmpResult = new Result(undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, key);
tmpResult.setIndex(i);
this.results.push(tmpResult);
}
}
}
Results.prototype.deleteResults = function(){
var keys = [];
for(var i = 0; i < localStorage.length; i++){
if(localStorage.key(i).indexOf(this.prefix) === 0){
var key = localStorage.key(i);
keys.push(key);
}
}
$.each(keys, function(index, value){
localStorage.removeItem(value);
});
}
Results.prototype.updateResultPageInterface = function(sortType){
if(this.results.length === 0){
$("#savedFokiTabSelector, #savedFoki").remove();
$($("#foki > li[data-loaded=1]").get(0)).find(">a").tab("show");
return;
}
if($("#savedFokiTabSelector").length === 0){
var savedFoki = $('\
<li id="savedFokiTabSelector" data-loaded="1" class="tab-selector" role="presentation">\
<a aria-controls="savedFoki" href="#savedFoki" role="tab" data-toggle="tab">\
<span class="glyphicon glyphicon-floppy-disk"></span> gespeicherte Ergebnisse\
<span class="badge">' + this.results.length + '</span>\
</a>\
</li>\
');
$("#foki").append(savedFoki);
}else{
$("#savedFokiTabSelector span.badge").html(this.results.length);
}
if($("#savedFoki").length === 0){
// Now append the Tab Panel
var tabPanel = $('\
<div role="tabpanel" class="tab-pane" id="savedFoki">\
</div>\
');
$("#main-content-tabs").append(tabPanel);
}else{
$("#savedFoki").html("");
var tabPanel = $("#savedFoki");
}
this.addToContainer(tabPanel, sortType);
}
Results.prototype.addToContainer = function(container, sortType){
$.each(this.results, function(index, result){
$(container).append(result.toHtml());
});
var options = $('\
<div class="saver-options row">\
<input class="form-control" type="text" placeholder="Filtern">\
<select class="form-control">\
<option value="chronological">Chronologisch</option>\