mwsuggest - /* * OpenSearch ajax suggestion engine for...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * OpenSearch ajax suggestion engine for MediaWiki * * uses core MediaWiki open search support to fetch suggestions * and show them below search boxes and other inputs * * by Robert Stojnic (April 2008) */ // search_box_id -> Results object var os_map = {}; // cached data, url -> json_text var os_cache = {}; // global variables for suggest_keypress var os_cur_keypressed = 0; var os_last_keypress = 0; var os_keypressed_count = 0; // type: Timer var os_timer = null; // tie mousedown/up events var os_mouse_pressed = false; var os_mouse_num = -1; // if true, the last change was made by mouse (and not keyboard) var os_mouse_moved = false; // delay between keypress and suggestion (in ms) var os_search_timeout = 250; // these pairs of inputs/forms will be autoloaded at startup var os_autoload_inputs = new Array('searchInput', 'searchInput2', 'powerSearchText', 'searchText'); var os_autoload_forms = new Array('searchform', 'searchform2', 'powersearch', 'search' ); // if we stopped the service var os_is_stopped = false; // max lines to show in suggest table var os_max_lines_per_suggest = 7; // number of steps to animate expansion/contraction of container width var os_animation_steps = 6; // num of pixels of smallest step var os_animation_min_step = 2; // delay between steps (in ms) var os_animation_delay = 30; // max width of container in percent of normal size (1 == 100%) var os_container_max_width = 2; // currently active animation timer var os_animation_timer = null; /** Timeout timer class that will fetch the results */ function os_Timer(id,r,query){ this.id = id; this.r = r; this.query = query; } /** Timer user to animate expansion/contraction of container width */ function os_AnimationTimer(r, target){ this.r = r; var current = document.getElementById(r.container).offsetWidth; this.inc = Math.round((target-current) / os_animation_steps); this.inc = os_animation_min_step; // minimal animation step this.inc = -os_animation_min_step; this.target = target; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
/** Property class for single search box */ function os_Results(name, formname){ this.searchform = formname; // id of the searchform this.searchbox = name; // id of the searchbox this.container = name+"Suggest"; // div that holds results this.resultTable = name+"Result"; // id base for the result table (+num = table row) this.resultText = name+"ResultText"; // id base for the spans within result tables (+num) this.toggle = name+"Toggle"; // div that has the toggle (enable/disable) link this.query = null; // last processed query this.results = null; // parsed titles this.resultCount = 0; // number of results this.original = null; // query that user entered this.selected = -1; // which result is selected this.containerCount = 0; // number of results visible in container this.containerRow = 0; // height of result field in the container this.containerTotal = 0; // total height of the container will all results
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 14

mwsuggest - /* * OpenSearch ajax suggestion engine for...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online