Commit 0ca4e2f3 authored by Romain Loth's avatar Romain Loth

basic version of one search bar

parent d3fcaa96
...@@ -58,15 +58,28 @@ ...@@ -58,15 +58,28 @@
margin: 0 ; margin: 0 ;
padding: 0; padding: 0;
} }
/* small messages */
p.micromessage{
font-size: 85%;
color: #707070 ;
}
/* ------------- crowdsourcing proprement dit ----------------------- */ /* ------------- crowdsourcing proprement dit ----------------------- */
#crowdsourcing_intro{ #crowdsourcing_answer{
font-size: 85%;
color: #707070 ;
padding:0 1em ;
text-align:center ;
} }
#savesuggestion.btn { #crowdsourcing_answer p {
margin: 2px 0;
} }
#savesuggestion.btn {
}
#savesuggestion.btn[disabled], #savesuggestion.btn.disabled { #savesuggestion.btn[disabled], #savesuggestion.btn.disabled {
background-color: #B0B0B0 ; background-color: #B0B0B0 ;
......
...@@ -14,8 +14,9 @@ loadCSS(module_name+"/crowdTerms.css") ...@@ -14,8 +14,9 @@ loadCSS(module_name+"/crowdTerms.css")
loadJS(module_name+"/modal.js") ; loadJS(module_name+"/modal.js") ;
// histogram // histogram
loadJS(module_name+"/dygraph/dygraph.combined.js") ;
loadCSS(module_name+"/dygraph/gallery.css") ; loadCSS(module_name+"/dygraph/gallery.css") ;
loadCSS(module_name+"/dygraph/textarea.css") ; loadCSS(module_name+"/dygraph/textarea.css") ;
loadJS(module_name+"/dygraph/dygraph.combined.js") ;
console.log("OK LOADED " + module_name) ; console.log("OK LOADED " + module_name) ;
This diff is collapsed.
This diff is collapsed.
...@@ -11,6 +11,7 @@ function newPopup(url) { ...@@ -11,6 +11,7 @@ function newPopup(url) {
// Execution: ChangeGraphAppearanceByAtt( true ) // Execution: ChangeGraphAppearanceByAtt( true )
// It scans the existing node-attributes and t keeps only those which are Numeric. // It scans the existing node-attributes and t keeps only those which are Numeric.
// then, add the button in the html with the sigmaUtils.clustersBy(x) listener. // then, add the button in the html with the sigmaUtils.clustersBy(x) listener.
// [TODO: fonction un peu lourde dans le profilage]
function ChangeGraphAppearanceByAtt( manualflag ) { function ChangeGraphAppearanceByAtt( manualflag ) {
if ( !isUndef(manualflag) && !TW.colorByAtt ) TW.colorByAtt = manualflag; if ( !isUndef(manualflag) && !TW.colorByAtt ) TW.colorByAtt = manualflag;
......
...@@ -23,11 +23,16 @@ ...@@ -23,11 +23,16 @@
margin-bottom:1px; margin-bottom:1px;
} }
#defaultop{ #defaultop{
min-height: 5%; min-height: 5%;
max-height: 10%; max-height: 10%;
} }
/* searchnav gets same padding as bootstrap's .navbar-nav > li > a */
#defaultop div#searchnav {
padding-top: 13px;
padding-bottom: 9px;
}
#sigma-example { #sigma-example {
width: 100%; width: 100%;
height: 300px; height: 300px;
...@@ -45,6 +50,10 @@ ...@@ -45,6 +50,10 @@
.my-legend { .my-legend {
position:fixed; position:fixed;
/* width: we set it smaller than #leftcolumn container's width */
width:16%;
max-height: 40%;
overflow-y:scroll;
bottom:5px; bottom:5px;
left:5px; left:5px;
......
.fsslider { .fsslider {
position: relative; position: relative;
min-width: 100px; /* min-width: 100px; */
min-width: 75px;
height: 8px; height: 8px;
display: inline-block; display: inline-block;
width: 100%; width: 100%;
......
...@@ -51,6 +51,8 @@ var TW = {} ...@@ -51,6 +51,8 @@ var TW = {}
TW.SystemStates.opposites = []; TW.SystemStates.opposites = [];
TW.catSoc = "Document"; TW.catSoc = "Document";
TW.catSem = "NGram"; TW.catSem = "NGram";
TW.strSearchBar = "Select or suggest topics";
var ParseCustom = function () {}; var ParseCustom = function () {};
var SigmaUtils = function () {}; var SigmaUtils = function () {};
...@@ -67,7 +69,6 @@ var inactiveColor = '#666'; ...@@ -67,7 +69,6 @@ var inactiveColor = '#666';
var startingNodeId = "1"; var startingNodeId = "1";
var minLengthAutoComplete = 1; var minLengthAutoComplete = 1;
var maxSearchResults = 10; var maxSearchResults = 10;
var strSearchBar = "Search";
var cursor_size_min= 0; var cursor_size_min= 0;
var cursor_size= 0; var cursor_size= 0;
......
This diff is collapsed.
...@@ -833,6 +833,8 @@ function extractContext(string, context) { ...@@ -833,6 +833,8 @@ function extractContext(string, context) {
return begin_pts + str + end_pts; return begin_pts + str + end_pts;
} }
// TODO check duplicate function with sigmaUtils exactfind()
function searchLabel(string){ function searchLabel(string){
var id_node = ''; var id_node = '';
var n; var n;
......
...@@ -193,6 +193,46 @@ function rgbToHex(r, g, b) { ...@@ -193,6 +193,46 @@ function rgbToHex(r, g, b) {
} }
// lowercase etc query strings
normalizeString = function(string) {
if (! typeof string == "string") {
return "" ;
}
else {
return $.trim( string.toLowerCase() )
}
}
// html-escape user input strings
// /!\ TODO check if safe enough?
saferString = function(string) {
// TODO table in an outer scope
conversions = {
'&' : '&' ,
'<' : '&lt;' ,
'>' : '&gt;' ,
'"' : '&quot;' ,
"'" : '&apos;' ,
'%' : '&percnt;'
} ;
matchables = /[&<>"'%]/ ;
if (! typeof string == "string") {
return "" ;
}
else {
return string.replace(
matchables,
function(char) {
return conversions[char]
}
)
}
}
/** /**
* function to load a given css file * function to load a given css file
*/ */
...@@ -207,4 +247,4 @@ function rgbToHex(r, g, b) { ...@@ -207,4 +247,4 @@ function rgbToHex(r, g, b) {
loadJS = function(src) { loadJS = function(src) {
var jsLink = $("<script type='text/javascript' src='"+src+"'>"); var jsLink = $("<script type='text/javascript' src='"+src+"'>");
$("head").append(jsLink); $("head").append(jsLink);
}; };
\ No newline at end of file
...@@ -265,7 +265,7 @@ if(RES["OK"]) { ...@@ -265,7 +265,7 @@ if(RES["OK"]) {
console.log(typestring) console.log(typestring)
if(typestring=="0|1") { if(typestring=="0|1") {
$("#category0").hide();set_ClustersLegend $("#category0").hide();
$("#category1").show(); $("#category1").show();
if($("#slidercat1nodesweight").html()=="") if($("#slidercat1nodesweight").html()=="")
...@@ -364,6 +364,9 @@ if(RES["OK"]) { ...@@ -364,6 +364,9 @@ if(RES["OK"]) {
// load optional modules // load optional modules
ProcessDivsFlags() ; ProcessDivsFlags() ;
// grey message in the search bar from settings
$("#searchinput").attr('placeholder', TW.strSearchBar) ;
console.log("finish") console.log("finish")
......
...@@ -37,7 +37,12 @@ function cancelSelection (fromTagCloud) { ...@@ -37,7 +37,12 @@ function cancelSelection (fromTagCloud) {
$("#searchinput").val(""); $("#searchinput").val("");
$("#unselectbutton").hide(); $("#unselectbutton").hide();
$("#tips").html(getTips()); $("#tips").html(getTips());
} }
// we send our "eraseNodeSet" event
// (signal for plugins that any selection behavior is finished)
$('#searchinput').trigger("tw:eraseNodeSet");
for(var i in deselections){ for(var i in deselections){
if( !isUndef(TW.partialGraph._core.graph.nodesIndex[i]) ) { if( !isUndef(TW.partialGraph._core.graph.nodesIndex[i]) ) {
TW.partialGraph._core.graph.nodesIndex[i].forceLabel=false; TW.partialGraph._core.graph.nodesIndex[i].forceLabel=false;
......
...@@ -27,6 +27,8 @@ SigmaUtils = function () { ...@@ -27,6 +27,8 @@ SigmaUtils = function () {
if(Number(n.id)==287) console.log("coordinates of node 287: ( "+n.x+" , "+n.y+" ) ") if(Number(n.id)==287) console.log("coordinates of node 287: ( "+n.x+" , "+n.y+" ) ")
graph.addNode( n.id , node); graph.addNode( n.id , node);
// fill the "labels" global variable
updateSearchLabels( n.id , n.label , n.type); updateSearchLabels( n.id , n.label , n.type);
} }
} }
...@@ -148,17 +150,20 @@ function gete(id){ ...@@ -148,17 +150,20 @@ function gete(id){
} }
function find(label){ function find(lquery){
var results=[]; var results=[];
var nds=getnodesIndex(); if (typeof lquery == 'string' && lquery.length > 0) {
label=label.toLowerCase() lquery=lquery.toLowerCase() ;
for(var i in nds){ var nds=getnodesIndex();
var n=nds[i]; for(var i in nds){
if(n.hidden==false){ var n=nds[i];
var possiblematch=n.label.toLowerCase() if(n.hidden==false){
if (possiblematch.indexOf(label)!==-1) { var possiblematch=n.label.toLowerCase()
results.push(n); // string.indexOf(substring) faster than search/match
} if (possiblematch.indexOf(lquery)!==-1) {
results.push(n);
}
}
} }
} }
return results; return results;
...@@ -166,11 +171,13 @@ function find(label){ ...@@ -166,11 +171,13 @@ function find(label){
function exactfind(label) { function exactfind(label) {
nds=getnodesIndex(); nds=getnodesIndex();
for(var i in nds){ if (typeof lquery == 'string' && lquery.length > 0) {
n=nds[i]; for(var i in nds){
if(!n.hidden){ n=nds[i];
if (n.label==label) { if(!n.hidden){
return n; if (n.label==label) {
return n;
}
} }
} }
} }
...@@ -387,4 +394,4 @@ function makeEdgeWeightUndef() { ...@@ -387,4 +394,4 @@ function makeEdgeWeightUndef() {
for(var e in TW.partialGraph._core.graph.edges) { for(var e in TW.partialGraph._core.graph.edges) {
TW.partialGraph._core.graph.edges[e].weight=1; TW.partialGraph._core.graph.edges[e].weight=1;
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment