Mailinglist Archive: yast-devel (34 mails)

< Previous Next >
[yast-devel] WebYast server side path completion
  • From: Josef Reidinger <jreidinger@xxxxxxx>
  • Date: Mon, 25 May 2009 14:43:00 +0200
  • Message-id: <4A1A9254.3070305@xxxxxxx>
Hi,
I think that might be useful for some modules to allows enhanced specify
path of target machine. Usual java script browsing cannot be used, as it
uses browser pc and not server pc. As base I use this script
http://www.pengoworks.com/workshop/jquery/autocomplete.htm , but must
disable caching and losing focus, as it doesn't work after submit first
part of path (no hint on another parts).
If you want try it, just add to public/javascript attached js file and
to public/stylesheets attached css and gif.
Additional you must define for some controller response:
for path finding I use this:
def pathcompl
path = params[:q]
if (path[0].chr != "/")
path = "/"+path
end
dir = path[0..path.rindex("/")]
pre = path[path.rindex("/")+1..path.size]
result = `ls -1 '#{dir}' | sed "s:^\\(.\\+\\)$:#{dir}\\1:"| grep
'#{dir}#{pre}'`
render :text => result
end

How to use...fast way is add this to your RoR view (home_controller
contain pathcompl method) and:
<input type="text" id="autocomplete" name="autocomplete_parameter"/>

<script type="text/javascript">
$("#autocomplete").autocomplete("home/pathcompl",{ cacheLength:1 });
</script>

and to head of view:
<script src="/javascripts/jquery.autocomplete.js"
type="text/javascript"></script>
<link rel="stylesheet" type="text/css"
href="/stylesheets/jquery.autocomplete.css" />


What do you think about this enhancement? I welcome any comments as I am
just learning AJAX, RoR and js.
Josef
.ac_results {
padding: 0px;
border: 1px solid WindowFrame;
background-color: Window;
overflow: hidden;
}

.ac_results ul {
width: 100%;
list-style-position: outside;
list-style: none;
padding: 0;
margin: 0;
}

.ac_results iframe {
display:none;/*sorry for IE5*/
display/**/:block;/*sorry for IE5*/
position:absolute;
top:0;
left:0;
z-index:-1;
filter:mask();
width:3000px;
height:3000px;
}

.ac_results li {
margin: 0px;
padding: 2px 5px;
cursor: pointer;
display: block;
width: 100%;
font: menu;
font-size: 12px;
overflow: hidden;
}

.ac_loading {
background : Window url('./indicator.gif') right center no-repeat;
}

.ac_over {
background-color: Highlight;
color: HighlightText;
}
< Previous Next >
This Thread
  • No further messages