From 38ea6a6fee6be89bd05a4d4e6ba6abf544b567b3 Mon Sep 17 00:00:00 2001 From: Sanj Date: Tue, 4 Oct 2011 22:47:55 +0530 Subject: [PATCH] added js --- itf/festival/models.py | 1 + itf/static/js/query_parser.js | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 itf/static/js/query_parser.js diff --git a/itf/festival/models.py b/itf/festival/models.py index 2526c49..d8686ba 100644 --- a/itf/festival/models.py +++ b/itf/festival/models.py @@ -170,6 +170,7 @@ class Document(ItfModel): talk = models.ForeignKey('Talk', blank=True, null=True) is_resource = models.BooleanField() + fts_fields = ['title', 'intro'] fk_filters = [] sort_fields = ['title'] diff --git a/itf/static/js/query_parser.js b/itf/static/js/query_parser.js new file mode 100644 index 0000000..79cf06f --- /dev/null +++ b/itf/static/js/query_parser.js @@ -0,0 +1,39 @@ +function QueryParser(str) { + /******************** QueryParser ********************** + ********************* by Airshow ********************** + *** http://www.daniweb.com/forums/member512379.html *** + ********* Please keep this attribution intact *********/ + if (str) { + str = unescape(str); + if (str.indexOf("?") === 0) { str = str.substring(1); } + var args = str.split("&"); + for (var i = 0; i < args.length; i++) { + var pair = args[i].split("="); + if (pair.length >= 1) { + var prop = pair.shift(); + this[prop] = (pair.length == 1) ? pair[0] : (pair.length > 1) ? pair.join('=') : ''; + } + } + } + this.set = function (prop, value) { return this[prop] = value; }; + this.clear = function (prop) { + if(typeof this[prop] !== 'undefined') { + this.set(prop, null); + return true; + } + else { return false; } + }; + this.build = function (baseURL, hashName) { + baseURL = (!baseURL || typeof baseURL !== 'string') ? '?' : (baseURL.indexOf("?") === -1) ? (baseURL + '?') : baseURL; + hashName = (!hashName || typeof hashName !== 'string') ? '' : (hashName.indexOf("#") === -1) ? ('#' + hashName) : hashName; + var strArray = []; + for (var prop in this) { + if (typeof this[prop] !== 'undefined' && typeof this[prop] !== 'function' && this[prop] !== null) { strArray.push([prop, '=', this[prop]].join('')); } + } + return baseURL + strArray.join('&') + hashName; + }; + this.buildLink = function (baseURL, linkTxt) { + var url = this.build(baseURL); + return [ '', ((!linkTxt) ? url : linkTxt), '' ].join(''); + }; +}