Commit 471419c2 authored by Romain Loth's avatar Romain Loth

[FEAT] removable subforms in groups + simplified group management in js

parent 996bf406
...@@ -34,24 +34,36 @@ def _query_list(list_id, ...@@ -34,24 +34,36 @@ def _query_list(list_id,
""" """
if not details: if not details:
# simple contents # simple contents
query = session.query(NodeNgram.ngram_id) query = session.query(NodeNgram.ngram_id).filter(NodeNgram.node_id == list_id)
else: else:
# detailed contents (terms and some NodeNodeNgram for score) # detailed contents (terms and some NodeNodeNgram for score)
# NB: score can be undefined (eg ex-subform that now became free)
# ==> we need outerjoin
# and the filter needs to have scoring_metric_id so we do it before
ScoresTable = (session
.query(NodeNodeNgram.score, NodeNodeNgram.ngram_id)
.filter(NodeNodeNgram.node1_id == scoring_metric_id)
.subquery()
)
query = (session query = (session
.query( .query(
NodeNgram.ngram_id, NodeNgram.ngram_id,
Ngram.terms, Ngram.terms,
NodeNodeNgram.score ScoresTable.c.score
) )
.join(Ngram, NodeNgram.ngram_id == Ngram.id) .join(Ngram, NodeNgram.ngram_id == Ngram.id)
.join(NodeNodeNgram, NodeNgram.ngram_id == NodeNodeNgram.ngram_id)
.filter(NodeNodeNgram.node1_id == scoring_metric_id)
.order_by(desc(NodeNodeNgram.score))
)
# main filter # main filter ----------------------
# ----------- .filter(NodeNgram.node_id == list_id)
query = query.filter(NodeNgram.node_id == list_id)
# scores if possible
.outerjoin(ScoresTable,
ScoresTable.c.ngram_id == NodeNgram.ngram_id)
.order_by(desc(ScoresTable.c.score))
)
if pagination_limit: if pagination_limit:
query = query.limit(pagination_limit) query = query.limit(pagination_limit)
...@@ -128,13 +140,18 @@ class GroupChange(APIView): ...@@ -128,13 +140,18 @@ class GroupChange(APIView):
} }
Chained effect: Chained effect:
any previous group under mainformA or B will be overwritten
The DELETE HTTP method also works, with same url
(and simple array in the data)
NB: request.user is also checked for current authentication status NB: request.user is also checked for current authentication status
""" """
def initial(self, request): def initial(self, request):
""" """
Before dispatching to post() Before dispatching to post() or delete()
Checks current user authentication to prevent remote DB manipulation Checks current user authentication to prevent remote DB manipulation
""" """
...@@ -150,28 +167,29 @@ class GroupChange(APIView): ...@@ -150,28 +167,29 @@ class GroupChange(APIView):
=> removes couples where newly reconnected ngrams where involved => removes couples where newly reconnected ngrams where involved
=> adds new couples from GroupsBuffer of terms view => adds new couples from GroupsBuffer of terms view
TODO recalculate scores after new groups
TODO see use of util.lists.Translations TODO see use of util.lists.Translations
TODO benchmark selective delete compared to entire list rewrite
POST data:
<QueryDict: {'1228[]': ['891', '1639']}> => creates 1228 - 891
and 1228 - 1639
request.POST.lists() iterator where each elt is like :('1228[]',['891','1639'])
""" """
group_node = get_parameters(request)['node'] group_node = get_parameters(request)['node']
all_nodes_involved = [] all_mainforms = []
links = [] links = []
for (mainform_key, subforms_ids) in request.POST.lists(): for (mainform_key, subforms_ids) in request.POST.lists():
mainform_id = mainform_key[:-2] # remove brackets '543[]' -> '543' mainform_id = mainform_key[:-2] # remove brackets '543[]' -> '543'
all_nodes_involved.append(mainform_id) all_mainforms.append(mainform_id)
for subform_id in subforms_ids: for subform_id in subforms_ids:
links.append((mainform_id,subform_id)) links.append((mainform_id,subform_id))
all_nodes_involved.append(subform_id)
# remove selectively all groupings with these nodes involved # remove selectively all groupings with these mainforms
# TODO benchmark # using IN is correct in this case: list of ids is short and external
# see stackoverflow.com/questions/444475/
old_links = (session.query(NodeNgramNgram) old_links = (session.query(NodeNgramNgram)
.filter(NodeNgramNgram.node_id == group_node) .filter(NodeNgramNgram.node_id == group_node)
.filter(or_( .filter(NodeNgramNgram.ngram1_id.in_(all_mainforms))
NodeNgramNgram.ngram1_id.in_(all_nodes_involved),
NodeNgramNgram.ngram2_id.in_(all_nodes_involved)))
) )
n_removed = old_links.delete(synchronize_session=False) n_removed = old_links.delete(synchronize_session=False)
session.commit() session.commit()
...@@ -189,6 +207,40 @@ class GroupChange(APIView): ...@@ -189,6 +207,40 @@ class GroupChange(APIView):
}, 200) }, 200)
def delete(self, request):
"""
Deletes some groups from the group node
Send in data format is simply a json { 'keys':'["11492","16438"]' }
==> it means removing any synonym groups having these 2 as mainform
(within the url's groupnode_id)
NB: At reception here it becomes like:
<QueryDict: {'keys[]': ['11492', '16438']}>
"""
# from the url
group_node = get_parameters(request)['node']
print(request.POST)
# from the data in body
all_mainforms = request.POST.getlist('keys[]')
links_to_remove = (session.query(NodeNgramNgram)
.filter(NodeNgramNgram.node_id == group_node)
.filter(NodeNgramNgram.ngram1_id.in_(all_mainforms))
)
n_removed = links_to_remove.delete(synchronize_session=False)
session.commit()
return JsonHttpResponse({
'count_removed': n_removed
}, 200)
class ListChange(APIView): class ListChange(APIView):
""" """
......
...@@ -22,6 +22,30 @@ ...@@ -22,6 +22,30 @@
* The stateIds are described by the System object. * The stateIds are described by the System object.
* - columns use stateId [0..2] (miam aka normal, map aka keep, stop aka delete) * - columns use stateId [0..2] (miam aka normal, map aka keep, stop aka delete)
* *
*
* These states are stored in 3 places :
* Original (in *OriginalNG*)
* Current (in *AjaxRecords*)
* Changes to make (in "FlagsBuffer")
*
* (the crud operations create FlagsBuffer at the last moment by
* inspecting the diff of original vs current and infering changes)
*
* For the groups it's a little different with only 2 main vars:
* Current (in CurrentGroups)
* Changes to make (in "GroupsBuffer")
*
* (each user action is enacted in Current and at the same time carried
* over to GroupsBuffer)
*
* NB for groups removal: there is a case when user clicks "cancel" in group modifs
* but some modifications will already be triggered:
* it happens when an entire group A is attached to a new
* group B, and then later an ex-element of A is removed
* from the new group
* => even if the new group B is canceled, it will mark
* the entire old group A for destruction
*
* @author * @author
* Samuel Castillo (original 2015 work) * Samuel Castillo (original 2015 work)
* Romain Loth * Romain Loth
...@@ -44,12 +68,19 @@ ...@@ -44,12 +68,19 @@
// ============================================================================= // =============================================================================
// ngram infos (<-> row data) // current ngram infos (<-> row data)
// -------------------------- // ----------------------------------
// from /api/ngramlists/lexmodel?corpus=312 // from /api/ngramlists/lexmodel?corpus=312
// with some expanding in AfterAjax // with some expanding in AfterAjax
var AjaxRecords = [] ; var AjaxRecords = [] ;
// current groups
// --------------
// links and subforms (reverse index)
var CurrentGroups = {"links":{}, "subs":{}}
// table element (+config +events) // table element (+config +events)
// ------------------------------- // -------------------------------
var MyTable ; var MyTable ;
...@@ -108,7 +139,15 @@ for(var i in System[GState]["states"] ) { ...@@ -108,7 +139,15 @@ for(var i in System[GState]["states"] ) {
var FlagsBuffer = {} var FlagsBuffer = {}
// + 1 for groups // + 1 for groups
GroupsBuffer = {} var GroupsBuffer = {'_to_add':{}, '_to_del':{}}
// to_add will have structure like this { mainformid1 : [array1 of subformids],
// mainformid2 : [array2 of subformids]}
// to_del is simple array of mainforms : [mainform3, mainform4]
// because deleting "the group of mainform3" is deleting all DB rows of
// couples having mainform3 on the left-hand-side ( <=> no need to know the subform)
// GROUP "WINDOWS" // GROUP "WINDOWS"
...@@ -239,22 +278,22 @@ function printCorpuses() { ...@@ -239,22 +278,22 @@ function printCorpuses() {
if(Object.keys( results ).length>0) { if(Object.keys( results ).length>0) {
var sub_ngrams_data = { var sub_ngrams_data = {
"ngrams":[], "ngrams":[],
"scores": $.extend({}, NGrams["main"].scores) "scores": $.extend({}, OriginalNG.scores)
} }
for(var i in NGrams["main"].ngrams) { for(var i in OriginalNG["records"].ngrams) {
if( results[ NGrams["main"].ngrams[i].id] ) { if( results[ OriginalNG["records"].ngrams[i].id] ) {
var a_ngram = NGrams["main"].ngrams[i] var a_ngram = OriginalNG["records"].ngrams[i]
sub_ngrams_data["ngrams"].push( a_ngram ) sub_ngrams_data["records"].push( a_ngram )
} }
// if( results[ NGrams["main"].ngrams[i].id] && NGrams["main"].ngrams[i].name.split(" ").length==1 ) { // if( results[ OriginalNG["records"][i].id] && OriginalNG["records"][i].name.split(" ").length==1 ) {
// if( NGrams["map"][ NGrams["main"].ngrams[i].id] ) { // if( OriginalNG["map"][ i ] ) {
// var a_ngram = NGrams["main"].ngrams[i] // var a_ngram = OriginalNG["records"][i]
// // a_ngram["state"] = System[0]["statesD"]["delete"] // // a_ngram["state"] = System[0]["statesD"]["delete"]
// sub_ngrams_data["ngrams"].push( a_ngram ) // sub_ngrams_data["ngrams"].push( a_ngram )
// } // }
// } // }
} }
var result = MainTableAndCharts(sub_ngrams_data , NGrams["main"].scores.initial , "filter_all") var result = MainTableAndCharts(sub_ngrams_data , OriginalNG.scores.initial , "filter_all")
} }
}); });
} }
...@@ -362,40 +401,30 @@ function saveActiveGroup() { ...@@ -362,40 +401,30 @@ function saveActiveGroup() {
var mainform = activeGroup.now_mainform_id var mainform = activeGroup.now_mainform_id
// pr("saving mainform to GroupsBuffer: " + mainform) // pr("saving mainform to GroupsBuffer: " + mainform)
// the new array to save is in now_links ------------- // the new array of tgt forms to save is in now_links
GroupsBuffer[mainform] = activeGroup.now_links addInCurrentGroups(mainform, activeGroup.now_links) // -> current status
// --------------------------------------------------- GroupsBuffer._to_add[mainform] = activeGroup.now_links // -> changes to make
// console.log(AjaxRecords[mainform]) // -----------------------------------------------------
// various consequences
// also we prefix "*" to the name if not already there // also we prefix "*" to the name if not already there
if (AjaxRecords[mainform].name[0] != '*') { if (AjaxRecords[mainform].name[0] != '*') {
AjaxRecords[mainform].name = "*" + AjaxRecords[mainform].name AjaxRecords[mainform].name = "*" + AjaxRecords[mainform].name
} }
// the previous mainforms that became subforms can't stay in the main records // all subforms old and new become deactivated in AjaxRecords
for (downgradedNgramId in activeGroup.were_mainforms) { for (var i in activeGroup.now_links) {
if (downgradedNgramId != mainform) { subformId = activeGroup.now_links[i]
AjaxRecords[subformId].state = -1
AjaxRecords[downgradedNgramId].state = -1
// they go to nodesmemory
// NGrams.group.nodesmemory = AjaxRecords[downgradedNgramId]
// delete AjaxRecords[downgradedNgramId]
}
} }
// TODO posttest // the previous mainforms have old groupings to be marked for deletion
// the previous "old" links are now in GroupsBuffer so from now on for (downgradedNgramId in activeGroup.were_mainforms) {
// they'll be searched in AjaxRecords by updateActiveGroupInfo() // (except the one we just saved)
delete NGrams.group.links[mainform] if (downgradedNgramId != mainform) {
for (i in activeGroup.now_links) { GroupsBuffer._to_del[downgradedNgramId] = true
newLink = activeGroup.now_links[i] ; deleteInCurrentGroups(downgradedNgramId, false) // "false" <=> no need to change subform states
if (activeGroup.ngraminfo[newLink].origin == 'old' || activeGroup.ngraminfo[newLink].origin == 'oldnew') {
// new AjaxRecords entry from nodesmemory
AjaxRecords[newLink] = NGrams.group.nodesmemory[newLink]
delete NGrams.group.nodesmemory[newLink]
// console.log('oldLinkThatBecameNew: '+AjaxRecords[newLink].name)
} }
} }
...@@ -404,6 +433,9 @@ function saveActiveGroup() { ...@@ -404,6 +433,9 @@ function saveActiveGroup() {
} }
function removeActiveGroupFrame() { function removeActiveGroupFrame() {
// no need to restore records: everything from the frame
// was in temporary var activeGroup
// erases now_links and restores empty activeGroup global cache // erases now_links and restores empty activeGroup global cache
activeGroup = {'now_mainform_id':undefined, 'were_mainforms':{}} ; activeGroup = {'now_mainform_id':undefined, 'were_mainforms':{}} ;
...@@ -447,7 +479,7 @@ function toggleSeeGroup(plusicon, ngramId) { ...@@ -447,7 +479,7 @@ function toggleSeeGroup(plusicon, ngramId) {
* @param ngramId (of the mainform) * @param ngramId (of the mainform)
*/ */
function seeGroup ( ngramId , allowChangeFlag) { function seeGroup ( ngramId , allowChangeFlag) {
// 1/7 create new element container // 1/6 create new element container
var subNgramHtml = $('<p class="note">') ; var subNgramHtml = $('<p class="note">') ;
subNgramHtml.attr("id", "subforms-"+ngramId) ; subNgramHtml.attr("id", "subforms-"+ngramId) ;
subNgramHtml.css("line-height", 1.2) ; subNgramHtml.css("line-height", 1.2) ;
...@@ -455,32 +487,24 @@ function seeGroup ( ngramId , allowChangeFlag) { ...@@ -455,32 +487,24 @@ function seeGroup ( ngramId , allowChangeFlag) {
subNgramHtml.css("margin-top", '.5em') ; subNgramHtml.css("margin-top", '.5em') ;
// 2/7 attach flag open to global state register // 2/6 attach flag open to global state register
vizopenGroup[ngramId] = true ; vizopenGroup[ngramId] = true ;
// 3/7 retrieve names of the untouched (from DB) grouped ngrams (aka "old") // 3/6 retrieve names of the grouped ngrams
var oldlinksNames = [] ; var linksNames = [] ;
if( ngramId in NGrams.group.links ) { if( ngramId in CurrentGroups["links"] ) {
for (var i in NGrams.group.links[ngramId]) { var thisGroup = CurrentGroups["links"][ngramId]
var subNgramId = NGrams.group.links[ngramId][i] ; for (var i in thisGroup) {
oldlinksNames[i] = NGrams.group.nodesmemory[subNgramId].name var subNgramId = thisGroup[i] ;
} linksNames[i] = AjaxRecords[subNgramId].name
} }
// 4/7 retrieve names of the newly created grouped ngrams (aka "new" + "oldnew")
var newlinksNames = [] ;
if( ngramId in GroupsBuffer ) {
for(var i in GroupsBuffer[ ngramId ] ) {
var subNgramId = GroupsBuffer[ ngramId ][i] ;
newlinksNames[i] = AjaxRecords[subNgramId].name
}
} }
// 5/7 create the "tree" from the names, as html lines // 4/6 create the "tree" from the names, as html lines
var htmlMiniTree = drawSublist(oldlinksNames.concat(newlinksNames)) var htmlMiniTree = drawSublist(linksNames)
subNgramHtml.append(htmlMiniTree) subNgramHtml.append(htmlMiniTree)
// 6/7 add a "modify group" button // 5/6 add a "modify group" button
if (allowChangeFlag) { if (allowChangeFlag) {
var changeGroupsButton = '<button style="float:right"' ; var changeGroupsButton = '<button style="float:right"' ;
changeGroupsButton += ' title="add/remove contents of groups"' ; changeGroupsButton += ' title="add/remove contents of groups"' ;
...@@ -490,7 +514,7 @@ function seeGroup ( ngramId , allowChangeFlag) { ...@@ -490,7 +514,7 @@ function seeGroup ( ngramId , allowChangeFlag) {
subNgramHtml.append(changeGroupsButton) ; subNgramHtml.append(changeGroupsButton) ;
} }
// 7/7 return html snippet (ready for rendering) // 6/6 return html snippet (ready for rendering)
return(subNgramHtml) return(subNgramHtml)
} }
...@@ -562,27 +586,21 @@ function subformSpan( subNgramInfo ) { ...@@ -562,27 +586,21 @@ function subformSpan( subNgramInfo ) {
span = $('<span/>', { span = $('<span/>', {
text: subNgramInfo.name, text: subNgramInfo.name,
title: subNgramInfo.id, title: subNgramInfo.id,
id: 'active-subform-' + subNgramInfo.id id: 'active-subform-' + subNgramInfo.id,
class: 'subform'
}) })
if (subNgramInfo.origin == 'old') {
span.addClass("oldsubform")
}
else if (subNgramInfo.origin == 'new' || subNgramInfo.origin == 'oldnew'){
span.addClass("usersubform")
}
// remove button // remove button
// var removeButton = '&nbsp;<span class="note glyphicon glyphicon-minus-sign"' var removeButton = '<span class="note glyphicon glyphicon-minus-sign"'
// removeButton += ' title="remove from group (/!\\ bug: will be unattached if was previously a subform)"' ; removeButton += ' title="remove from group"' ;
// removeButton += ' onclick="removeSubform('+ subNgramInfo.id +')"></span>' removeButton += ' onclick="removeSubform('+ subNgramInfo.id +')"></span> &nbsp;'
// span.append(removeButton) span.prepend(removeButton)
// makes this subform become the mainform // makes this subform become the mainform
// var mainformButton = '&nbsp;<span class="note glyphicon glyphicon-circle-arrow-up"' // var mainformButton = '<span class="note glyphicon glyphicon-circle-arrow-up"'
// mainformButton += ' title="upgrade to mainform of this group"' // mainformButton += ' title="upgrade to mainform of this group"'
// mainformButton += ' onclick="makeMainform('+ subNgramInfo.id +')"></span>' // mainformButton += ' onclick="makeMainform('+ subNgramInfo.id +')"></span>&nbsp;'
// span.append(mainformButton) // span.prepend(mainformButton)
return(span[0].outerHTML) return(span[0].outerHTML)
} }
...@@ -610,7 +628,6 @@ function makeMainform(ngramId) { ...@@ -610,7 +628,6 @@ function makeMainform(ngramId) {
activeGroup.now_links[i] = previousMainformId activeGroup.now_links[i] = previousMainformId
// if it was previously a subform then: // if it was previously a subform then:
// -> it had no entry in AjaxRecords
// -> it was not in any of the lists // -> it was not in any of the lists
if (! (mainform in activeGroup.were_mainforms)) { if (! (mainform in activeGroup.were_mainforms)) {
// update records // update records
...@@ -640,21 +657,47 @@ function makeMainform(ngramId) { ...@@ -640,21 +657,47 @@ function makeMainform(ngramId) {
function removeSubform(ngramId) { function removeSubform(ngramId) {
// no need to restore AjaxRecords[ngramId] because it's untouched
// NB removeSubform has a side effect for subforms that were previously
// in another group see comment at the top of script
// special case: if removed form already was a subform it becomes independant
//
// (because the old mainform may be remaining in the new group, we set a
// convention: entire previous group goes "to_delete" at 1st sub remove)
//
if (CurrentGroups["subs"][ngramId]) {
var oldMainFormId = CurrentGroups["subs"][ngramId]
// it must break the old group, mark for deletion
GroupsBuffer._to_del[oldMainFormId] = true
// consequences:
deleteInCurrentGroups(oldMainFormId, true)
// => they are all removed from CurrentGroups
// => the removed subform and all others from the old group
// get a state (map/del/normal)
}
// ==========================================
// core of the function for any type of ngram
// ==========================================
$('#active-subform-'+ngramId).remove() $('#active-subform-'+ngramId).remove()
if (activeGroup.now_links.length == 1) { if (activeGroup.now_links.length == 1) {
// close the frame if last subform
removeActiveGroupFrame() removeActiveGroupFrame()
} }
else { else {
// clean were_mainforms dict
delete activeGroup.were_mainforms[ngramId]
// clean now_links array // clean now_links array
var i = activeGroup.now_links.indexOf(ngramId) var i = activeGroup.now_links.indexOf(ngramId)
activeGroup.now_links.splice(i,1) activeGroup.now_links.splice(i,1)
// if (activeGroup.ngraminfo[ngramId].origin == 'new') { // clean were_mainforms dict (if key existed)
// AjaxRecords[ngramId].state = 0 ; delete activeGroup.were_mainforms[ngramId]
// }
// redraw active group_box_content // redraw active group_box_content
drawActiveGroup( drawActiveGroup(
...@@ -668,6 +711,59 @@ function removeSubform(ngramId) { ...@@ -668,6 +711,59 @@ function removeSubform(ngramId) {
} }
} }
/**
* Effects of deleting a mainform from the current groups
*
* => updates the global var CurrentGroups
*
* @param ngramId of a mainform
* @param inheritState boolean => updates the AjaxRecords[subformId].state
*/
function deleteInCurrentGroups(ngramId, inheritState) {
if (inheritState) {
// ex-subforms can inherit state from their previous mainform
var implicitState = AjaxRecords[ngramId].state
}
if (CurrentGroups.links[ngramId]) {
var oldGroup = CurrentGroups.links[ngramId]
// deleting in reverse index
for (var i in oldGroup) {
var subformId = oldGroup[i]
delete CurrentGroups.subs[subformId]
if (inheritState) {
AjaxRecords[subformId].state = implicitState
// consequence:
// now OriginalNG.records[subformId].state
// is != AjaxRecords[subformId].state
// therefore the newly independant forms
// will be added to their new wordlist
}
}
// deleting in "links"
delete CurrentGroups.links[ngramId]
}
}
/**
* Adding links to the current groups
*
* => updates the global var CurrentGroups
*
* @param mainformId
* @param subforms array of subNgramIds
*/
function addInCurrentGroups(mainformId, subforms) {
console.log("addInCurrentGroups: "+mainformId+"("+JSON.stringify(subforms)+")")
CurrentGroups["links"][mainformId] = subforms
for (var i in subforms) {
var subformId = subforms[i]
CurrentGroups["subs"][subformId] = mainformId
}
}
function modifyGroup ( mainFormNgramId ) { function modifyGroup ( mainFormNgramId ) {
// create modification container // create modification container
// //
...@@ -706,9 +802,9 @@ function modifyGroup ( mainFormNgramId ) { ...@@ -706,9 +802,9 @@ function modifyGroup ( mainFormNgramId ) {
// add new ngramid (and any present subforms) to currently modified group // add new ngramid (and any present subforms) to currently modified group
function add2group ( ngramId ) { function addToGroup ( ngramId ) {
// console.log("FUN add2group(" + AjaxRecords[ngramId].name + ")") // console.log("FUN addToGroup(" + AjaxRecords[ngramId].name + ")")
var toOther = true ; var toOther = true ;
activeGroup.were_mainforms[ngramId] = true ; activeGroup.were_mainforms[ngramId] = true ;
...@@ -718,7 +814,6 @@ function add2group ( ngramId ) { ...@@ -718,7 +814,6 @@ function add2group ( ngramId ) {
// add this mainform as a new subform // add this mainform as a new subform
activeGroup.now_links.push(ngramId) activeGroup.now_links.push(ngramId)
activeGroup.ngraminfo[ngramId] = AjaxRecords[ngramId] activeGroup.ngraminfo[ngramId] = AjaxRecords[ngramId]
activeGroup.ngraminfo[ngramId].origin = 'new'
// also add all its subforms as new subforms // also add all its subforms as new subforms
updateActiveGroupInfo (ngramId, toOther) updateActiveGroupInfo (ngramId, toOther)
...@@ -736,14 +831,13 @@ function add2group ( ngramId ) { ...@@ -736,14 +831,13 @@ function add2group ( ngramId ) {
else { else {
console.warn("ADD2GROUP but no active group") console.warn("ADD2GROUP but no active group")
} }
} }
/** /**
* subforms from DB have their info in a separate NGrams.group.nodesmemory * subforms from DB have their info in AjaxRecords like everyone, and state = -1
* so here and in saveActiveGroup we need to take it into account
* *
* TODO: remove this mecanism * here all current infos are copied to activeGroup temporary var
* (copy will remain until user cancel/finishes group modif)
* *
* @param ngramId * @param ngramId
* @param toOtherMainform = flag if ngram was a subform of another mainform * @param toOtherMainform = flag if ngram was a subform of another mainform
...@@ -754,23 +848,11 @@ function updateActiveGroupInfo (ngramId, toOtherMainform) { ...@@ -754,23 +848,11 @@ function updateActiveGroupInfo (ngramId, toOtherMainform) {
// console.log(activeGroup) // console.log(activeGroup)
// fill active link info // fill active link info
if( ngramId in NGrams.group.links ) { for(var i in CurrentGroups["links"][ ngramId ] ) {
for (var i in NGrams.group.links[ngramId]) { var subId = CurrentGroups["links"][ ngramId ][i] ;
var subId = NGrams.group.links[ngramId][i] ; // ----------- links (old and new)
// ----------- old links (already in DB) activeGroup.now_links.push(subId)
activeGroup.now_links.push(subId) activeGroup.ngraminfo[subId] = AjaxRecords[subId]
activeGroup.ngraminfo[subId] = NGrams.group.nodesmemory[subId]
activeGroup.ngraminfo[subId].origin = toOtherMainform ? 'oldnew' : 'old'
}
}
if( ngramId in GroupsBuffer ) {
for(var i in GroupsBuffer[ ngramId ] ) {
var subId = GroupsBuffer[ ngramId ][i] ;
// ----------- new links (not in DB)
activeGroup.now_links.push(subId)
activeGroup.ngraminfo[subId] = AjaxRecords[subId]
activeGroup.ngraminfo[subId].origin = 'new'
}
} }
} }
...@@ -881,12 +963,12 @@ function transformContent(ngramId) { ...@@ -881,12 +963,12 @@ function transformContent(ngramId) {
} }
// GState = 1 situation: button allows to add to active group // GState = 1 situation: button allows to add to active group
// (if previously had add2group button clicked) // (if previously had addToGroup button clicked)
if(GState==1 ) { if(GState==1 ) {
if(ngram_info.state!=System[0]["statesD"]["delete"] && ! GroupsBuffer[ngramId]) { // if deleted and already group, no Up button if(ngram_info.state!=System[0]["statesD"]["delete"] && ! GroupsBuffer._to_add[ngramId]) { // if deleted and already group, no Up button
plus_event = '<span class="note glyphicon glyphicon-plus"' plus_event = '<span class="note glyphicon glyphicon-plus"'
plus_event += ' color="#FF530D"' plus_event += ' color="#FF530D"'
plus_event += ' onclick="add2group('+ ngramId +')"></span>' plus_event += ' onclick="addToGroup('+ ngramId +')"></span>'
} }
} }
...@@ -1219,6 +1301,19 @@ function InferCRUDFlags(id, oldState, desiredState, registry) { ...@@ -1219,6 +1301,19 @@ function InferCRUDFlags(id, oldState, desiredState, registry) {
} }
} }
} }
// (if previously was under a group)
else if (oldState === state_skip) {
if (desiredState === state_main || desiredState === state_map) {
registry["inmain"][id] = true
// (... and one more action only if is now desired to be in MAP)
if(desiredState === state_map) {
registry["inmap"][ id ] = true
}
}
else if(desiredState === state_stop) {
registry["indel"][id] = true
}
}
// (if previously was in MAIN) // (if previously was in MAIN)
else { else {
if(desiredState === state_map) { if(desiredState === state_map) {
...@@ -1230,6 +1325,8 @@ function InferCRUDFlags(id, oldState, desiredState, registry) { ...@@ -1230,6 +1325,8 @@ function InferCRUDFlags(id, oldState, desiredState, registry) {
} }
} }
} }
console.log("registry")
console.log(registry)
return registry return registry
} }
...@@ -1260,13 +1357,13 @@ function SaveLocalChanges() { ...@@ -1260,13 +1357,13 @@ function SaveLocalChanges() {
// LOOP on all mainforms + subforms // LOOP on all mainforms + subforms
// -------------------------------- // --------------------------------
// we use 2 globals to evaluate change-of-state // we use 2 globals to evaluate change-of-state
// => NGrams for old states (as in DB) // => OriginalNG for old states (as in DB)
// => AjaxRecords for current (desired) states // => AjaxRecords for current (desired) states
for(var id in AjaxRecords) { for(var id in AjaxRecords) {
var oldState = 0 ; var oldState = 0 ;
if (NGrams["map"][ id ] ) oldState = 1 if (OriginalNG["map"][ id ] ) oldState = 1
else if (NGrams["stop"][ id ]) oldState = 2 else if (OriginalNG["stop"][ id ]) oldState = 2
var mainNewState = AjaxRecords[id]["state"] ; var mainNewState = AjaxRecords[id]["state"] ;
...@@ -1275,26 +1372,22 @@ function SaveLocalChanges() { ...@@ -1275,26 +1372,22 @@ function SaveLocalChanges() {
FlagsBuffer = InferCRUDFlags(id, oldState, mainNewState, FlagsBuffer) FlagsBuffer = InferCRUDFlags(id, oldState, mainNewState, FlagsBuffer)
} }
console.log( "dont do anything" )
return "dont do anything"
// [ = = = = propagating to subforms = = = = ] // [ = = = = propagating to subforms = = = = ]
// if change in mainform list or change in groups // if change in mainform list or change in groups
if(oldState != mainNewState || GroupsBuffer[id]) { if(oldState != mainNewState || GroupsBuffer._to_add[id]) {
// linked nodes
var linkedNodes ;
// a) retrieve the untouched (from DB) grouped ngrams (aka "old")
if(NGrams.group.links[id]) linkedNodes = NGrams.group.links[id]
// b) or retrieve the new linked nodes (aka "new" + "oldnew")
else if( GroupsBuffer[id] ) linkedNodes = GroupsBuffer[id]
for (var i in linkedNodes) { // linked nodes
var subNgramId = linkedNodes[i] ; for (var i in CurrentGroups["links"][id]) {
var subNgramId = CurrentGroups["links"][id][i] ;
// todo check (if undefined old state, should add to main too...) // todo check (if undefined old state, should add to main too...)
var subOldState = undefined ; var subOldState = undefined ;
if (NGrams["map"][ subNgramId ] ) subOldState = System[0]["statesD"]["keep"] if (OriginalNG["map"][ subNgramId ] ) subOldState = System[0]["statesD"]["keep"]
else if (NGrams["stop"][ subNgramId ]) subOldState = System[0]["statesD"]["delete"] else if (OriginalNG["stop"][ subNgramId ]) subOldState = System[0]["statesD"]["delete"]
else { else {
subOldState = System[0]["statesD"]["normal"] ; subOldState = System[0]["statesD"]["normal"] ;
// (special legacy case: subforms can have oldStates == undefined, // (special legacy case: subforms can have oldStates == undefined,
...@@ -1405,7 +1498,7 @@ function SaveLocalChanges() { ...@@ -1405,7 +1498,7 @@ function SaveLocalChanges() {
console.log("===> AJAX CRUD6 RmStop <===\n") ; console.log("===> AJAX CRUD6 RmStop <===\n") ;
CRUD( stoplist_id , Object.keys(FlagsBuffer["outdel"]), "DELETE" , function(success) { CRUD( stoplist_id , Object.keys(FlagsBuffer["outdel"]), "DELETE" , function(success) {
if (success) { if (success) {
CRUD_7_groups() // chained AJAX 6 -> 7 CRUD_7_AddGroups() // chained AJAX 6 -> 7
} }
else { else {
console.warn('CRUD error on ngrams remove from stoplist ('+stoplist_id+')') console.warn('CRUD error on ngrams remove from stoplist ('+stoplist_id+')')
...@@ -1413,14 +1506,28 @@ function SaveLocalChanges() { ...@@ -1413,14 +1506,28 @@ function SaveLocalChanges() {
}); });
} }
// add to groups reading data from GroupsBuffer // add to groups reading data from GroupsBuffer
function CRUD_7_groups() { // (also removes previous groups with same mainforms!)
console.log("===> AJAX CRUD7 RewriteGroups <===\n") ; function CRUD_7_AddGroups() {
GROUPCRUD(groupnode_id, GroupsBuffer, function(success) { console.log("===> AJAX CRUD7 AddGroups <===\n") ;
GROUPCRUDS(groupnode_id, GroupsBuffer._to_add, "POST" , function(success) {
if (success) {
CRUD_8_RmGroups() // chained AJAX 7 -> 8
}
else {
console.warn('CRUD error on groups modification ('+groupnode_id+')')
}
}) ;
}
// add to groups reading data from GroupsBuffer
function CRUD_8_RmGroups() {
console.log("===> AJAX CRUD8 RmGroups <===\n") ;
GROUPCRUDS(groupnode_id, GroupsBuffer._to_del, "DELETE", function(success) {
if (success) { if (success) {
window.location.reload() // all 7 CRUDs OK => refresh whole page window.location.reload() // all 8 CRUDs OK => refresh whole page
} }
else { else {
console.warn('CRUD error on ngrams add to group node ('+groupings_id+')') console.warn('CRUD error on groups removal ('+groupnode_id+')')
} }
}) ; }) ;
} }
...@@ -1464,36 +1571,54 @@ function CRUD( list_id , ngram_ids , http_method , callback) { ...@@ -1464,36 +1571,54 @@ function CRUD( list_id , ngram_ids , http_method , callback) {
// For group modifications (POST: {mainformA: [subformsA1,A2,A3], mainformB:..}) // For group modifications (POST: {mainformA: [subformsA1,A2,A3], mainformB:..})
function GROUPCRUD( groupnode_id , post_data , callback) { // (adds new groups for mainformA and mainformB)
// ngramlists/change?node_id=42&ngram_ids=1,2 // (also deletes any old group under A or B)
//
// (DEL: {"keys": [mainformX, mainformY]})
// (just deletes the old groups of X and Y)
function GROUPCRUDS( groupnode_id , send_object, http_method , callback) {
// ngramlists/groups?node=9
var the_url = window.location.origin+"/api/ngramlists/groups?node="+groupnode_id; var the_url = window.location.origin+"/api/ngramlists/groups?node="+groupnode_id;
// debug // array of the keys
// console.log(" ajax target: " + the_url + " (" + http_method + ")") var mainformIds = Object.keys(send_object)
$.ajax({ var send_data ;
method: 'POST',
url: the_url, // if DELETE we need only them keys
data: post_data, // currently all data explicitly in the url (like a GET) if (http_method == "DELETE") {
beforeSend: function(xhr) { send_data = {"keys": mainformIds} ;
xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken")); }
}, else {
success: function(data){ send_data = send_object ;
console.log("-- GROUPCRUD ----------") }
console.log("POST ok!!")
console.log(JSON.stringify(data))
console.log("-----------------------")
callback(true);
},
error: function(result) {
console.log("-- GROUPCRUD ----------")
console.log("AJAX Error on POST " + the_url);
console.log(result)
console.log("-----------------------")
callback(false);
}
});
if(mainformIds.length > 0) {
$.ajax({
method: http_method,
url: the_url,
data: send_data,
beforeSend: function(xhr) {
xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));
},
success: function(data){
console.log("-- GROUPCRUD ----------")
console.log(http_method + " ok!!")
console.log(JSON.stringify(data))
console.log("-----------------------")
callback(true);
},
error: function(result) {
console.log("-- GROUPCRUD ----------")
console.log("AJAX Error on " + http_method + " " + the_url);
console.log(result)
console.log("------------------")
callback(false);
}
});
} else callback(true);
} }
...@@ -1509,7 +1634,7 @@ function GROUPCRUD( groupnode_id , post_data , callback) { ...@@ -1509,7 +1634,7 @@ function GROUPCRUD( groupnode_id , post_data , callback) {
* 3. Creates the scores distribution chart over table * 3. Creates the scores distribution chart over table
* 4. Set up Search div * 4. Set up Search div
* *
* @param ngdata: a response from the api/node/CID/ngrams/list/ routes * @param ngdata: OriginalNG['records']
* @param initial: initial score type "occs" or "tfidf" * @param initial: initial score type "occs" or "tfidf"
* @param search_filter: value among {0,1,2,'reset'} (see #picklistmenu options) * @param search_filter: value among {0,1,2,'reset'} (see #picklistmenu options)
*/ */
...@@ -1518,24 +1643,24 @@ function MainTableAndCharts( ngdata , initial , search_filter) { ...@@ -1518,24 +1643,24 @@ function MainTableAndCharts( ngdata , initial , search_filter) {
// debug // debug
// alert("refresh main") // alert("refresh main")
console.log("") // console.log("")
console.log(" = = = = MainTableAndCharts: = = = = ") // console.log(" = = = = MainTableAndCharts: = = = = ")
console.log("ngdata:") // console.log("ngdata:")
console.log(ngdata) // console.log(ngdata)
console.log("initial:") // // console.log("initial:") //
console.log(initial) // console.log(initial)
console.log("search_filter:") // eg 'filter_all' // console.log("search_filter:") // eg 'filter_all'
console.log(search_filter) // console.log(search_filter)
console.log(" = = = = / MainTableAndCharts: = = = = ") // console.log(" = = = = / MainTableAndCharts: = = = = ")
console.log("") // console.log("")
// Expected infos in "ngdata.ngrams" should have the form: // Expected infos in "ngdata" should have the form:
// { "1": { id: "1", name: "réalité", score: 36 }, // { "1": { id: "1", name: "réalité", score: 36 },
// "9": { id: "9", name: "pdg", score: 116 }, // "9": { id: "9", name: "pdg", score: 116 },
// "10": { id:"10", name: "infrastructure", score: 12 } etc. } // "10": { id:"10", name: "infrastructure", score: 12 } etc. }
// (see filling of rec_info below) // (see filling of rec_info below)
// console.log(ngdata.ngrams) // console.log(ngdata)
var DistributionDict = {} var DistributionDict = {}
for(var i in DistributionDict) for(var i in DistributionDict)
...@@ -1616,21 +1741,21 @@ function MainTableAndCharts( ngdata , initial , search_filter) { ...@@ -1616,21 +1741,21 @@ function MainTableAndCharts( ngdata , initial , search_filter) {
$('#delAll').data("columnSelection", 'SOME') $('#delAll').data("columnSelection", 'SOME')
$('#mapAll').data("columnSelection", 'SOME') $('#mapAll').data("columnSelection", 'SOME')
var div_stats = "<p>"; // var div_stats = "<p>";
for(var i in ngdata.scores) { // for(var i in ngscores) {
var value = (!isNaN(Number(ngdata.scores[i])))? Number(ngdata.scores[i]).toFixed(1) : ngdata.scores[i]; // var value = (!isNaN(Number(ngscores[i])))? Number(ngscores[i]).toFixed(1) : ngscores[i];
div_stats += i+": "+value+" | " // div_stats += i+": "+value+" | "
} // }
div_stats += "</p>" // div_stats += "</p>"
$("#stats").html(div_stats) // $("#stats").html(div_stats)
AjaxRecords = {} AjaxRecords = {}
for(var id in ngdata.ngrams) { for(var id in ngdata) {
// console.log(i) // console.log(i)
// console.log(ngdata.ngrams[i]) // console.log(ngdata[i])
var le_ngram = ngdata.ngrams[id] ; var le_ngram = ngdata[id] ;
// INIT records // INIT records
// one record <=> one line in the table + ngram states // one record <=> one line in the table + ngram states
...@@ -1643,7 +1768,7 @@ function MainTableAndCharts( ngdata , initial , search_filter) { ...@@ -1643,7 +1768,7 @@ function MainTableAndCharts( ngdata , initial , search_filter) {
"state": (le_ngram.state)?le_ngram.state:0, "state": (le_ngram.state)?le_ngram.state:0,
// properties enabling to see old and new groups // properties enabling to see old and new groups
"group_exists": (le_ngram.id in NGrams.group.links || le_ngram.id in GroupsBuffer), "group_exists": (le_ngram.id in CurrentGroups["links"])
} }
// AjaxRecords.push(rec_info) // AjaxRecords.push(rec_info)
AjaxRecords[id] = rec_info AjaxRecords[id] = rec_info
...@@ -1960,12 +2085,12 @@ function GET_( url , callback ) { ...@@ -1960,12 +2085,12 @@ function GET_( url , callback ) {
// [ = = = = = = = = = = INIT = = = = = = = = = = ] // [ = = = = = = = = = = INIT = = = = = = = = = = ]
// http://localhost:8000/api/node/84592/ngrams?format=json&score=tfidf,occs&list=miam // http://localhost:8000/api/node/84592/ngrams?format=json&score=tfidf,occs&list=miam
var corpus_id = getIDFromURL( "corpora" ) var corpus_id = getIDFromURL( "corpora" )
var NGrams = { var OriginalNG = {
"group" : {}, "records" : {},
"stop" : {}, "stop" : {},
"main" : {},
"map" : {}, "map" : {},
"scores" : {} "scores" : {},
"links" : {}
} }
...@@ -1982,51 +2107,47 @@ var final_url = window.location.origin+"/api/ngramlists/family?corpus="+corpus_i ...@@ -1982,51 +2107,47 @@ var final_url = window.location.origin+"/api/ngramlists/family?corpus="+corpus_i
GET_(final_url, HandleAjax) GET_(final_url, HandleAjax)
function HandleAjax(res, sourceUrl) { function HandleAjax(res, sourceUrl) {
//£TODO unify with AfterAjax
if (res && res.ngraminfos) { if (res && res.ngraminfos) {
main_ngrams_objects = {} // = = = = MIAM = = = = //
OriginalNG["records"] = {}
for (var ngram_id in res.ngraminfos) { for (var ngram_id in res.ngraminfos) {
var ngram_tuple = res.ngraminfos[ngram_id] var ngram_tuple = res.ngraminfos[ngram_id]
main_ngrams_objects[ngram_id] = { OriginalNG["records"][ngram_id] = {
'id' : ngram_id, // redundant but for backwards compat 'id' : ngram_id, // redundant but for backwards compat
'name' : ngram_tuple[0], 'name' : ngram_tuple[0],
'score' : ngram_tuple[1] 'score' : ngram_tuple[1]
} }
} }
// = = = = MIAM = = = = //
NGrams["main"] = { OriginalNG["scores"] = {
"ngrams": main_ngrams_objects,
"scores": {
"initial":"occs", "initial":"occs",
"nb_ngrams":Object.keys(main_ngrams_objects).length, "nb_ngrams":Object.keys(OriginalNG["records"]).length,
} }
} ;
// = = MAP ALSO STOP = = // // = = MAP ALSO STOP = = //
// 2x(array of ids) ==> 2x(lookup hash) // 2x(array of ids) ==> 2x(lookup hash)
NGrams["map"] = {} ; OriginalNG["map"] = {} ;
for (var i in res.listmembers.maplist) { for (var i in res.listmembers.maplist) {
var map_ng_id = res.listmembers.maplist[i] ; var map_ng_id = res.listmembers.maplist[i] ;
NGrams["map"][map_ng_id] = true ; OriginalNG["map"][map_ng_id] = true ;
} }
NGrams["stop"] = {} ; OriginalNG["stop"] = {} ;
for (var i in res.listmembers.stoplist) { for (var i in res.listmembers.stoplist) {
var stop_ng_id = res.listmembers.stoplist[i] ; var stop_ng_id = res.listmembers.stoplist[i] ;
NGrams["stop"][stop_ng_id] = true ; OriginalNG["stop"][stop_ng_id] = true ;
} }
// = = = = GROUP = = = = // // = = = = GROUP = = = = //
NGrams["group"] = { // they go directly to "Current" var (we need not keep the original situation)
"links" : res.links , CurrentGroups["links"] = res.links ;
// "nodesmemory" will be filled from "links" in AfterAjax()
"nodesmemory" : {}
};
} }
// console.log('after init NGrams["main"].ngrams') // console.log('after init OriginalNG["records"]')
// console.log(NGrams["main"].ngrams) // console.log(OriginalNG["records"])
// cache all DB node_ids // cache all DB node_ids
$("input#mainlist_id").val(res.nodeids['mainlist']) $("input#mainlist_id").val(res.nodeids['mainlist'])
...@@ -2039,86 +2160,73 @@ function HandleAjax(res, sourceUrl) { ...@@ -2039,86 +2160,73 @@ function HandleAjax(res, sourceUrl) {
function AfterAjax(sourceUrl) { function AfterAjax(sourceUrl) {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// console.log(JSON.stringify(NGrams)) // console.log(JSON.stringify(OriginalNG))
// ------------------------------------------------------------------- // -------------------------------------------------------------------
state_skip = -1 // -1
state_main = System[0]["statesD"]["normal"] // 0
state_map = System[0]["statesD"]["keep"] // 1
state_stop = System[0]["statesD"]["delete"] // 2
// ----------------------------------------- MAPLIST // ----------------------------------------- MAPLIST
// keepstateId = 1
keepstateId = System[0]["statesD"]["keep"] if( Object.keys(OriginalNG["map"]).length>0 ) {
if( Object.keys(NGrams["map"]).length>0 ) { for(var ngram_id in OriginalNG["map"]) {
for(var ngram_id in NGrams["map"]) { myNgramInfo = OriginalNG["records"][ngram_id]
myNgramInfo = NGrams["main"].ngrams[ngram_id] if (typeof myNgramInfo == "undefined") {
// initialize state of maplist items console.error("record of ngram " + ngram_id + " is undefined")
myNgramInfo["state"] = keepstateId ; }
else {
// initialize state of maplist items
myNgramInfo["state"] = state_map ;
}
} }
} }
// ----------------------------------------- STOPLIST // ----------------------------------------- STOPLIST
// delstateId = 2
delstateId = System[0]["statesD"]["delete"] if( Object.keys(OriginalNG["stop"]).length>0 ) {
if( Object.keys(NGrams["stop"]).length>0 ) { for(var ngram_id in OriginalNG["stop"]) {
for(var ngram_id in NGrams["stop"]) { myNgramInfo = OriginalNG["records"][ngram_id]
console.log('stopping ' + ngram_id) if (typeof myNgramInfo == "undefined") {
myNgramInfo = NGrams["main"].ngrams[ngram_id] console.error("record of ngram " + ngram_id + " is undefined")
// initialize state of stoplist items }
myNgramInfo["state"] = delstateId ; else {
// initialize state of stoplist items
myNgramInfo["state"] = state_stop ;
}
} }
} }
// Deleting subforms from the ngrams-table, clean start baby! // Deactivating subforms from the ngrams-table, clean start baby!
if( Object.keys(NGrams["group"].links).length>0 ) { if( Object.keys(CurrentGroups["links"]).length>0 ) {
// init global actualized subform inventory (reverse index of links)
// subforms inventory { "main":{ all mainform ids } , "sub":{ all subform ids} } // (very useful to find what to change if group is split)
var _forms = { "main":{} , "sub":{} } for(var ngramId in CurrentGroups["links"]) {
for(var ngramId in NGrams["group"].links) { for(var i in CurrentGroups["links"][ngramId]) {
_forms["main"][ngramId] = true var subformId = CurrentGroups["links"][ngramId][i]
for(var i in NGrams["group"].links[ngramId]) { // for each subform: mainform
var subformId = NGrams["group"].links[ngramId][i] CurrentGroups["subs"][ subformId ] = ngramId
// for each subform: true
_forms["sub"][ subformId ] = true
} }
} }
// ------------------------------------------- MAINLIST // use it to deactivate <=> hidden state for all them subforms
// ngrams_data_ will update NGrams.main.ngrams (with subforms removed) for (var subNgramId in CurrentGroups["subs"]) {
var ngrams_data_ = {}
for(var ngram_id in NGrams["main"].ngrams) {
// if ngram is subform of another
if(_forms["sub"][ngram_id]) {
// move subform info into NGrams.group.nodesmemory
// ------------------------------------------
// (subform goes away from new list but info preserved)
// (useful if we want to see/revive subforms in future)
NGrams.group.nodesmemory[ngram_id] = NGrams["main"].ngrams[ngram_id]
// debug:
// console.log(ngram_id + " ("+NGrams["main"].ngrams[ngram_id].name+") is a subform")
}
// normal case
else {
// we keep the info untouched in the new obj
ngrams_data_[ngram_id] = NGrams["main"].ngrams[ngram_id]
}
}
// the new hash of ngrams replaces the old main // will allow us to distinguish it from mainlist items that
NGrams["main"].ngrams = ngrams_data_; // have original state undefined (in InferCRUDFlags)
OriginalNG['records'][subNgramId]['state'] = state_skip
}
} }
// NB: this miamlist will eventually become AjaxRecords
// debug:
// console.log('NGrams["main"]')
// console.log( NGrams["main"] )
// Building the Score-Selector //NGrams["scores"] // Building the Score-Selector //OriginalNG["scores"]
var FirstScore = NGrams["main"].scores.initial var FirstScore = OriginalNG.scores.initial
// TODO scores_div // TODO scores_div
// Recreate possible_scores from some constants (tfidf, occs) // Recreate possible_scores from some constants (tfidf, occs)
// and not from ngrams[0], to keep each ngram's info smaller // and not from ngrams[0], to keep each ngram's info smaller
// var possible_scores = Object.keys( NGrams["main"].ngrams[0].scores ); // var possible_scores = Object.keys( OriginalNG["main"].ngrams[0].scores );
// var scores_div = '<br><select style="font-size:25px;" class="span1" id="scores_selector">'+"\n"; // var scores_div = '<br><select style="font-size:25px;" class="span1" id="scores_selector">'+"\n";
// scores_div += "\t"+'<option value="'+FirstScore+'">'+FirstScore+'</option>'+"\n" // scores_div += "\t"+'<option value="'+FirstScore+'">'+FirstScore+'</option>'+"\n"
// for( var i in possible_scores ) { // for( var i in possible_scores ) {
...@@ -2131,22 +2239,11 @@ function AfterAjax(sourceUrl) { ...@@ -2131,22 +2239,11 @@ function AfterAjax(sourceUrl) {
termsfilter = (sourceUrl == final_url) ? "reset" : "1" termsfilter = (sourceUrl == final_url) ? "reset" : "1"
// Initializing the Charts and Table --------------------------------------- // Initializing the Charts and Table ---------------------------------------
var result = MainTableAndCharts( NGrams["main"] , FirstScore , termsfilter) ; var result = MainTableAndCharts(OriginalNG["records"], FirstScore , termsfilter) ;
console.log( result ) // OK console.log( result ) // OK
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// see TODO scores_div
// Listener for onchange Score-Selector
// scores_div += "<select>"+"\n";
// $("#ScoresBox").html(scores_div)
// $("#scores_selector").on('change', function() {
// console.log( this.value )
// var result = MainTableAndCharts( NGrams["main"] , this.value , "filter_all")
// console.log( result )
//
// });
$("#content_loader").remove() $("#content_loader").remove()
$(".nav-tabs a").click(function(e){ $(".nav-tabs a").click(function(e){
......
...@@ -61,6 +61,7 @@ span.note { ...@@ -61,6 +61,7 @@ span.note {
span.note.glyphicon { span.note.glyphicon {
color: #555; color: #555;
top:0;
} }
p.note { p.note {
...@@ -129,14 +130,10 @@ tr:hover { ...@@ -129,14 +130,10 @@ tr:hover {
margin-bottom: 1em; margin-bottom: 1em;
} }
.oldsubform { .subform {
color: #777 ; color: #777 ;
} }
.usersubform {
color: blue ;
}
.dynatable-record-count { .dynatable-record-count {
font-size: 0.7em; font-size: 0.7em;
} }
......
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