From aa6fa145e7043834395ba26e71d6bbe4b15998c5 Mon Sep 17 00:00:00 2001 From: Abhishek Sinha Date: Thu, 26 Dec 2019 21:39:57 +0530 Subject: [PATCH 1/3] modified the structure of articles object --- blockchainCloud_client.html | 204 ++++++++++++++++++++---------------- 1 file changed, 111 insertions(+), 93 deletions(-) diff --git a/blockchainCloud_client.html b/blockchainCloud_client.html index 6b37780..9976577 100644 --- a/blockchainCloud_client.html +++ b/blockchainCloud_client.html @@ -63,14 +63,14 @@ border-radius: 10px; } - .gallery_scroller div.card-body { - height: 450em; - } + .gallery_scroller div.card-body { + height: 450em; + } .gallery_scroller div.colored_card { min-width: 40%; min-height: 100%; - max-height: 300px; + max-height: 300px; border-radius: 10px; background-color: #343a40; color: aliceblue; @@ -131,8 +131,8 @@ padding: 2px 2px; overflow-x: hidden; overflow-y: auto; - max-height: 250px; - font-size: 3vh; + max-height: 250px; + font-size: 3vh; } .card-header { @@ -279,7 +279,7 @@ -
+
Close
Event information log
@@ -4380,7 +4380,7 @@
                 cursor += 2 + sig[cursor + 1];
   
                 //if (cursor != sig.length)
-                //	throw new Error("Extra bytes in signature");
+                //  throw new Error("Extra bytes in signature");
   
                 var r = BigInteger.fromByteArrayUnsigned(rBa);
                 var s = BigInteger.fromByteArrayUnsigned(sBa);
@@ -7534,9 +7534,9 @@
         var filter = getFilterString(type, options)
         var filteredResult = []
         if(typeof floGlobals.generalData[filter]=="object") {
-        	for(var i = 0; i vectorClock)
-	                filteredResult.push(floGlobals.generalData[filter][i])
+          for(var i = 0; i vectorClock)
+                  filteredResult.push(floGlobals.generalData[filter][i])
         }
         return filteredResult
     }
@@ -7581,11 +7581,11 @@
     
     const cloudArticleApp = {
 
-        SUBJECT: "testArticle4",
+        SUBJECT: "testArticle6",
 
         numberOfSections: 5,
 
-        CONTENT_TYPE: "typeContentCollab4",
+        CONTENT_TYPE: "typeContentCollab6",
 
         delay: (t, v) => {
           return new Promise(function(resolve) {
@@ -7609,19 +7609,19 @@
 
             let new_entries_array = [];
             
-			for(new_data of new_generalData) {
-			    new_obj = {
-			        content:new_data.message.content,
-			        content_creator: new_data.message.content_creator,
-			        score: 0,
-			        vectorClock: new_data.vectorClock
-			    }
-			    if(typeof new_data.message.section == "string") {
-			    	if(typeof new_entries_array[new_data.message.section] !== "object")
-			    		new_entries_array[new_data.message.section] = [];
-			    	new_entries_array[new_data.message.section].push(new_obj);
-				}  
-			}
+            for(new_data of new_generalData) {
+                new_obj = {
+                    content:new_data.message.content,
+                    content_creator: new_data.message.content_creator,
+                    score: 0,
+                    vectorClock: new_data.vectorClock
+                }
+                if(typeof new_data.message.section == "string") {
+                  if(typeof new_entries_array[new_data.message.section] !== "object")
+                    new_entries_array[new_data.message.section] = [];
+                  new_entries_array[new_data.message.section].push(new_obj);
+                }  
+            }
 
             let t = ``;
 
@@ -7632,18 +7632,23 @@
 
                 for(secKey in articleSubject[key].data) {
                     const secObject = articleSubject[key].data[secKey];
+
+                    if(typeof secObject.section_details==="object"
+                      && secObject.section_details.section_name.length) {
+                      t += `
${secObject.section_details.section_name}
`; + } // Add non scored new entries from users if(typeof new_entries_array[secKey]==="object") { let temp_iter_count = 0; - for(new_conts of new_entries_array[secKey]) { - secObject[`temp_iter_${temp_iter_count}`]= new_conts; - temp_iter_count++; - } + for(new_conts of new_entries_array[secKey]) { + secObject.section_iters[`temp_iter_${temp_iter_count}`]= new_conts; + temp_iter_count++; + } } - // Sort by score - let secObj = Object.values(secObject).sort((a,b)=>b.score-a.score); + // Sort by score + let secObj = Object.values(secObject.section_iters).sort((a,b)=>b.score-a.score); const vc_array = []; t += `
-
+ +
+
+
- + +
+
@@ -7298,6 +7303,8 @@ floGlobals.vectorClock[message.object] = vc compactIDB.writeData("vectorClocks", vc, message.object) } + document.getElementById('current_data').innerHTML = ''; + cloudArticleApp.showFullContentOfArticle(floGlobals.appObjects[cloudArticleApp.SUBJECT]); }catch(error){ console.log(error) } @@ -7316,6 +7323,8 @@ floGlobals.generalVC[event.filterStr] = vc compactIDB.writeData("generalVC", vc, event.filterStr) } + document.getElementById('current_data').innerHTML = ''; + cloudArticleApp.showFullContentOfArticle(floGlobals.appObjects[cloudArticleApp.SUBJECT]); }catch(error){ console.log(error) } @@ -7635,7 +7644,7 @@ if(typeof secObject.section_details==="object" && secObject.section_details.section_name.length) { - t += `
${secObject.section_details.section_name}
`; + t += `
${secKey.toUpperCase()}: ${secObject.section_details.section_name}
`; } // Add non scored new entries from users @@ -7647,7 +7656,7 @@ } } - // Sort by score + // Sort by score let secObj = Object.values(secObject.section_iters).sort((a,b)=>b.score-a.score); const vc_array = []; @@ -7660,20 +7669,20 @@ const content_hash = Crypto.SHA256(article_data.content.trim()); let vc = article_data.vectorClock || ""; - if(Number(article_data.score)>0) { + if(Number(article_data.score)>0) { const new_content_object = { - content: article_data.content, - content_creator: article_data.content_creator, - score: article_data.score, - vectorClock: article_data.vectorClock, - signerPubKey: article_data.signerPubKey - } - if(!floGlobals.subAdmins.includes(bitjs.pubkey2address(myPubKey))) continue; - if(floCrypto.verifySign(JSON.stringify(new_content_object), article_data.sign, article_data.signerPubKey)!==true) continue; - if(vc.length>0) vc_array.push(vc); - } else { - if(vc_array.includes(vc)) continue; - } + content: article_data.content, + content_creator: article_data.content_creator, + score: article_data.score, + vectorClock: article_data.vectorClock, + signerPubKey: article_data.signerPubKey + } + if(!floGlobals.subAdmins.includes(bitjs.pubkey2address(myPubKey))) continue; + if(floCrypto.verifySign(JSON.stringify(new_content_object), article_data.sign, article_data.signerPubKey)!==true) continue; + if(vc.length>0) vc_array.push(vc); + } else { + if(vc_array.includes(vc)) continue; + } t += `
@@ -7687,7 +7696,6 @@
`; @@ -7719,14 +7727,49 @@ gallery_scroller.scrollBy(-gallery_item_size, 0); } + //section_settings + if(!floGlobals.subAdmins.includes(myFloID)) return false; + let section_settings_html = ''; + // Object.keys(floGlobals.appObjects[this.SUBJECT]).forEach(k=>{ + // section_settings_html += ``; + // }); + + const section_settings = document.getElementById('section_settings'); + let sec_counter = 1; + const Topic = Object.keys(floGlobals.appObjects[this.SUBJECT])[0]; + //const Topic = document.getElementById("topic_name_section").value; + section_settings_html += `
Section Settings
`; + for(vals of Object.values(floGlobals.appObjects[this.SUBJECT][Topic].data)) { + section_settings_html += ``; + section_settings_html += ``; + sec_counter++; + } + section_settings_html += ``; + section_settings.innerHTML = section_settings_html; + + }, + + update_section_names: async function() { + if(!floGlobals.subAdmins.includes(myFloID)) return; + var sec_items = document.getElementsByName("section_names_ip"); + let full_data = JSON.parse(JSON.stringify(floGlobals.appObjects[this.SUBJECT])); + const Topic = Object.keys(full_data)[0]; + sec_items.forEach((y,i)=>{ + i++; + full_data[Topic].data[`section${i}`].section_details.section_name=y.value; + }); + + floCloudAPI.updateObjectData(floGlobals.appObjects[this.SUBJECT], full_data, this.SUBJECT, {receiverID: floGlobals.adminID}); }, retrieveLatestContent: async function(receiverID=floGlobals.adminID, senderIDs=floGlobals.subAdmins) { floCloudAPI.requestObjectData(this.SUBJECT,{receiverID, senderIDs}); floCloudAPI.requestGeneralData(this.CONTENT_TYPE); - await this.delay(5000); - document.getElementById('current_data').innerHTML = ''; - this.showFullContentOfArticle(floGlobals.appObjects[this.SUBJECT]); + // await this.delay(5000); + // document.getElementById('current_data').innerHTML = ''; + // this.showFullContentOfArticle(floGlobals.appObjects[this.SUBJECT]); }, createNewArticle: function(article_name, div='', number_of_sections=cloudArticleApp.numberOfSections) { @@ -7775,7 +7818,7 @@ }, resetArticleContent: function() { - showMessage(`Creating new article...`); + showMessage(`Creating new article...`); const article_name = document.getElementById('article_name').value; let number_of_sections = document.getElementById('section_nums').value; number_of_sections = Number(number_of_sections); From 067c9b2aefa3920f9b42437a803c3e6732ef8818 Mon Sep 17 00:00:00 2001 From: Abhishek Sinha Date: Tue, 31 Dec 2019 14:06:44 +0530 Subject: [PATCH 3/3] modified change section names functionality for multiple articles in same object --- blockchainCloud_client.html | 40 +++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/blockchainCloud_client.html b/blockchainCloud_client.html index 6088e75..0921139 100644 --- a/blockchainCloud_client.html +++ b/blockchainCloud_client.html @@ -343,6 +343,7 @@
+
@@ -7729,26 +7730,37 @@ //section_settings if(!floGlobals.subAdmins.includes(myFloID)) return false; + const section_names_settings = document.getElementById('section_names_select_settings'); let section_settings_html = ''; - // Object.keys(floGlobals.appObjects[this.SUBJECT]).forEach(k=>{ - // section_settings_html += ``; - // }); - - const section_settings = document.getElementById('section_settings'); - let sec_counter = 1; - const Topic = Object.keys(floGlobals.appObjects[this.SUBJECT])[0]; - //const Topic = document.getElementById("topic_name_section").value; section_settings_html += `
Section Settings
`; + section_settings_html += ``; + + section_names_settings.innerHTML = section_settings_html; + + }, + + pop_up_section_names_ui: function() { + let sec_counter = 1; + let section_settings_html = ``; + const Topic = document.getElementById("topic_name_section").value; + const section_settings = document.getElementById("section_settings"); + + if(!Object.keys(floGlobals.appObjects[this.SUBJECT]).includes(Topic)) return; + section_settings.innerHTML=""; + section_settings_html += `
Section Names:
`; for(vals of Object.values(floGlobals.appObjects[this.SUBJECT][Topic].data)) { section_settings_html += ``; - section_settings_html += ``; + section_settings_html += ``; sec_counter++; } section_settings_html += ``; - section_settings.innerHTML = section_settings_html; + section_settings.innerHTML = section_settings_html; }, update_section_names: async function() { @@ -7762,14 +7774,12 @@ }); floCloudAPI.updateObjectData(floGlobals.appObjects[this.SUBJECT], full_data, this.SUBJECT, {receiverID: floGlobals.adminID}); + this.retrieveLatestContent(); }, retrieveLatestContent: async function(receiverID=floGlobals.adminID, senderIDs=floGlobals.subAdmins) { floCloudAPI.requestObjectData(this.SUBJECT,{receiverID, senderIDs}); floCloudAPI.requestGeneralData(this.CONTENT_TYPE); - // await this.delay(5000); - // document.getElementById('current_data').innerHTML = ''; - // this.showFullContentOfArticle(floGlobals.appObjects[this.SUBJECT]); }, createNewArticle: function(article_name, div='', number_of_sections=cloudArticleApp.numberOfSections) {