mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
Remove some post parameters, if they are set to default values, as their values are already set by YaCy. Added some documentation.
This commit is contained in:
parent
405878182f
commit
2214bf5396
|
@ -7,6 +7,10 @@
|
|||
<script type="text/javascript" src="/js/IndexCreate.js"></script>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
/**
|
||||
* Set the state of all elements based on other elements state.
|
||||
* @param {String} cId id of the element that had changed it's state
|
||||
*/
|
||||
function setStates(cId) {
|
||||
// order matters!
|
||||
// crawl start points
|
||||
|
@ -90,32 +94,41 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable element if value matches val.
|
||||
* @param {String} id element id
|
||||
* @param {String} val value to comapre to elements value */
|
||||
function disableIf(id, val) {
|
||||
var e = $('#'+id);
|
||||
if (e.val() === val) {
|
||||
e.disable();
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
(function($) {
|
||||
/** Disable a form element. */
|
||||
$.fn.disable = function() {
|
||||
return this.each(function() {
|
||||
$(this).prop('disabled', true);
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
(function($) {
|
||||
/** Enable a form element. */
|
||||
$.fn.enable = function() {
|
||||
return this.each(function() {
|
||||
$(this).prop('disabled', false);
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
(function($) {
|
||||
/** Set checked state for checkoxes/radio buttons. */
|
||||
$.fn.check = function() {
|
||||
return this.each(function() {
|
||||
$(this).attr("checked", "checked").prop("checked", true);
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
(function($) {
|
||||
/** Unset checked state for checkoxes/radio buttons. */
|
||||
$.fn.uncheck = function() {
|
||||
return this.each(function() {
|
||||
$(this).removeAttr("checked").prop("checked", false);
|
||||
|
@ -123,6 +136,37 @@
|
|||
};
|
||||
})(jQuery);
|
||||
|
||||
/**
|
||||
* On form submission remove text fields with default values as they
|
||||
* are set to those by yacy values by yacy, if missing.
|
||||
* @param {eventObject} ev */
|
||||
$('#Crawler').on('submit', function(ev){
|
||||
var defaultMatchAll = "#[matchAllStr]#";
|
||||
var defaultMatchNone = "#[matchNoneStr]#";
|
||||
|
||||
// remove empty textfields
|
||||
disableIf('crawlingDepthExtension', '');
|
||||
disableIf('intention', '');
|
||||
|
||||
// remove if MATCH_NEVER_STRING
|
||||
disableIf('mustnotmatch', defaultMatchNone);
|
||||
disableIf('ipMustnotmatch', defaultMatchNone);
|
||||
disableIf('indexmustnotmatch', defaultMatchNone);
|
||||
disableIf('indexcontentmustnotmatch', defaultMatchNone);
|
||||
|
||||
// remove if MATCH_ALL_STRING
|
||||
disableIf('mustmatch', defaultMatchAll);
|
||||
disableIf('ipMustmatch', defaultMatchAll);
|
||||
disableIf('indexmustmatch', defaultMatchAll);
|
||||
disableIf('indexcontentmustmatch', defaultMatchAll);
|
||||
|
||||
// remove default collection name
|
||||
disableIf('collection', '#[defaultCollection]#');
|
||||
|
||||
console.log("POST: "+$(this).serialize());
|
||||
return false;
|
||||
});
|
||||
|
||||
// add event handlers to all checkoxes & radio buttons
|
||||
$(document).on('change', 'input:checkbox,input:radio', function() {
|
||||
setStates($(this).attr("id"));
|
||||
|
|
|
@ -42,6 +42,12 @@ public class CrawlStartExpert_p {
|
|||
// return variable that accumulates replacements
|
||||
final Switchboard sb = (Switchboard) env;
|
||||
final serverObjects prop = new serverObjects();
|
||||
final String defaultCollection = "user";
|
||||
|
||||
// javascript values
|
||||
prop.put("matchAllStr", CrawlProfile.MATCH_ALL_STRING);
|
||||
prop.put("matchNoneStr", CrawlProfile.MATCH_NEVER_STRING);
|
||||
prop.put("defaultCollection", defaultCollection);
|
||||
|
||||
// ---------- Start point
|
||||
// crawl start URL
|
||||
|
@ -534,7 +540,7 @@ public class CrawlStartExpert_p {
|
|||
if (post != null && post.containsKey("collection")) {
|
||||
prop.put("collection", post.get("collection", ""));
|
||||
} else {
|
||||
prop.put("collection", collectionEnabled ? "user" : "");
|
||||
prop.put("collection", collectionEnabled ? defaultCollection : "");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user