-100
Home • Plugins • FirstMagic • app • -100
 
<!--#if expr="<X-FC-URL-PARAMETER native exists>=0"--><!--#include virtual="//Setup?plugin=firstmagic&templates=app&CONFIG&formid=2658" --><!--#else--><!--#include virtual="//Setup?plugin=firstmagic&templates=app&CONFIG&formid=2668" --><!--#endif--><!--#if expr="<X-FC-URL-PARAMETER newreq exists>=0"--><!--#if expr="`$HTTPS`=`off`"--><!--#set var="HTPREFIX" value="http://"--><!--#else--><!--#set var="HTPREFIX" value="https://"--><!--#endif--><!--#set var="DOM1" expr="@lower('$DOCUMENT_URI')"--><!--#set var="DOM2" expr="@split ('$DOM1', '/__directory')" --><!--#set var="DOM3" expr="@indexof ('$DOM2', '://')+3" --><!--#set var="THISDOMAIN" expr="@substr('$DOM2',$DOM3)"--><!--#set var="APPDOMAIN" value="$HTPREFIX$THISDOMAIN"--><!--#set var="GROUPSLIST" value="<X-FC-FIELD LANG.143.2000.10 LITERALSTRING>"--><!--#set var="groupfilter" value="0"--><!--#if expr="<X-FC-FIELD 2000 LENGTH>"--><!--#set var="GROUPSLIST" value="${GROUPSLIST};<X-FC-FIELD 2000 LITERALSTRING>"--><!--#while expr="@length($GROUPSLIST)"--><!--#set var="THISGROUP" expr="@split($GROUPSLIST,';')"--><!--#set var="CAPTION" expr="@split($THISGROUP,'=')"--><!--#if expr="$CAPTION=$APPDIRECTORY"--><!--#set var="groupfilter" value="$THISGROUP"--><!--#endif--><!--#endwhile--><!--#endif-->
// The following script is based on Autocompleter by Harald Kirschner <mail [at] digitarald.de> - copyright Harald Kirschner, MIT-style license - http://digitarald.de/project/Autocompleter/ 
var AutoLookUp = new Class({Implements: [Options, Events], options: {injectChoice: null, choicesMatch: null, multiple: false, separator: ', ', separatorSplit: /\s*[,;]\s*/, cache: true}, initialize: function(element, options) {this.element = $(element); this.setOptions(options); this.build(); this.observer = new Observer(this.element, this.prefetch.bind(this)); this.queryValue = null; this.cached = [];}, build: function() {{this.choices = new Element('span').inject('appstreamname');}}, setSelection: function(finish) {var input = this.selected.inputValue, value = input; var start = this.queryValue.length, end = input.length; if (input.substr(0, start).toLowerCase() != this.queryValue.toLowerCase()) start = 0; if (this.options.multiple) {var split = this.options.separatorSplit; value = this.element.value; start += this.queryIndex; end += this.queryIndex; var old = value.substr(this.queryIndex).split(split, 1)[0]; value = value.substr(0, this.queryIndex) + input + value.substr(this.queryIndex + old.length); if (finish) {var tokens = value.split(this.options.separatorSplit).filter(function(entry) {return this.test(entry);}, /[^\s,]+/); tokens = [].combine(tokens); var sep = this.options.separator; value = tokens.join(sep) + sep; end = value.length;}} this.observer.setValue(value); this.opted = value; if (finish) start = end; this.element.selectRange(start, end); this.fireEvent('onSelection', [this.element, this.selected, value, input]);}, showChoices: function() {var match = this.options.choicesMatch, first = this.choices.getFirst(match); this.choiceOver(first, this);}, prefetch: function() {var value = this.element.value, query = value; if (this.options.multiple) {var split = this.options.separatorSplit; var values = value.split(split); var index = this.element.getSelectedRange().start; var toIndex = value.substr(0, index).split(split); var last = toIndex.length - 1; index -= toIndex[last].length; query = values[last];}{if (query === this.queryValue) return false,$('appstreamlink').value='',$('appstreamname').value=''; else {this.queryValue = query; this.queryIndex = index; this.query();}} return true;}, update: function(tokens) {this.choices.empty(); var type = tokens && typeOf(tokens); {tokens.each(this.options.injectChoice, this); this.showChoices();}}, choiceOver: function(choice, selection) {if (!choice || choice == this.selected) return; this.selected = choice; this.fireEvent('onSelect', [this.element, this.selected, selection]); if (!selection) return; this.selectedValue = this.selected.inputValue; this.setSelection();}, choiceSelect: function(choice) {if (choice) this.choiceOver(choice); this.setSelection(true); this.queryValue = false;}, filter: function(tokens) {return (tokens || this.tokens).filter(function(token) {return this.test(token);}, new RegExp(((this.options.filterSubset) ? '' : '^') + this.queryValue.escapeRegExp(), (this.options.filterCase) ? '' : 'i'));}, addChoiceEvents: function(el) {return el.addEvents({'keyup': this.choiceSelect.bind(this, el)});}}); Element.implement({getSelectedRange: function() {var pos = {start: 0, end: 0}; var range = this.getDocument().selection.createRange(); if (!range || range.parentElement() != this) return pos; var dup = range.duplicate(); if (this.type == 'text') {pos.start = 0 - dup.moveStart('character', -100000); pos.end = pos.start + range.text.length;} else {var value = this.value; var offset = value.length - value.match(/[\n\r]*$/)[0].length; dup.moveToElementText(this); dup.setEndPoint('StartToEnd', range); pos.end = offset - dup.text.length; dup.setEndPoint('StartToStart', range); pos.start = offset - dup.text.length;} return pos;}, selectRange: function(start, end) {this.focus(); this.setSelectionRange(start, end); return this;}}); AutoLookUp.Local = new Class({Extends: AutoLookUp, initialize: function(element, tokens, options) {this.parent(element, options); this.tokens = tokens;}, query: function() {this.update(this.filter());}}); AutoLookUp.Local.URL = new Class({Extends : AutoLookUp.Local, initialize : function(input,url,options) {options = options || {}; options.injectChoice = function(el) {var value = el[0]; var id = el[1]; var choice = new Element('span'); choice.inputValue = value; choice.store('id',id); this.addChoiceEvents(choice).inject(this.choices);}.bind(this); options.onSelection = function(input,elm,value,bool) {var id = elm.retrieve('id'); $('appstreamlink').value='<!--#echo var="APPDOMAIN"-->'+id;showSaveStream();}.bind(this); this.parent(input,url,options);}}); var Observer = new Class({ Implements: [Options, Events], initialize: function(el, onFired, options){this.element = $(el) || $$(el); this.addEvent('onFired', onFired); this.setOptions(options); this.bound = this.changed.bind(this); this.resume();}, changed: function() {var value = this.element.get('value'); if(value !='') this.onFired(this.options, this);}, setValue: function(value) {this.value = value; this.element.set('value', value);}, onFired: function() {this.fireEvent('onFired', [this.value, this.element]);}, resume: function(){this.value = this.element.get('value'); this.element.addEvent('keyup', this.bound); return this;}}); var script= document.createElement('script');
script.src = '<!--#echo var="APPDOMAIN"-->/__Directory/__Lookup?templates=app&newreq&AddrBook=1&Local=1&Remote=0&Conf=0&Groups=<!--#echo var="groupfilter"-->'; document.head.appendChild(script);<!--#endif-->