Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to a "contains" semantics for search #1

Merged
merged 2 commits into from Mar 26, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions sdnforumsearch.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<script src="/~dj/sapui5/sapui5-static/resources/sap-ui-core.js"
<script src="./sap-ui-core.js"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand where you're coming from with this change, but am curious: with sap-ui-core.js in the same directory, does that imply that all the rest of the sapui5-static/resources files are in that same root-level directory alongside this HTML file? I want to get to a situation where we can have the resources held in a single (abstract) place. Or am I missing the point?

(Hmm, perhaps we can get SAP to host...?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, if it was at a central location that would be good, but barring that it makes more sense to me to have it in the same directory rather than somewhere that only exists on one machine. The normal practice would be to host the sap-ui-core.js file in the same Git repository as the application, but given SAP's licensing restrictions that is not possible. Just one more way that SAP is shooting itself in the foot with developer licensing.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SAPUI5 is too huge to host in same dir as app. So will assume / suggest a 'definitive' dir to use as convention: '/sapui5/' like this:

<script src="/sapui5/sap-ui-core.js">...

And each user can replace that with whatever is relevant for them.

type="text/javascript"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.ui.commons"
Expand All @@ -28,13 +28,14 @@
});

// Load the plugin to use 'jQuery.sap.startsWithIgnoreCase'
jQuery.sap.require("jquery.sap.strings");
// jQuery.sap.require("jquery.sap.strings");

// Filter the forums according to the given prefix
var filterSdnForums = function (sPrefix) {
var filterSdnForums = function (sTerm) {
var re = new RegExp(sTerm,"i")
var aResult = [];
for (var i = 0; i < aSdnForums.length; i++) {
if (!sPrefix || sPrefix.length == 0 || jQuery.sap.startsWithIgnoreCase(aSdnForums[i], sPrefix)) {
if (!sTerm || sTerm.length == 0 || re.test(aSdnForums[i])) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this. The original is, as you say, too restrictive, and also a bit ugly anyway (startsWith...).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I looked at the UI5 library I was kind of shocked to see these utility methods and not jQuery.sap.containsIgnoreCase(). So RegExp it is!

aResult.push(aSdnForums[i]);
}
}
Expand Down