Changeset 1252 for MDService2/trunk/MDService2/WebContent
- Timestamp:
- 04/27/11 20:37:11 (13 years ago)
- Location:
- MDService2/trunk/MDService2/WebContent/scripts
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
MDService2/trunk/MDService2/WebContent/scripts/mdservice_model.js
r1235 r1252 9 9 var page_record_count = 10; 10 10 var formatquerystring_len = 25; 11 11 var workspace; 12 13 function Workspace(){ 14 15 }; 16 Workspace.save = function(type){ 17 var JSONText = JSON.stringify(jsonw["WorkspaceProfile"]); 18 //var JSONText = JSON.stringify({"aa.a":"r"}); 19 //notifyUser(JSONText,'debug'); 20 $.post("/MDService2/workspaceprofilesave/" + type,{"data":JSONText}); 21 }; 22 Workspace.saveQuery = function(query){ 23 //queryset id 24 var id = parseInt($("#qts_select option:selected").val()); 25 var iq = 0; 26 var queries = jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"]; 27 28 //var iq = $('#userqueries').children().size(); 29 if (queries == "null"){ 30 jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"] = [{}]; 31 } else { 32 iq = queries.length; 33 } 34 var jsonq = query.toJSON(); 35 jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq] = jsonq; 36 Workspace.save("USER"); 37 appendQueryUI(jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq],iq, $('#userqueries')); 38 39 }; 12 40 function Collection(index, name){ 13 41 this.index = index; … … 162 190 }; 163 191 164 Query.prototype.query_json = function () { 165 var jsonq = {"squerystring":this.squery, 166 "querystring":this.query, 167 "collections" : this.getcollectiontext("index"), 168 "columns" : this.columns, 192 Query.prototype.toString = function(){ 193 var str = ""; 194 var coll = (this.getcollectiontext("name") != "" ) ? " in " + this.getcollectiontext("name") : ""; 195 str = Query.queryliststring(this.squery, this.query) + coll + " @" + this.repository.toString(); 196 return str; 197 }; 198 199 Query.prototype.toJSON = function () { 200 //Query.prototype.query_json = function () { 201 var dt = new Date(); 202 var str_time = dateFormat(dt);//dt.toString("dd/mm/yyyy HH:mm:ss"); 203 //var jsonq = { "options" : json_options, "bookmark" : bookmark, "time" : str_time}; 204 var json_options = this.options; 205 if (this.options != null) { 206 json_opts = [{}]; 207 json_opts[0] = this.options; 208 } 209 210 // collections 211 var json_coll; 212 213 if (this.collection.length == 0) { 214 json_coll = {}; 215 json_coll = "null"; 216 } else { 217 json_coll = [{}]; 218 for (var i = 0; i < this.collection.length; i++) { 219 json_coll[i] = {"index" : this.collection[i].index, "name" :this.collection[i].name}; 220 } 221 } 222 //columns 223 var json_cols; 224 var colls = this.columns; 225 if (colls == "") { 226 //json_cols = {}; 227 json_cols = "null"; 228 } else { 229 var pos = this.columns.indexOf(",", 0); 230 var i = 0; 231 232 json_cols = [{}]; 233 while (pos > -1){ 234 if (pos > -1){ 235 json_cols[i] = cols.substring(0,pos); 236 } else { 237 json_cols[i] = cols; 238 } 239 cols = cols.substring(pos+1); 240 pos = cols.indexOf(",", 0); 241 i = i+1; 242 } 243 244 json_cols[i] = cols; 245 } 246 247 var jsonq = {"name":"", 248 "squerystring":this.squery, 249 "querystring":this.query, 250 "searchclauses":"null" , 251 "collections" : json_coll, 252 "columns" : json_cols, 169 253 "startItem" : this.startItem, 170 "maximumItems" : this.maximumItems}; 171 return JSON.stringify(jsonq); 254 "maximumItems" : this.maximumItems, 255 "options" : json_options, "bookmark" : "0", "time" : str_time}; 256 257 jsonq.name = Query.fullformatstring(jsonq); 258 259 return jsonq;//JSON.stringify(jsonq); 172 260 }; 173 261 … … 370 458 */ 371 459 // FIXME: this is not nice, there should be a function providing the formatted string of the query. 372 var coll = (this.getcollectiontext("name") != "" ) ? " in " + this.getcollectiontext("name") : "";460 //var coll = (this.getcollectiontext("name") != "" ) ? " in " + this.getcollectiontext("name") : ""; 373 461 var x = "<div id='" + this.listid + "' class='query_wrapper ui-widget' name='query' ><div class='query_header ui-widget-header ui-state-default ui-corner-top'>" + 374 462 "<span class='cmd cmd_get'></span><span class='cmd cmd_del'> </span>" + 375 463 "<span class='query_id'>" + this.listid + "</span>: <span class='query'>" + 376 Query.queryliststring(this.squery, this.query) + coll + " @" + this.repository.toString() + "</span>" + 464 this.toString() + 465 //Query.queryliststring(this.squery, this.query) + coll + " @" + this.repository.toString() + 466 "</span>" + 377 467 "</div>" + 378 468 "<div class='result ui-widget-content ui-corner-bottom'></div>"; -
MDService2/trunk/MDService2/WebContent/scripts/mdservice_ui.js
r1236 r1252 299 299 jsonw["WorkspaceProfile"]["CustomTermsets"][id] = jsont; 300 300 301 saveWorkspace("USER"); 301 //saveWorkspace("USER"); 302 Workspace.save("USER"); 302 303 loadTermsets(jsonw["WorkspaceProfile"]["CustomTermsets"]); 303 304 //createTermsUI(jsonw["WorkspaceProfile"]["CustomTermsets"][id],$('#userterms')); … … 327 328 qid = $(this).data('query').listid; 328 329 notifyUser("here I would save query: " + qid, "debug"); 330 Workspace.saveQuery($(this).data('query')); 329 331 }); 330 332 … … 384 386 385 387 jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq] = jsonq; 386 saveWorkspace("USER"); 388 //saveWorkspace("USER"); 389 Workspace.save("USER"); 387 390 appendQueryUI(jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq],iq, $('#userqueries')); 388 391 … … 476 479 477 480 $("#qts_select option:selected").text( $('#qts_input').val()); 478 saveWorkspace("USER"); 481 //saveWorkspace("USER"); 482 Workspace.save("USER"); 479 483 }); 480 484 $('#qts_add').click(function(){ … … 491 495 jsonw["WorkspaceProfile"]["Querysets"][id] = {"name":new_name,"created":str_time , "Queries" : "null"}; 492 496 493 saveWorkspace("USER"); 497 //saveWorkspace("USER"); 498 Workspace.save("USER"); 494 499 //todo 495 500 … … 517 522 jsonw["WorkspaceProfile"]["Querysets"] = "null"; 518 523 } 519 saveWorkspace("USER"); 524 //saveWorkspace("USER"); 525 Workspace.save("USER"); 520 526 //$("#qts_select option").remove(); 521 527 loadQuerysets(jsonw["WorkspaceProfile"]["Querysets"],"user"); … … 530 536 531 537 $("#ts_select option:selected").text( $('#ts_input').val()); 532 saveWorkspace("USER"); 538 //saveWorkspace("USER"); 539 Workspace.save("USER"); 533 540 }); 534 541 $('#ts_add').click(function(){ … … 545 552 jsonw["WorkspaceProfile"]["CustomTermsets"][id] = {"name":new_name,"created":str_time , "Terms" : "null"}; 546 553 547 saveWorkspace("USER"); 554 //saveWorkspace("USER"); 555 Workspace.save("USER"); 548 556 //todo 549 557 … … 553 561 $("#ts_select").find('option').last().attr("selected","true"); 554 562 $('#ts_input').val(new_name); 555 createTermsUI(jsonw["WorkspaceProfile"]["CustomTermsets"][id],$('#userterms')) 563 createTermsUI(jsonw["WorkspaceProfile"]["CustomTermsets"][id],$('#userterms')); 556 564 }); 557 565 $('#ts_delete').click(function(){ … … 572 580 jsonw["WorkspaceProfile"]["CustomTermsets"] = "null"; 573 581 } 574 saveWorkspace("USER"); 582 //saveWorkspace("USER"); 583 Workspace.save("USER"); 575 584 loadTermsets(jsonw["WorkspaceProfile"]["CustomTermsets"]); 576 585 }); … … 598 607 } 599 608 600 saveWorkspace("USER"); 609 //saveWorkspace("USER"); 610 Workspace.save("USER"); 601 611 loadTermsets(jsonw["WorkspaceProfile"]["CustomTermsets"]); 602 612 //$("#ts_select option").remove(); … … 660 670 } 661 671 662 saveWorkspace("USER"); 672 //saveWorkspace("USER"); 673 Workspace.save("USER"); 663 674 loadQuerysets(jsonw["WorkspaceProfile"]["Querysets"],"user"); 664 675 //$("#qs_select option").remove(); -
MDService2/trunk/MDService2/WebContent/scripts/mdservice_ui_load.js
r1233 r1252 290 290 291 291 jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq].name = $(this).val(); 292 saveWorkspace("USER"); 292 //saveWorkspace("USER"); 293 Workspace.save("USER"); 293 294 evStop(); 294 295 } … … 501 502 } 502 503 503 function saveWorkspace(type){504 var JSONText = JSON.stringify(jsonw["WorkspaceProfile"]);505 //var JSONText = JSON.stringify({"aa.a":"r"});506 //notifyUser(JSONText,'debug');507 $.post("/MDService2/workspaceprofilesave/" + type,{"data":JSONText});508 509 }510 504 511 505 function saveTermset(id, name, listwidget) { … … 519 513 var str_time = dateFormat(dt);//dt.toString("dd/mm/yyyy HH:mm:ss"); 520 514 var jsont = {"name":name, "time" : str_time, "Terms" :terms}; 521 if (jsonw["WorkspaceProfile"]["CustomTermsets"] == undefined) {515 if (jsonw["WorkspaceProfile"]["CustomTermsets"] == "null") { 522 516 jsonw["WorkspaceProfile"]["CustomTermsets"] = [{}]; 523 517 if (id == -1) {id = 0;}; … … 526 520 jsonw["WorkspaceProfile"]["CustomTermsets"][id] = jsont; 527 521 528 saveWorkspace("USER"); 522 //saveWorkspace("USER"); 523 Workspace.save("USER"); 529 524 530 525 }; … … 542 537 jsonw["WorkspaceProfile"]["CustomTermsets"] = "null"; 543 538 } 544 saveWorkspace("USER"); 539 //saveWorkspace("USER"); 540 Workspace.save("USER"); 545 541 } 546 542 -
MDService2/trunk/MDService2/WebContent/scripts/mdservice_widgets.js
r1235 r1252 464 464 if (id < 2) { 465 465 if (id == 1){ 466 sl.listwidget.load( this.autolist);466 sl.listwidget.load(sl.autolist.split(',')); 467 467 }else{ 468 468 sl.listwidget.clear(); … … 486 486 //$select.append(new Option(this.items[0], 0)); 487 487 //$select.append(new Option(this.items[1], 1)); 488 489 $.each(json, function(i,item) { 490 items[items.length] = new ListItem(item.name); 491 //$select.append(new Option(item.name, i+2)); 492 }); 488 if (json != "null") { 489 $.each(json, function(i,item) { 490 items[items.length] = new ListItem(item.name); 491 //$select.append(new Option(item.name, i+2)); 492 }); 493 } 493 494 /* 494 495 // find id of selected
Note: See TracChangeset
for help on using the changeset viewer.