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