CSV Search
Javascript: csvSearch

Send comments on this topic.

Description

Namespace which Contains all Javascript parts

Elements

csvSearch.urls - Contains neccessary urls for server requests
csvSearch.utils - Contains utility functions, which have no direct purpose, but are handy everywhere.
csvSearch.session - Contains functions that handle user session.
csvSearch.ui - Contains functions, which act only on current ui and dont connect to the server.
csvSearch.ctrl.main - Main controller. Bootstraps the application.
csvSearch.ctrl.uploadpage - Contains functions, to upload a file and manage the upload form.
csvSearch.ctrl.errorpage - Contains functions, to show errors of a file.
csvSearch.ctrl.searchpage - Contains functions, to search and display results
csvSearch.filterboxes - Contains functions, to display and update filterboxes.
csvSearch.option - Contains functions to set and update Options for the completesearch server directly from the frontend by the user.
csvSearch.share - Contains functions to share and load servers.

Contents

Javascript: csvSearch.urls

Description

Contains neccessary urls.

Javascript: csvSearch.utils

Description

Contains utility functions, which have no direct pourpose, but are handy everywhere.

toggleClass

$($selector[key]). toggleClass($class);

 toggleClass

function($selector, $class)

Description

  • Toggles a class on an elment when called.
  • Is able to handle multiple elements at once (passed as array)

Parameters

$selector - Either a jquery object or an array of jquery objects. Element(s) on which to toggle class.
$class - A string containing the class name to add or remove.

debounce

 debounce

function($func, $wait, $immediate)

Description

Returns a function, that, as long as it continues to be invoked, will not be triggered. The function will be called after it stops being called for N milliseconds. If `immediate` is passed, trigger the function on the leading edge, instead of the trailing.

Parameters

$func - The function to call.
$wait - The time to wait in miliseconds.
$immediate - If $immediate is passed, trigger the function on the leading edge, instead of the trailing.

delay

var delayedFunction = csvSearch.utils. delay(
csvSearch.ctrl.searchpage.doSearch,
800);

 delay

function($func, $wait)

Description

Returns a function, that will throthle calls to $func.

Parameters

$func - The function to call.
$wait - The time to wait in miliseconds.

getDimensions

csvSearch.utils. getDimensions();

Description

Get the dimensions of the current csv file from the server

Javascript: csvSearch.session

Description

Contains functions that handle user session.

checkSession

csvSearch.session. checkSession($callback);

 checkSession

function($ifactive)

Description

Checks if the user has an active session and calls the given function if so.

Parameters

$callback - A function to call. First argument is true if session exists.

removeSharedSessionHash

 removeSharedSessionHash

function()

Description

Removes a share session hash identifier.

Javascript: csvSearch.ui

Description

Contains functions, which act only on current ui and dont connect to the server.

init

 init

function()

Description

Toggles the hidden state of the forms on the site. Currently there are only two forms.

toggleForms

 toggleForms

function()

Description

Toggles the hidden state of the forms on the site. Currently there are only two forms.

addEventsToElements

 addEventsToElements

function()

Description

Adds events and event handlers to the elements.

cleanUp

csvSearch.ui. cleanUp();

 cleanUp

function()

Description

Go back to uploadform.

Javascript: csvSearch.ctrl.main

Description

Main controller. Bootstraps the application.

activate

$controller. activate();

 activate

function()

Description

Check user session. Dispatch to either
  • uploadpage, searchpage, errorpage or parseerrorpage

bootstrap

 bootstrap

function()

Description

Bootstrap application.

pushController

csvSearch.ctrl.main. pushController(csvSearch.ctrl.uploadpage);

 pushController

function()

Description

Add $controller to controller stack.

popController

ctrlManager. popController();

 popController

function()

Description

Remove top controller from controller stack.

dispatch

 dispatch

function()

Description

Dispatch application flow controllment to a subcontroller.

Javascript: csvSearch.ctrl.uploadpage

Description

Contains functions, to upload a file and manage the upload form.

unblock

csvSearch.ctrl.errorpage. unblock();

 unblock

function()

Description

Called by control manager when controller gets visible again.

block

csvSearch.ctrl.uploadpage. block();

 block

function()

Description

Called by control manager when controller gets hidden.

deactivate

 deactivate

function()

Description

Called by control manager when controller gets removed from stack.

setPageVisibility

csvSearch.ctrl.errorpage. setPageVisibility(true);

 setPageVisibility

function()

Description

Make search form/page (in)visible.

Parameter

$show - true to show page and false to hide

upload

input.simpleUpload(
csvSearch.urls.upload, { start: function() { ctrlManager.pushController(csvSearch.ctrl.loadingscreen);
var button1 = input.parents('.btn-file').find('.txt-bfr-upld');
var button2 = input.parents('.btn-file').find('.txt-aft-upld');
csvSearch.utils.toggleClass([button1, button2], 'hide');
}, progress: function(progress) { received progress $('.status').text("... Uploading your File ...");
$('.numprogress').text("Progress: " + Math.round(progress) + "%");
if (progress == 100) { $('.status').text("... Processing your File ...");
$('.numprogress').text("");
} }, success: function(data) { upload successful handle errors in csv file if (data == "error") { ctrlManager.popController();
csvSearch.ctrl.errorpage.errors = true;
ctrlManager.pushController(csvSearch.ctrl.errorpage);
} else if (data == "parse_error") { ctrlManager.popController();
csvSearch.ctrl.parseerrorpage.errors = true;
ctrlManager.pushController(csvSearch.ctrl.parseerrorpage);
} else { setTimeout(function () { ctrlManager.popController();
csvSearch.ctrl.errorpage.errors = false;
csvSearch.ctrl.parseerrorpage.errors = false;
ctrlManager.pushController(csvSearch.ctrl.searchpage);
csvSearch.option.createCheckboxes(data);
}, 3000);
} csvSearch.share.shared = false;
}, });

 upload

function($inputfield)

Description

Upload a given file and toggle forms.

Parameters

$inputfield - The input of type "file"

updateFilePath

csvSearch.ctrl.uploadpage. updateFilePath(inputfield);

 updateFilePath

function($inputfield)

Description

Update file path in span after user chose a file.

Parameters

$inputfield - The input of type "file" from which to take the path.

addEventsToPage

csvSearch.ctrl.errorpage. addEventsToPage();

 addEventsToPage

function()

Description

Adds change event to upload button, input and help-button.

Javascript: csvSearch.ctrl.errorpage

Description

Contains functions, to display errors in a file

getErrors

csvSearch.ctrl.parseerrorpage. getErrors();

Description

Display the errors of the CSV file

Javascript: csvSearch.ctrl.parseerrorpage

Description

Contains functions, to display errors if parsing failed

Javascript: csvSearch.ctrl.loadingscreen

Description

Contains functions, to display a simple loadingsceen

Javascript: searchpage-ctrl.js

Description

Contains functions to execute search, generating hits/completions

execSearch.

 execSearch = function(query, skip_filterbox_update, first) 

Description

Parameters

query - query for which shall be searched
skip_filterbox_update - true: filterboxes won't be updated,
false: filterboxes will be updated.
first - index from where the hits shall be sent.
(e.g 10 would skip the first 9 results and send from the 10th.)

doSearch.

 doSearch

function(query, skip_filterbox_update)

Description

Parameters

query - query for which shall be searched
skip_filterbox_update - true: filterboxes won't be updated,
false: filterboxes will be updated.

showCompletetions

Description

Parameters

data - JSON data, the answer of the Completesearch Server if you curl it with a query + format=json, already interpreted

showHits

 showHits

function(data, deleteOldResults)

Description

Parameters

data - JSON data, the answer of the Completesearch Server if you curl it with a query + format=json
deleteOldResults - true: old results will be deleted
false: old results will be preserved and new ones appended.

 addEventsToPage

function()

Description

Add events to search page.

Javascript: csvSearch.filterboxes

Description

handles generating and updating of Filterboxes

updateAllBoxes.

 updateAllBoxes

function(query, num)

Description

Function which updates all filterboxes for a given query

Parameters

query - query for which filterboxes shall be updated.
num - amount of box-entries you want initially.

updateBox.

 updateBox

function(is_filter, field, query, num)

Description

Function which updates a single Filterbox used if more button is clicked

Parameters

is_filter - bool
field - field which you want to create the box for
query - query for which filterbox shall be updated.
num - amount of box-entries you want initially.

showBox

 showBox

function(is_filter, field)

Description

Function to display Filterboxes.

Parameters

is_filter - bool
field - field which you want to create boxes for

selectBoxEntry

 selectBoxEntry

function(is_filter, field, entry, obj)

Description

function to select a Filterbox entry.

Parameters

is_filter - bool
field - field which you want to create boxes for
entry - entry which shall be selected.
obj - object to which selected class shall be added.

getQueryAdditions

 getQueryAdditions

function()

Description

Function which returns the query additions if you set filters. e.g. :filter:fieldname:entry such that the search server returns a filtered result.

Return

string, for filters and facets concatenated. e.g result = :filter:fieldname1:entry1 :facet:fieldname3:entry2

settingsChangedUpdateBoxes

csvSearch.filterboxes. settingsChangedUpdateBoxes();

 settingsChangedUpdateBoxes

function()

Description

Function wich will Update the Filterboxes if the settings have changed. basicly clears the list of selected Filters + Facets and recreates the boxes on an empty query.

resetFilters

 resetFilters

function() Description: Function which will reset the Filters and Facets, including Completions.

Javascript: csvSearch.option

Description

decodeFieldNames

var checkbox = "" + csvSearch.option. decodeFieldNames(
field) + "
";

Description

setOrigAndNewInfoDelimiter

csvSearch.option. setOrigAndNewInfoDelimiter(
backendOptions["orig-info-delimiter"],
backendOptions["shellOptions"]["PARSER_OPTIONS_CSV"]["info-delimiter"]);

Description

set the original info delimiter of the csv and the new (replaced) info delmiter

updateOptions

Description

createCheckboxes

Description

Parameters

data - backend Options in JSON format (PHP: Options Class // function: printData)

setOptions

Description

Parameters

backendOptions - backend Options in JSON format (PHP: Options Class // function: printData)

Javascript: csvSearch.share

Description

share.

shares a search-server.
 shareServer: function() 
Description:

load.

loads a search-server.
 load: function() 
Description:

display_link

Description

Created with TwinText