[Issue #276] Round off timestamps when uploading user data

This commit is contained in:
Mavis Ou 2013-07-26 11:43:09 -07:00
Родитель cd475c9012
Коммит f02ad28134
2 изменённых файлов: 17 добавлений и 3 удалений

Просмотреть файл

@ -1,5 +1,6 @@
'use strict';
const roundOffFactor = 5*60*1000; // in milliseconds
var visualizations = {};
var currentVisualization;
var allConnections = [];
@ -237,7 +238,7 @@ function sharingData(){
var connections = allConnections.filter(function(connection){
return ( connection[TIMESTAMP] ) > lastUpload;
});
var data = exportFormat(connections);
var data = exportFormat(connections,true); // round off timestamp
var request = new XMLHttpRequest();
request.open("POST", uploadServer, true);
request.setRequestHeader("Collusion-Share-Data","collusion");

Просмотреть файл

@ -299,12 +299,16 @@ document.querySelector(".stage").addEventListener("mouseleave",function(event){
/* Export ========== */
function exportFormat(connections){
function exportFormat(connections, roundOff){
var tempConnections = excludePrivateConnection(connections).slice(0);
if ( roundOff ){
tempConnections = roundOffTimestamp(tempConnections);
}
return JSON.stringify({
format: 'Collusion Save File',
version: '1.1',
token: localStorage.collusionToken,
connections: excludePrivateConnection(connections)
connections: tempConnections
});
}
@ -315,6 +319,15 @@ function excludePrivateConnection(connections){
})
}
function roundOffTimestamp(connections){
return connections.map(function(conn){
var tempConn = conn.slice(0);
tempConn[TIMESTAMP] -= ( tempConn[TIMESTAMP] % roundOffFactor );
return tempConn;
});
}
/* Info Panel Connections List ===================================== */
document.querySelector(".connections-list ul").addEventListener("click", function(event){