forked from dariok/officeEntityPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.js
59 lines (55 loc) · 1.35 KB
/
form.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
var conf =[];
$.ajax({
dataType: "json",
url: "config.json",
success: function (data) {
conf = data;
Object.keys(conf.types).forEach(function(key) {
$('#type').append($('<option>', { text:conf.types[key], value: key }));
});
setConf();
}
});
function setConf() {
var ajaxConf;
if (conf.authMode == "static token" && conf.token !== '' && conf.token !== 'undefined') {
ajaxConf = {
"x-access-token": conf.token
}
} else if (conf.authMode == "dynamic token") {
var local = localStorage.getItem("oepDynamicToken");
console.log(local);
ajaxConf = {
"x-access-token": local
}
} else {
ajaxConf = { }
}
$('#search-entity').select2({
minimumInputLength: 2,
/* tags: true, */
escapeMarkup: function (markup) {
return markup;
},
templateResult: function (data) {
return data.text;
},
templateSelection: function (data) {
return data.text;
},
ajax: {
url: function () { return conf.server + $('#type').val() + conf.suffix },
data: function (params) { return queryString (conf, params) },
headers: ajaxConf,
dataType: 'json',
processResults: function (data) {
return {
results: process(data)
};
},
error: function ( jqXHR, textStatus, errorThrown ) {
handleError ( jqXHR, textStatus, errorThrown );
}
}
});
}