summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Levsen <holger@debian.org>2014-09-20 09:42:28 +0000
committerHolger Levsen <holger@debian.org>2014-09-20 09:42:28 +0000
commitb4f682b53315a5c2e61d230014929fd1925c16fd (patch)
tree10473db043f493c492afa437a3d354090c2ba375
parent54bd2b174508b10e7bbc2d505a65ea8e64b3c69a (diff)
move javascript code into external file
git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@28928 e39458fd-73e7-0310-bf30-c45bca0a0e42
-rw-r--r--bin/tracker_service.py26
-rw-r--r--lib/python/web_support.py4
-rw-r--r--static/script.js15
3 files changed, 27 insertions, 18 deletions
diff --git a/bin/tracker_service.py b/bin/tracker_service.py
index 3da96dc9cf..a633c558f3 100644
--- a/bin/tracker_service.py
+++ b/bin/tracker_service.py
@@ -88,22 +88,8 @@ class BugFilterNoDSA(BugFilter):
class TrackerService(webservice_base_class):
head_contents = compose(
LINK(' ', href="/tracker/style.css"),
- SCRIPT('''var old_query_value = "";
- function selectSearch() {
- document.searchForm.query.focus();
- }
-
- function onSearch(query) {
- if (old_query_value == "") {
- if (query.length > 5) {
- old_query_value = query;
- document.searchForm.submit();
- } else {
- old_query_value = query;
- }
- }
- }
- ''')).toHTML()
+ SCRIPT(' ', src="/tracker/script.js"),
+ ).toHTML()
nvd_text = P('''If a "**" is included, the urgency field was automatically
assigned by the NVD (National Vulnerability Database). Note that this
@@ -149,6 +135,7 @@ class TrackerService(webservice_base_class):
self.register('data/report', self.page_report)
self.register('style.css', self.page_style_css)
self.register('logo.png', self.page_logo_png)
+ self.register('script.js', self.page_script_js)
def page_style_css(self, path, params, url):
f=open('../static/style.css', 'r')
@@ -162,6 +149,13 @@ class TrackerService(webservice_base_class):
f.close()
return BinaryResult(content,'image/png')
+ def page_script_js(self, path, params, url):
+ f=open('../static/script.js', 'r')
+ content=f.read()
+ f.close()
+ return BinaryResult(content,'text/javascript')
+
+
def page_home(self, path, params, url):
query = params.get('query', ('',))[0]
if query:
diff --git a/lib/python/web_support.py b/lib/python/web_support.py
index e4b82477e4..82bb4c56ee 100644
--- a/lib/python/web_support.py
+++ b/lib/python/web_support.py
@@ -377,8 +377,8 @@ def A(url, text=None):
return tag('a', text, href=str(url))
def STYLE(contents, type='text/css'):
return tag('style', contents, type=type)
-def SCRIPT(contents, type="text/javascript", language="JavaScript"):
- return tag('script', contents, type=type, language=language)
+def SCRIPT(contents, type="text/javascript", src=""):
+ return tag('script', contents, type=type, src=src)
def LINK(contents, type="text/css", rel="stylesheet", href=""):
return tag('link', contents, type=type, rel=rel, href=href)
def TITLE(contents):
diff --git a/static/script.js b/static/script.js
new file mode 100644
index 0000000000..62ec7ebf29
--- /dev/null
+++ b/static/script.js
@@ -0,0 +1,15 @@
+var old_query_value = "";
+function selectSearch() {
+document.searchForm.query.focus();
+}
+
+function onSearch(query) {
+if (old_query_value == "") {
+ if (query.length > 5) {
+ old_query_value = query;
+ document.searchForm.submit();
+ } else {
+ old_query_value = query;
+ }
+}
+}

© 2014-2024 Faster IT GmbH | imprint | privacy policy