Load VC by default and solely rely on VC.getName() for VC name

Change-Id: I14a7894f44dc390af1718053b681d09fcfb2e481
diff --git a/dev/demo/all.html b/dev/demo/all.html
index e19b474..d959a6b 100644
--- a/dev/demo/all.html
+++ b/dev/demo/all.html
@@ -40,7 +40,7 @@
         <div id="vc-view"></div>
         in
         <input id="show" name="show" type="hidden" />
-        <input id="collection-name" name="collection-name" type="hidden">
+        <!--<input id="collection-name" name="collection-name" type="hidden"> -->
         <input id="collection" name="collection" type="text" value="">
 	with <span class="menu select">
 	  <select name="ql" id="ql-field">
diff --git a/dev/demo/alldemo.js b/dev/demo/alldemo.js
index 5a3d3c8..02a6190 100644
--- a/dev/demo/alldemo.js
+++ b/dev/demo/alldemo.js
@@ -765,11 +765,18 @@
 
 KorAP.currentQuery = queryExample;
 
+/*
+KorAP.koralQuery["collection"] = {
+  "@type" : "koral:docGroupRef",
+  "ref" : "This is my name"
+};
+*/
+
 require(['app/en', 'init', 'hint/foundries/cnx'], function (lang) {
   KorAP.hintArray = hintArray;
 
   // Set current virtual collection
-  KorAP.currentVC = vcExample;
+  // KorAP.currentVC = vcExample;
 
   // Parse and show the table
   // Override getMatchInfo API call
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 21887f3..d992c3f 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -40,11 +40,6 @@
              selectMenuClass,
              resultPanelClass) {
 
-  // Localization values
-  const loc = KorAP.Locale;
-  loc.VC_allCorpora    = loc.VC_allCorpora    || 'all corpora';
-  loc.VC_oneCollection = loc.VC_oneCollection || 'a virtual corpus';
-
   const d = document;
 
   KorAP.session = sessionClass.create('KalamarJS');
@@ -87,23 +82,35 @@
      */
     var vcname, vcchoose;
     var input = d.getElementById('collection');
+
+    var vc = vcClass.create(vcArray);
+
+    // Add vc name object
     if (input) {
       input.style.display = 'none';
       vcname = d.createElement('span');
       vcname.setAttribute('id', 'vc-choose');
       vcname.classList.add('select');
 
-      var currentVC = loc.VC_allCorpora;
+      // Load virtual corpus object
       if (KorAP.koralQuery !== undefined && KorAP.koralQuery["collection"]) {
-        currentVC = loc.VC_oneCollection;
+        try {
+          vc.fromJson(KorAP.koralQuery["collection"]);
+        }
+        catch (e) {
+          KorAP.log(0,e);
+        }
       };
 
       vcchoose = vcname.addE('span');
-
       vcchoose.addT(
-        d.getElementById('collection-name').value || currentVC
+        vc.getName()
       );
 
+      if (vc.wasRewritten()) {
+        vcchoose.classList.add('rewritten');
+      };
+
       input.parentNode.insertBefore(vcname, input);
     };
 
@@ -245,7 +252,6 @@
      * Toggle the Virtual Collection builder
      */
     if (vcname) {
-      var vc;
       var vcclick = function () {
         var view = d.getElementById('vc-view');
 
@@ -258,8 +264,6 @@
 
         // The vc is not visible
         else {
-          if (vc === undefined)
-            vc = _getCurrentVC(vcClass, vcArray);
           view.appendChild(vc.element());
           vcname.classList.add('active');
           show['collection'] = true;
@@ -271,11 +275,6 @@
       // Click, if the VC should be shown
       if (show['collection']) {
         vcclick.apply();
-      }
-
-      // else
-      else if (_checkVCrewrite(vcClass)) {
-        vcchoose.classList.add('rewritten');
       };
     };
 
@@ -324,11 +323,6 @@
         // Store session information
         KorAP.session.set("show", show);
 
-        // Set Virtual collection 
-        if (vc === undefined) {
-          vc = _getCurrentVC(vcClass, vcArray);
-        };
-
         if (vc !== undefined) {
           input.value = vc.toQuery();
         }
@@ -354,27 +348,3 @@
     return obj;
   });
 });
-
-
-// Render Virtual collection
-function _getCurrentVC (vcClass, vcArray) {
-  var vc = vcClass.create(vcArray);
-  try {
-    if (KorAP.koralQuery !== undefined && KorAP.koralQuery["collection"]) {
-      vc.fromJson(KorAP.koralQuery["collection"]);
-    };
-  }
-  catch (e) {
-    KorAP.log(0, e);
-    return;
-  }
-  return vc;
-};
-
-
-function _checkVCrewrite (vcClass) {
-  if (KorAP.koralQuery !== undefined && KorAP.koralQuery["collection"]) {
-    return vcClass.checkRewrite(KorAP.koralQuery["collection"]);
-  };
-  return false;
-}