Changeset 6834


Ignore:
Timestamp:
11/23/15 10:48:31 (8 years ago)
Author:
matej.durco@oeaw.ac.at
Message:

clean up of files and code

Location:
SMC/trunk/SMC/src/web
Files:
1 deleted
7 edited
1 moved

Legend:

Unmodified
Added
Removed
  • SMC/trunk/SMC/src/web/index.html

    r5299 r6834  
    1 <!DOCTYPE html>
     1<?xml version="1.0" encoding="UTF-8"?>
    22<html xmlns="http://www.w3.org/1999/xhtml">
    3 <head>
    4 <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    5 <title>CLARIN SMC Browser</title>
     3    <head>
     4        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
     5        <title>CLARIN SMC Browser</title>
     6        <link rel="stylesheet" href="scripts/style/jquery/clarindotblue/jquery-ui-1.8.5.custom.css" type="text/css" />
     7        <link href="scripts/style/cmds-ui.css" type="text/css" rel="stylesheet" />
     8        <link href="scripts/style/smc-graph.css" media="screen" rel="stylesheet" type="text/css" />
    69
    7         <link rel="stylesheet" href="scripts/style/jquery/clarindotblue/jquery-ui-1.8.5.custom.css" type="text/css" />
    8         <link href="scripts/style/cmds-ui.css" type="text/css" rel="stylesheet" />
    9         <link href="scripts/style/smc-graph.css" media="screen" rel="stylesheet" type="text/css" />
    10        
    11 <script src="scripts/js/d3.v2.js" type="text/javascript" ></script>     
    12 <script src="scripts/js/jquery/jquery-1.4.2.js" type="text/javascript"></script>
    13 <script src="scripts/js/jquery/jquery-ui-1.8.5.custom.min.js" type="text/javascript"></script>
    14 <!--
    15 <script src="scripts/jquery/jquery-treeview/jquery.treeview.js" type="text/javascript"></script>
    16 <script src="scripts/jquery/jquery-treeTable/jquery.treeTable.js" type="text/javascript"></script>
     10        <script src="scripts/js/d3.js" type="text/javascript"></script>
     11        <script src="scripts/js/jquery/jquery-1.10.2.js" type="text/javascript"></script>
     12        <script src="scripts/js/jquery/jquery-ui-1.10.4.custom.min.js" type="text/javascript"></script>
     13        <script src="scripts/js/jquery/jquery.layout-latest.js" type="text/javascript"></script>
     14        <script src="scripts/js/mdservice/mdservice_ui_helpers.js" type="text/javascript"></script>
     15         <script src="scripts/js/query_input/qi.js" type="text/javascript"></script>
     16                                <script src="scripts/js/query_input/lib/URI.js" type="text/javascript"></script>
    1717
    18 <script src="scripts/jquery/jsTree.v.1.0rc2/jquery.jstree.js" type="text/javascript"></script>
    19 <script src="scripts/jquery/jquery-autocomplete/jquery.autocomplete.js" type="text/javascript"></script>-->
    20 <script src="scripts/js/jquery/jquery.layout-1.3.0.rc29.12.js" type="text/javascript"></script>
    21 
    22 
    23 <script src="scripts/js/mdservice/mdservice_helpers.js" type="text/javascript"></script>
    24 <script src="scripts/js/mdservice/mdservice_ui_helpers.js" type="text/javascript"></script>
    25         <script src="scripts/js/query_input/qi.js" type="text/javascript"></script>
    26        
    27 <!--<script src="scripts/js/ui_helpers.js" type="text/javascript"></script>-->
    28 <script src="scripts/js/mdservice/mdservice_widgets.js" type="text/javascript"></script>
    29 <!--    <script src="scripts/js/mdservice/mdservice_model.js" type="text/javascript"></script>-->
    30        
    31         <!--<script src="scripts/js/mdservice/mdservice_searchclause.js" type="text/javascript"></script>
    32                 <script src="scripts/js/mdservice/mdservice_pz2.js" type="text/javascript"></script>
    33                 <script src="scripts/js/mdservice/mdservice_ui_detail.js" type="text/javascript"></script>
    34                 <script src="scripts/js/mdservice/mdservice_ui_load.js" type="text/javascript"></script> -->
    35        
    36         <script src="scripts/js/smc-graph.js" type="text/javascript"></script>
    37         <script src="scripts/js/ui_settings.js" type="text/javascript"></script>
    38         <script src="scripts/js/ui.js" type="text/javascript"></script>
    39        
    40 </head>
    41 
    42 <body>
     18        <script src="scripts/js/config.js" type="text/javascript"></script>
     19        <script src="scripts/js/smc-graph.js" type="text/javascript"></script>
     20        <script src="scripts/js/ui_settings.js" type="text/javascript"></script>
     21        <script src="scripts/js/main.js" type="text/javascript"></script>
     22    </head>
     23    <body>
    4324
    4425<!--  - BLOCK -->
    45 <div class="cmds-ui-block" id="header">
    46                         <span id="logo"><a href="http://www.clarin.eu"><img
    47                                                 src="scripts/style/imgs/clarin-logo.png" alt="CLARIN" /></a>
    48                         </span>
    49                         <div id="site-name">SMC Browser</div>
    50         <span id="top-menu">
    51                                 <!-- class="open-in-context"  -->
    52                                 <a href="."> home </a>
    53                                 <a target="_blank" href="docs/userdocs.html"> docs</a>
    54                                 <a target="_blank" href="smc_stats.html"> stats</a>
    55                 <a target="_blank" href="docs/examples.html"> examples</a>
    56                 <a target="_blank" href="docs/reports.html"> reports</a>
    57                         </span>
    58                
    59                         <div id="notify" class="cmds-elem-plus note">
    60                                 <div id="notifylist" class="note">
     26        <div class="cmds-ui-block" id="header"><span id="logo"><a href="http://www.clarin.eu"><img src="scripts/style/imgs/clarin-logo.png" alt="CLARIN" /></a></span>
     27            <div id="site-name">SMC Browser</div><span id="top-menu">
     28                                <!-- class="open-in-context"  --><a href="."> home </a><a target="_blank" href="docs/userdocs.html"> docs</a><a target="_blank" href="data/smc_stats_summary1.html"> stats</a><a target="_blank" href="docs/examples.html"> examples</a><a target="_blank" href="docs/reports.html"> reports</a></span>
     29            <div id="notify" class="cmds-elem-plus note">
     30                <div id="notifylist" class="note">
    6131                                        <!--  class="cmds-elem-plus note" > -->
    62                                 </div>
    63                         </div>
    64                 </div>
    65 
    66         <div id="navigate" class="block">navigate
     32                </div>
     33            </div>
     34        </div>
     35        <div id="navigate" class="block">navigate
    6736                <!--<label for="input-depth-before">before</label><input type="text" id="input-depth-before" value="1" size="3"/>
    6837                <label for="input-depth-after">after</label><input type="text" id="input-depth-after" value="1" size="3"/> -->
    69         </div>
    70        
    71                 <div id="index-container" class="block"><h3>Index <input type="text" id="input-filter-index" size="10" /></h3>
    72                
    73                 </div>
    74         <div id="infovis-wrapper">
    75                 <div id="infovis">graph</div>
    76         </div>
    77                 <div id="detail-container" class="block"><h3>Detail</h3></div>
    78         <div id="detail-info-holder" class="data"></div>
     38        </div>
     39        <div id="index-container" class="block">
     40            <h3>Index <input type="text" id="input-filter-index" size="10" />
     41            </h3>
     42        </div>
     43        <div id="infovis-wrapper">
     44            <div id="infovis">graph</div>
     45        </div>
     46        <div id="detail-container" class="block">
     47            <h3>Detail</h3>
     48        </div>
     49        <div id="detail-info-holder" class="data"></div>
    7950       
    8051       
     
    8657                <div class="content" id="query-input" >         
    8758                -->
    88                
    89 </body>
    90 
     59    </body>
    9160</html>
  • SMC/trunk/SMC/src/web/scripts/js/config.js

    r5978 r6834  
    11
    22var config ={
    3        "url": {"data_prefix":"data/",
    4                 "detail":"get.xql" ,
     3       "url": {// "data_prefix":"data/",
     4                 "data_prefix":"/graph-data/",
     5                //"detail":"get.xql" ,
     6                "detail":"http://localhost:8082/exist/rest/db/cr-projects/tester/get.xql?key=",
    57             //  "detail":"http://localhost:8580/exist/apps/smc-browser/get.xql" ,
    68            // "detail":"data/smc_stats_detail.html",
     
    1820
    1921// configuration of the navigation widgets
    20 var opts = {"graph": {"value":"smc-graph-basic.js",
    21                     "values":[{value: "smc-graph-basic.js", label:"SMC graph basic"},
    22                               {value: "smc-graph-all.js", label:"SMC graph all"},                             
    23                               {value: "smc-graph-profiles-datcats.js", label:"only profiles + datcats"},
    24                               {value: "smc-graph-groups-profiles-datcats-rr.js", label:"profiles+datcats+groups+rr"},
    25                               {value: "smc-graph-profiles-similarity.js", label:"profiles similarity"}                             
    26                               /*{value: "dbpedia_philosophers_influence_years_graph.json", label:"Philosophers"},
    27                               {value: "SC_Persons_120201_cAll_graph.json", label:"Schnitzler Cooccurrences"},*/
     22var opts = {"graph": {"value":"issues/issues_all_c747_2015-03-20_graph.json",
     23                    "values":[{value: "smc/smc-graph-basic.js", label:"SMC graph basic"},
     24                              {value: "smc/smc-graph-all.js", label:"SMC graph all"},                             
     25                              {value: "smc/smc-graph-profiles-datcats.js", label:"only profiles + datcats"},
     26                              {value: "smc/smc-graph-groups-profiles-datcats-rr.js", label:"profiles+datcats+groups+rr"},
     27                              {value: "smc/smc-graph-profiles-similarity.js", label:"profiles similarity"},                             
     28                              {value: "philosophers/dbpedia_philosophers_influence_years_graph.json", label:"Philosophers"},
     29                              {value: "SC_Persons_120201_cAll_graph.json", label:"Schnitzler Cooccurrences"},
     30                              {value: "issues/issues_all_c747_2015-03-20_graph.json", label:"Issues"},
     31                             
    2832                              /*,
    2933                              {value: "smc-graph-mdrepo-stats.js", label:"instance data"}*/
  • SMC/trunk/SMC/src/web/scripts/js/main.js

    r5978 r6834  
    1 
    21/**
    3  * @fileOverview This is based on mdservice/mdservice_ui.js, but removed all unused code.
    4  *  This is the main file, contains main app function (jquery-initialization).
    5  * The app main function runs setup functionality, which covers this domains:
    6  * <dl>
    7  * <dt>the variable initialization<dt>
    8  *      <dd>functions from mdservice_searchclause.js, mdservice_widget.js, mdservice_ui_helpers.js</dd>
    9  * <dt>loadData()</dt>
    10  *      <dd>loading data from repository and creating particular client-side representations  - functions from <a>mdservice_ui_load.js</a></dd>
    11  * <dt>creating of ui-layout</dt>
    12  *      <dd>i.e. split UI to individual panes  - functions from mdservice_ui_layout.js</dd>
    13  * <dt>addFunctionality()</dt>
    14  *      <dd>bind handlers to events of ui-elements (function directly in mdservice_ui.js)</dd>
    15  * </dl>
    16  * @author
     2 * @fileOverview
     3 *  This is the main file. Invokes app initialization on ready()
     4 * @author vronk
    175 * @version
    186 */
    19 
    207
    218var index_container_selector = "#index-container";
     
    2411var detail_container_selector = "#detail-container";
    2512var detail_info_holder_selector =  '#detail-info-holder';
    26 
    2713var graph_container = null;
    2814var index_container = null;
    2915
    30 
    3116$(function(){
    32                 // turn on debugging (see jquery.xslTransform.js)
    33                 var DEBUG = false;
    34        
     17               
    3518                // check for jQuery
    3619                try{
     
    4124       
    4225        graph_container = $(graph_container_selector);
    43    
    44                 /////// INIT VARIABLE SETTINGS
    45                 url_params = getUrlVars();
    46 //              workspace = new Workspace();
    47                
    48                 // create widgets
    49         /*      columns_widget = new ListWidget($('#columns-widget'), "columns");
    50                 collections_widget = new ListWidget($('#collections-widget'), "collections");
    51                 listwidgetset.add(columns_widget);
    52                 listwidgetset.add(collections_widget);
    53                 */
    54                 //////////// LOAD DATA
    55                 // loadData();
    56        
    5726       
    5827  // loading userdocs as welcome info
     
    6029 
    6130                loadDetailInfo ();
    62                
    6331       
    6432        addFunctionality();
     
    6937                createBlock('base','');
    7038                createLayouts('base');
    71 
    72      
     39       
    7340       
    7441});
    75 
    7642
    7743/**
     
    8147function addFunctionality(){
    8248       
    83         $("#input-filter-index").live('change', function(event) {       
     49//      $("#input-filter-index").live('change', function(event) {
     50    $( document ).on( "change", '#input-filter-index', function(event) {       
    8451               filterIndex ($(this).val());
    8552        });
     
    8855    $("#navigate .slider").slider();
    8956    */
    90      $("#navigate").QueryInput({params: opts,
    91             onValueChanged: renderGraph
    92             });
     57      $("#navigate").QueryInput({params: opts,             onValueChanged: renderGraph             });
    9358   
    9459  /*  $('#infovis-wrapper').resizable( {
     
    10974                   });
    11075    */
    111     $('#input-download').live("mousedown", genDownload);
    11276   
    113  $(".detail-caller").live("click", function(event) {
     77    //$('#input-download').live("mousedown", genDownload);
     78    $( document ).on( "mousedown", '#input-download', genDownload);
     79   
     80// $(".detail-caller").live("click", function(event) {
     81 $( document ).on( "click", '.detail-caller', function(event) {
    11482                //console.log(this);
    11583                event.preventDefault();
     
    11785              });
    11886
    119  $(".node-item .detail a").live("click", function(event) {
     87// $(".node-item .detail a").live("click",
     88 $( document ).on( "click", '.node-item .detail a', function(event) {
    12089                event.preventDefault();               
    12190                key = $(this).attr("data-key");
    12291                console.log(key);
    12392                selectNodeByKey([key]);
    124                
    12593              });
    12694
    127 
    128 $("a.scan").live("click", function(event) {
    129                 console.log(this);
     95//$("a.scan").live("click", function(event) {
     96 $( document ).on( "click", 'a.scan', function(event) {
     97               console.log(this);
    13098                event.preventDefault();
    13199                url = $(this).attr("href");
     
    133101                $(this).parent().find('.node-detail').load(url + " div.content");
    134102              });
    135 
    136 
    137103}
  • SMC/trunk/SMC/src/web/scripts/js/mdservice/mdservice_ui_helpers.js

    r2438 r6834  
    2424        var settings;
    2525        if (layout_initialisation[name].settings == ""){
    26                 settings = new CloneObject(layout_initialisation[name].model_settings);
     26                // settings = new CloneObject(layout_initialisation[name].model_settings);
     27                settings = jQuery.extend(true, {}, layout_initialisation[name].model_settings );
    2728        } else {
    2829                settings = layout_initialisation[name].settings;
  • SMC/trunk/SMC/src/web/scripts/js/query_input/qi.js

    r5302 r6834  
    11
    2 // jQuery closure
    3 (function($) {
    4 
    5 /**
    6  * @class QueryInput
     2// Module QueryInput
     3// provides a jQuery plugin with the same name.
     4!function ($, console) {
     5    // could expose the defaults: $.fn.QueryInput.defaults =
     6    //{q:{label:"Query", widget:"text"}, submit:{value:"Search", widget:"submit"}}
     7    var defaults = {
     8        params: {},
     9        input_prefix: "input-",
     10        slider_style: {width: "80px", display: "inline-block", "font-size": "70%", margin: "6px 12px 0 2px"},
     11        onValueChanged: function () {},
     12        fcs_source: "http://193.170.82.207:8680/exist/apps/sade/amc/fcs?operation=scan&x-format=json&scanClause="
     13    };
     14   
     15    var module = {};
     16
     17    /**
     18     * @class QueryInput
    719 * generate a customizable query_input UI, a input form with fields/widgets based on settings
    820 * options: multiple params/fields,
     
    1527 */
    1628/* we could make it a class (instead of jQuery plugin)
    17        function QueryInput(elem,s) */     
    18 $.fn.QueryInput = function (options)
     29       function QueryInput(elem,s) */
     30    module.QueryInput = function (options)
    1931{
    2032   /** the dom-element to generate the query input in */
     
    2537      */
    2638   var settings = $.extend(true, {}, defaults, options);
    27     blendInParams(settings.params, getUrlParams(location.search)) 
    28    
    29    // makes the settings publicly available as .data("qi")
     39       
     40        /** gets the current value for a parameter
     41         * accepting settings as reliable source of current value
     42         * i.e. changes in input have to change the .value in settings.
     43         * This is assured by calling setParamValue upon input-change.
     44         * public by calling: $(elem).data("qi").getParamValue(param_key);
     45         * @public
     46         */
     47        settings.getParamValue = function (key) {
     48            if (this.params[key]) {
     49                return this.params[key].value;
     50            } else {
     51                return "";
     52            }
     53        };
     54
     55        /** allow to update the current value in settings from outside */
     56        settings.setParamValue = function (key, value) {
     57
     58            if (settings.params[key]) {
     59                settings.params[key].value = value;
     60            }
     61            // callback:
     62            settings.onValueChanged.call(settings, value);
     63            return value;
     64        };
     65     
     66    blendInParams(); 
     67
     68        // makes the settings publicly available as .data("qi")
    3069   elem.data("qi",settings);
    3170   init(settings);   
     
    4584      for ( var key in params ) {
    4685         var param = params[key];
     86         console.log("creating widget: " + param.widget + " for: " + key);
    4787        // if input already exists - fill it with the default value
    4888        if ($('#' + settings.input_prefix + key).length) {
     
    5090         } else if (trg_container)  {
    5191            var label= param.label ? param.label : key;
    52             var new_input_label = param.label=='' ? '' : "<label>" + label+ "</label>";
    53             var new_input=null, new_widget=null;
     92            var new_input_label = param.label === '' ? $('') : $(
     93                            "<label for='" + settings.input_prefix + key + "'>" + label+ "</label>"
     94                            );
     95                    var new_input=null, new_widget=null;
    5496           
    5597            switch (param.widget) {
     
    5799                  new_input = genText(key, param);   
    58100                  break;
     101                case "checkbox":
     102                  new_input = genCheckBox(key, param);
     103                  break;
     104                case "hidden":
     105                  new_input = genHidden(key, param);
     106                  break;
    59107                case "submit":
    60108                  new_input = genSubmit (key, param);   
     
    63111                  new_input = genCombo(key, param);   
    64112                  break;
    65                 case "autocomplete":
     113                case "multiselect":
     114                            var elems = genMultiselect(key, param);
     115                            new_input = elems[0];
     116                            new_widget = elems[1];
     117                            break;
     118                        case "autocomplete":
    66119                  new_input = genAutocomplete (key, param);   
    67120                  break;
    68121               case "cql":
    69                   var cql_elems = genCQLInput(key, param);
     122                  var cql_elems = QueryInput_CQL.genCQLInput(key, param);
    70123                  new_input = cql_elems[0];
    71124                  new_widget = cql_elems[1];
    72125                  break;
    73                 case "link":
     126                case "vkb-cql":                       
     127                            var cql_elems = QueryInput_CQL.genCQLInput(key, param);
     128                            new_input = genVKBCombo(key, param, cql_elems[0]);
     129                            new_widget = cql_elems[1];
     130                            break;
     131                        case "link":
    74132                  new_input = genLink (key, param);   
    75133                  break;
     
    80138                  break;
    81139                default:
    82                   console.log("no such widget: " + param.widget);
     140                  console.log("no such widget: " + param.widget + " for: " + key);
    83141              }   
    84142       
    85143          if (new_input) {
    86             $(new_input).data("key", key)
    87                         .addClass("type-" + param.widget)
    88                              .attr("id", settings.input_prefix + key)
     144                        var new_input = $(new_input);
     145                        new_input.data("key", key)
     146                        .addClass("type-" + param.widget + (param.additional_classes === undefined ? '' :  ' ' + param.additional_classes))
     147                                .attr("id", settings.input_prefix + key)
    89148                             .data("param-object", param);
    90149                     
    91             if (param.widget!="link") {
     150            if (param.data !== undefined) {
     151                            for (var k in param.data) {
     152                                new_input.attr("data-" + k, param.data[k]);
     153                            }
     154                        }
     155                       
     156                        if (param.widget !== "link") {
    92157                 // set initial valuelink
    93158                 $(new_input).val(param.value);
     
    96161                new_input.change(function () {
    97162                           setParamValue(this);
    98                      });
    99                }           
    100                
    101              $(form).append(new_input_label, new_input, new_widget);
    102             // inputs.push(key, new_input_label, new_input, new_widget]);
    103            }
    104          }
    105        } // end for
     163                            });
     164                        }
     165                       
     166                        if (new_input_label !== undefined) {
     167                            new_input_label.attr('for', settings.input_prefix + key);
     168                            if (param.additional_label_classes !== undefined) {
     169                                new_input_label.addClass(param.additional_label_classes);
     170                            }
     171                        }
     172                        if (settings.params[key].label_after_input === true) {
     173                            $(form).append(new_input, new_input_label, new_widget);
     174                        } else {
     175                            $(form).append(new_input_label, new_input, new_widget);
     176                        }
     177                    }
     178                }
     179            } // end for
    106180       
    107181       
     
    121195         $(input).attr("name",key);
    122196         
    123         return input;
    124     }
    125    
    126     function genLink(key, param_settings) {
    127          
    128         var a = $("<a>" + key + "</a>");
     197        if (param_settings.size)
     198                $(input).attr("size", param_settings.size);
     199
     200            return input;
     201    }
     202   
     203    function genCheckBox(key, param_settings) {
     204         
     205        var input = $("<input type='checkbox'/>");
     206            $(input).attr("name", key);
     207            if (param_settings.checked !== undefined)
     208                $(input).attr("checked", param_settings.checked);
     209
     210            return input;
     211        }
     212       
     213        function genVKBCombo(key, param_settings, preconfigured_input) {
     214            preconfigured_input.attr("data-context", param_settings.cql_config.settings.context);
     215            preconfigured_input.addClass("virtual-keyboard-input");
     216            var input = $('<span class="virtual-keyboard-input-combo virtual-keyboard-input-above">' +
     217                        $('<div>').append(preconfigured_input).html() +
     218                        '<input type="checkbox" value="unused" class="virtual-keyboard-toggle" id="vkbt' + key + '"/>' +
     219                        '<label for="vkbt' + key + '" class="virtual-keyboard-first-three">ÀöÌ</label>');
     220           
     221            return input;
     222        }
     223
     224        function genHidden(key, unused) {
     225
     226            var input = $("<input type='hidden'  />");
     227            $(input).attr("name", key);
     228
     229            return input;
     230        }
     231
     232        function genLink(key, unused) {
     233
     234            var a = $("<a>" + key + "</a>");
    129235        a.attr("href", generateLink());
    130236       
     
    152258       if (param_settings.static_source) {
    153259              //var scanURL = settings.fcs_source +  param_settings.index
    154               var source_url = param_settings.static_source.replace(/&amp;/g,'&');
    155               // if static source - try to retrieve the data
     260              var source_url = param_settings.static_source.replace(/&amp;/g, '&');
     261                // if static source - try to retrieve the data
    156262              $.getJSON(source_url, function(data) {
    157                     param_settings.values = data.terms
    158                     param_settings.values.forEach(function(v) { $(select).append("<option value='" + v.value +"' >" + v.label + "</option>") });
     263                    param_settings.values = data.terms;
     264                    param_settings.values.forEach(function(v) { $(select).append("<option value='" + v.value + "' >" + v.label + "</option>") });
    159265                    //console.log($(input).autocomplete().source);
    160266              });
     
    184290        if (param_settings.static_source) {
    185291              //var scanURL = settings.fcs_source +  param_settings.index
    186               var source_url = param_settings.static_source.replace(/&amp;/g,'&');
    187               // if static source - try to retrieve the data
     292              var source_url = param_settings.static_source.replace(/&amp;/g, '&');
     293                // if static source - try to retrieve the data
    188294              $.getJSON(source_url, function(data) {
    189295                    param_settings.source = data.terms
     
    198304         
    199305        return input;
    200     }
    201 
    202    
    203     function fcsScan(request, response) {
    204         response( $.ui.autocomplete.filter(
    205                           scan.terms, request.term ) );
    206                                         // extractLast( request.term )
     306        }
     307
     308        /** generate a multiselect*/
     309        function genMultiselect(key, param_settings) {
     310
     311            var parent = $("<div/>");
     312            var select = $("<select multiple='multiple' id='widget-" + key + "' />");
     313            select.attr("name", key);
     314            //select.attr("id", settings.input_prefix + key)
     315            parent.append(select);
     316
     317            if (param_settings.static_source) {
     318                //var scanURL = settings.fcs_source +  param_settings.index
     319                var source_url = param_settings.static_source.replace(/&amp;/g, '&');
     320                // if static source - try to retrieve the data
     321                $.getJSON(source_url, function (data) {
     322                    param_settings.values = data.terms
     323                    param_settings.values.forEach(function (v) {
     324                        $(select).append("<option value='" + v.value + "' >" + v.label + "</option>")
     325                    });
     326                    //console.log($(input).autocomplete().source);
     327                });
     328
     329                //param_settings.source = fcsScan;
     330    }
     331
     332   
     333    else if (param_settings.values) {
     334                //    $(input).autocomplete(param_settings);
     335                param_settings.values.forEach(function (v) {
     336                    $(select).append("<option value='" + v + "' >" + v + "</option>")
     337                });
     338            } else { /* if no values,  rather make a textbox out of it? */
     339                //select =
     340            }
     341
     342            select.attr("id", settings.input_prefix + key)
     343            select.chosen(param_settings);
     344            return [select, parent.find("#input_context_chosen")];
     345        }
     346
     347
     348        function fcsScan(request, response) {
     349        response($.ui.autocomplete.filter(
     350                          scan.terms, request.term));
     351            // extractLast( request.term )
    207352    }
    208353         
     
    226371                        .data("related-widget",new_widget);
    227372                     
    228             new_widget.bind( "slidechange", function(event, ui) {
     373            new_widget.bind("slidechange", function(event, ui) {
    229374                $(this).data("related-input-field").val(ui.value);
    230375                // update the settings-object, but with the (updated) value of the related input-field
     
    235380            new_input.bind("change", function () {
    236381                   var related_widget = $(this).data("related-widget");
    237                    if ( $(related_widget).hasClass("widget-slider")) {$(related_widget).slider("option", "value", $(this).val()); }
     382                   if ($(related_widget).hasClass("widget-slider")) {
     383                    $(related_widget).slider("option", "value", $(this).val()); }
    238384             });
    239385             
     
    241387    }
    242388   
    243    
    244     /** gets the current value for a parameter
    245         accepting settings as reliable source of current value
    246         i.e. changes in input have to change the .value in settings.
    247         This is assured by calling setParamValue upon input-change.
    248         public by calling: $(elem).data("qi").getParamValue(param_key);
    249         @public
    250     */
    251     settings.getParamValue = function(key) {
    252          if (this.params[key])  {
    253             return this.params[key].value
    254          } else {
    255             return ""
    256          }
    257     }
    258 
    259     /** allow to update the current value in settings from outside */
    260     settings.setParamValue = function(key, value) {
    261        
    262         if (settings.params[key]) {
    263             settings.params[key].value = value
    264         }
    265         // callback:
    266         settings.onValueChanged.call( settings,value );
    267         return value   
    268     }
    269389   
    270390    /** update the current value in settings */
     
    277397        // callback:
    278398        settings.onValueChanged.call( input_object,value );
    279         return value   
    280     }
    281    
    282    
    283     /** get params from the uri */
    284     function getUrlParams(url)
    285     {
    286       var urlParams = {};
    287       if (url != undefined)
    288       {
    289         var match;
    290         var pl     = /\+/g;  // Regex for replacing addition symbol with a space
    291         var search = /([^&=]+)=?([^&]*)/g;
    292         var decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); };
    293    
    294         var query  = "";
    295         var qmPos = url.indexOf('?');
    296         if (qmPos != -1)
    297           query = url.substr(qmPos + 1);
    298         else
    299           query = url;
    300    
    301         while (match = search.exec(query))
    302            urlParams[decode(match[1])] = decode(match[2]);
    303       }
    304    
    305       return urlParams;
    306     }
    307 
    308     function blendInParams(settings_params, params) {
    309        
    310        for ( var key in settings_params ) {
    311             if (params[key]) {settings_params[key].value=params[key]; }     
    312        }
    313     }
    314 
    315  /** generate a query-link out of the current values of the params */
     399        return value;
     400        }
     401
     402        /** generate a query-link out of the current values of the params */
    316403    function generateLink()
    317404    {
    318       var url="?";
    319      
    320        for ( var key in settings.params) {
     405      var url = "?";
     406
     407            for ( var key in settings.params) {
    321408           if (settings.params[key].value) {
    322409                 url += key + "=" + settings.params[key].value + "&";
    323410             }     
     411            }
     412           
     413           return url;
    324414       }
    325        
    326       return url;
    327     }
    328 
    329 
    330 // }   
    331  
    332 }     // end $.fn.QueryInput
    333 
    334    
    335     // could expose the defaults: $.fn.QueryInput.defaults =
    336     //{q:{label:"Query", widget:"text"}, submit:{value:"Search", widget:"submit"}}
    337     var defaults = {params: {},
    338                     input_prefix:"input-",
    339                     slider_style:{width:"80px", display:"inline-block", "font-size": "70%",  margin: "6px 12px 0 2px"},
    340                     onValueChanged : function() {},
    341                     fcs_source: "http://193.170.82.207:8680/exist/apps/sade/amc/fcs?operation=scan&x-format=json&scanClause="
    342                     };
    343    
     415
     416    /** overwrite settings with param-values from the URL-search string if available
     417       not using $.extend(), because we still want only known/defined params overriden, not adding new params that might be in the url (?) */
     418       function blendInParams() {
     419           var params= getUrlParams();
     420             for ( var key in settings.params ) {
     421                if (params[key]) {settings.params[key].value=params[key]; }
     422             }
     423       }
     424 
     425         /** get params from the uri */
     426        function getUrlParams() {
     427            var currentURI = new URI();
     428            var params = currentURI.search(true);
     429            return params;
     430        }
     431
     432
     433
     434  };     // end $.fn.QueryInput
     435
     436
    344437    /* TODO: add defaults for widgets, like:
    345438     widgets: {slider: {style:{width:"80px", display:"inline-block", "font-size": "70%",  margin: "6px 12px 0 2px"}}},
    346     */
    347 
    348 })(jQuery, this);
    349 
     439     */
     440   
     441    // publish;
     442    // this.QueryInput = module;
     443    $.fn.QueryInput = module.QueryInput;
     444
     445}(jQuery, console);
     446
  • SMC/trunk/SMC/src/web/scripts/js/smc-graph.js

    r5978 r6834  
    7373                    if (json==null) { notifyUser("source data missing: " + graph_source ); return null}           
    7474                    data_all = json;
     75                    data_all.nodes_index = {};
     76                    data_all.nodes.forEach(function(d){           
     77                        data_all.nodes_index[d.key] = d;
     78                    });
     79                   
    7580                    data_all.links.forEach(function(d) {
    7681                                        //resolve numeric index to node references
    7782                                                src_ix = d.source;
    78                                                 d.source = data_all.nodes[src_ix];
    79                                                 d.source.index = src_ix;
     83                                                d.source = data_all.nodes_index[src_ix];
     84                                                //d.source.index = src_ix;
    8085                                                trg_ix = d.target;
    81                                                 d.target = data_all.nodes[trg_ix];
    82                                                 d.target.index = trg_ix;
    83                                                 src_key = d.source.key;
    84                                                 trg_key = d.target.key;
     86                                                d.target = data_all.nodes_index[trg_ix];
     87                                                //d.target.index = trg_ix;
     88//                                                src_key = d.source.key;
     89  //                                              trg_key = d.target.key;
     90                                                if (d.target == null | d.source == null) {
     91                                                  notifyUser("nodes for link missing: " + src_ix + " - " + trg_ix);
     92                                                }
     93 
    8594                                             });
     95                   // remove links for which nodes are missing!
     96                  data_all.links = data_all.links.filter(function(d){return (d.source !=null & d.target != null ) } )
     97 
    8698                // generate lookup hashes for neighbours;                                             
    8799                 add_lookups(data_all);
     
    185197                        .enter().append("div")
    186198                       .attr("id", function (d) { return "detail-" + d.key })                       
    187                         .classed("node-detail cmds-ui-block", 1)
     199                        .classed("node-detail cmds-ui-block init-show", 1)
    188200                        // collapse groups in index, but expand right away in detail view
    189                         .classed("init-show", (target_container_selector != index_container_selector));
     201                        //.classed("init-show", (target_container_selector != index_container_selector));
    190202                       
    191203      var group_headers = group_divs.append("div").classed("header", 1)
     
    449461            gnodes.append("svg:circle")
    450462/*            .attr("r", 6)*/
    451                     .on("click", function(d) {d.selected= d.selected ? 0 : 1; updateSelected() })
     463                    .on("click", function(d) {d.selected= d.selected ? 0 : 1;
     464                                                console.log("click:" + d.key);
     465                                                updateSelected(); })
    452466                      .on("mouseover", highlight()).on("mouseout", unhighlight())
    453467            .attr("r", function(d) { if (opt("node-size")=="count")
     
    756770if (opt("layout")!='freeze') {
    757771    nodes_sel = data_all.nodes.filter(function (d) { return d.selected });
    758    
     772console.log("updateSelected:" + nodes_sel);   
    759773    // update param
    760774      var selected = [];
     
    967981*/
    968982function neighbouring(a, b) {
    969 console.log("neighbouring: " +a.key + "," + b.key );
     983//console.log("neighbouring: " +a.key + "," + b.key );
    970984  return data_all.links_index[a.key + "," + b.key];
    971985}
     
    983997       data = typeof data !== 'undefined' ? data : data_all;
    984998    weight_threshold = parseInt(opt("weight")) / 100;
    985 console.log("weight_threshold:" + weight_threshold);
     999//console.log("weight_threshold:" + weight_threshold + "; depth:" + depth + "; key: " + n.key);
    9861000    if (depth==0) { return {nodes:[], links:[]};}
    9871001
     
    10491063    return result;
    10501064}
     1065
     1066function notifyUser (msg) {
     1067  $("#notifylist").append(msg);
     1068}
  • SMC/trunk/SMC/src/web/scripts/style/cmds-ui.css

    r5303 r6834  
    8585/* .cmds-elem-plus .detail { display: none; border: 1px solid #A6C9E2;} */
    8686.node-detail td.number .detail {position:relative; }
     87
     88li.node-item .node-detail {max-height:400px; overflow:auto;}
    8789
    8890.cmds-elem-prop {}
  • SMC/trunk/SMC/src/web/scripts/style/smc-graph.css

    r3631 r6834  
    113113}
    114114
     115/* persons (m/w) */
     116.type-m circle { fill: #339; }
     117.type-f circle { fill: #393; }
     118
    115119
    116120.highlight circle,
Note: See TracChangeset for help on using the changeset viewer.