mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-26 22:52:26 +00:00
Renomme des variables pour éviter les conflits
This commit is contained in:
parent
1c9a2fe4ac
commit
957dc567e2
2 changed files with 18 additions and 18 deletions
|
@ -152,12 +152,12 @@ def typeahead_js( f_name, f_value, t_choices, t_match_func ) :
|
|||
|
||||
match_func = mark_safe(t_match_func[f_name]) \
|
||||
if f_name in t_match_func.keys() \
|
||||
else default_match_func()
|
||||
else default_match_func( f_name )
|
||||
|
||||
js_content = \
|
||||
'var choices = ' + choices + ';\n' + \
|
||||
'var setup = function() {\n' + \
|
||||
'var engine = ' + deafult_engine() + ';\n' + \
|
||||
'var choices_'+f_name+' = ' + choices + ';\n' + \
|
||||
'var setup_'+f_name+' = function() {\n' + \
|
||||
'var engine_'+f_name+' = ' + default_engine() + ';\n' + \
|
||||
'$("#'+input_id(f_name) + '").typeahead("destroy");\n' + \
|
||||
'$("#'+input_id(f_name) + '").typeahead(\n' + \
|
||||
default_datasets( f_name, match_func ) + '\n' + \
|
||||
|
@ -171,7 +171,7 @@ def typeahead_js( f_name, f_value, t_choices, t_match_func ) :
|
|||
'"typeahead:change", ' + \
|
||||
typeahead_change( f_name ) + '\n' + \
|
||||
');\n'
|
||||
js_content += '$("#'+input_id(f_name)+'").ready( setup );\n'
|
||||
js_content += '$("#'+input_id(f_name)+'").ready( setup_'+f_name+' );\n'
|
||||
|
||||
return render_tag( 'script', content=mark_safe( js_content ) )
|
||||
|
||||
|
@ -187,13 +187,13 @@ def default_choices( f_value ) :
|
|||
]) + \
|
||||
']'
|
||||
|
||||
def default_engine () :
|
||||
def default_engine ( f_name ) :
|
||||
return 'new Bloodhound({ ' \
|
||||
'datumTokenizer: Bloodhound.tokenizers.obj.whitespace("value"), ' \
|
||||
'queryTokenizer: Bloodhound.tokenizers.whitespace, ' \
|
||||
'local: choices, ' \
|
||||
'local: choices_'+f_name+', ' \
|
||||
'identify: function(obj) { return obj.key; } ' \
|
||||
'});'
|
||||
'})'
|
||||
|
||||
def default_datasets( f_name, match_func ) :
|
||||
return '{ ' \
|
||||
|
@ -207,17 +207,17 @@ def default_datasets( f_name, match_func ) :
|
|||
'source: '+match_func + \
|
||||
'}'
|
||||
|
||||
def default_match_func () :
|
||||
def default_match_func ( f_name ) :
|
||||
return 'function(q, sync) {' \
|
||||
'if (q === "") {' \
|
||||
'var nb = 10;' \
|
||||
'var first = [] ;' \
|
||||
'for ( var i=0 ; i<nb && i<choices.length; i++ ) {' \
|
||||
'first.push(choices[i].key);' \
|
||||
'for ( var i=0 ; i<nb && i<choices_'+f_name+'.length; i++ ) {' \
|
||||
'first.push(choices_'+f_name+'[i].key);' \
|
||||
'}' \
|
||||
'sync(engine.get(first));' \
|
||||
'sync(engine_'+f_name+'.get(first));' \
|
||||
'} else {' \
|
||||
'engine.search(q, sync);' \
|
||||
'engine_'+f_name+'.search(q, sync);' \
|
||||
'}' \
|
||||
'}'
|
||||
|
||||
|
|
|
@ -105,11 +105,11 @@ def generate_ipv4_match_func() :
|
|||
'};' \
|
||||
'var cb = function (a) { sync(a.filter(filter)); };' \
|
||||
'if (q === "") {' \
|
||||
'sync( engine.get( select(choices, 10, filter).map(' \
|
||||
'sync( engine.get( select(choices_ipv4, 10, filter).map(' \
|
||||
'function (elt) { return elt.key; }' \
|
||||
') ) );' \
|
||||
'} else {' \
|
||||
'engine.search(q, cb);' \
|
||||
'engine_ipv4.search(q, sync);' \
|
||||
'}' \
|
||||
'}'
|
||||
|
||||
|
|
Loading…
Reference in a new issue