From ac455d58603e20dce1de0f74afaf74f2c4d1cc9b Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 28 Sep 2022 09:17:10 +0200 Subject: [PATCH 001/459] add proto js --- httpdocs/js/webots-cloud.js | 110 +++++++++++++++++++++++++++++++++++- 1 file changed, 108 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 41479f8aa..5c8256de7 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -5,15 +5,18 @@ document.addEventListener('DOMContentLoaded', function() { let scenePage = 1; let animationPage = 1; let simulationPage = 1; + let protoPage = 1; let serverPage = 1; let sceneSort = 'default'; let animationSort = 'default'; let simulationSort = 'default'; + let protoSort = 'default'; let sceneSearch = ''; let animationSearch = ''; let simulationSearch = ''; + let protoSearch = ''; let delaySearch = false; Project.run('webots.cloud', footer(), [ @@ -33,6 +36,10 @@ document.addEventListener('DOMContentLoaded', function() { url: '/simulation', setup: homePage }, + { + url: '/proto', + setup: homePage + }, { url: '/server', setup: homePage @@ -74,6 +81,8 @@ document.addEventListener('DOMContentLoaded', function() { animationPage = page; else if (activeTab === 'simulation') simulationPage = page; + else if (activeTab === 'proto') + protoPage = page; else if (activeTab === 'server') serverPage = page; } @@ -85,6 +94,8 @@ document.addEventListener('DOMContentLoaded', function() { return animationPage; if (activeTab === 'simulation') return simulationPage; + if (activeTab === 'proto') + return protoPage; if (activeTab === 'server') return serverPage; } @@ -96,6 +107,8 @@ document.addEventListener('DOMContentLoaded', function() { animationSort = sort; else if (activeTab === 'simulation') simulationSort = sort; + else if (activeTab === 'proto') + protoSort = sort; } function getSort(activeTab) { @@ -105,6 +118,8 @@ document.addEventListener('DOMContentLoaded', function() { return animationSort; if (activeTab === 'simulation') return simulationSort; + if (activeTab === 'proto') + return protoSort; } function setSearches(activeTab, search) { @@ -114,6 +129,8 @@ document.addEventListener('DOMContentLoaded', function() { animationSearch = search; else if (activeTab === 'simulation') simulationSearch = search; + else if (activeTab === 'proto') + protoSearch = search; else if (activeTab === 'delay') delaySearch = search; } @@ -125,6 +142,8 @@ document.addEventListener('DOMContentLoaded', function() { return animationSearch; if (activeTab === 'simulation') return simulationSearch; + if (activeTab === 'proto') + return protoSearch; if (activeTab === 'delay') return delaySearch; } @@ -154,16 +173,22 @@ document.addEventListener('DOMContentLoaded', function() { project.content.querySelector('#add-a-new-scene').addEventListener('click', function(event) { addAnimation('S'); }); project.content.querySelector('#add-a-new-animation').addEventListener('click', function(event) { addAnimation('A'); }); project.content.querySelector('#add-a-new-project').addEventListener('click', function(event) { addSimulation(); }); + project.content.querySelector('#add-a-new-proto').addEventListener('click', function(event) { addProto(); }); listAnimations('S', scenePage, getSort('scene'), getSearch('scene')); listAnimations('A', animationPage, getSort('animation'), getSearch('animation')); listSimulations(simulationPage, getSort('simulation'), getSearch('simulation')); + listProtos(protoPage, getSort('proto'), getSearch('proto')); listServers(serverPage); - if (project.email && project.email.endsWith('@cyberbotics.com')) + if (project.email && project.email.endsWith('@cyberbotics.com')) { project.content.querySelector('section[data-content="simulation"] > div > table > thead > tr') .appendChild(document.createElement('th')); + project.content.querySelector('section[data-content="proto"] > div > table > thead > tr') + .appendChild(document.createElement('th')); + } + function updatePagination(tab, current, max) { const hrefSort = getSort(tab) && getSort(tab) !== 'default' ? '?sort=' + getSort(tab) : ''; const hrefSearch = getSearch(tab) && getSearch(tab) !== '' ? '?search=' + getSearch(tab) : ''; @@ -313,6 +338,10 @@ document.addEventListener('DOMContentLoaded', function() { return row; } + function protoRow(data) { + // TODO: + } + function percent(value) { const level = 150 + value; let red, green; @@ -359,6 +388,9 @@ document.addEventListener('DOMContentLoaded', function() {
  • Simulation
  • +
  • + Proto +
  • Server
  • @@ -536,6 +568,64 @@ document.addEventListener('DOMContentLoaded', function() { +
    +
    + + + + + + + + + + + + + + +
    + + + + Title + + Branch/Tag + + + + + Version + + Updated +
    + +
    + +
    +
    + +
    +
    +
    @@ -607,7 +697,7 @@ document.addEventListener('DOMContentLoaded', function() { function initSearch(searchString) { if (activeTab !== 'server') document.getElementById(activeTab + '-search-input').value = searchString; - for (let type of ['scene', 'animation', 'simulation']) { + for (let type of ['scene', 'animation', 'simulation', 'proto']) { document.getElementById(type + '-search-input').addEventListener('keyup', function(event) { if (!getSearch('delay')) { setSearches('delay', true); @@ -687,6 +777,8 @@ document.addEventListener('DOMContentLoaded', function() { listAnimations('A', animationPage, getSort(type), getSearch(type)); else if (type === 'simulation') listSimulations(simulationPage, getSort(type), getSearch(type)); + else if (type === 'proto') + listProtos(protoPage, getSort(type), getSearch(type)); } function updateSearchIcon(type) { @@ -703,9 +795,11 @@ document.addEventListener('DOMContentLoaded', function() { updateSearchIcon('scene'); updateSearchIcon('animation'); updateSearchIcon('simulation'); + updateSearchIcon('proto'); } } + //TODO do it for proto as well function synchronizeSimulation(event) { const searchString = getSearch('simulation'); const id = event.target.id.substring(5); @@ -949,6 +1043,10 @@ document.addEventListener('DOMContentLoaded', function() { }); } + function addProto() { + // TODO + } + function listAnimations(type, page, sortBy, searchString) { const typeName = (type === 'A') ? 'animation' : 'scene'; const capitalizedTypeName = typeName.charAt(0).toUpperCase() + typeName.slice(1); @@ -1023,6 +1121,10 @@ document.addEventListener('DOMContentLoaded', function() { }); } + function listProtos(page, sortBy, searchString) { + // TODO + } + function listServers(page) { let offset = (page - 1) * pageLimit; fetch('/ajax/server/list.php', {method: 'post', body: JSON.stringify({offset: offset, limit: pageLimit})}) @@ -1106,6 +1208,10 @@ document.addEventListener('DOMContentLoaded', function() { }); }); } + + function deleteProto(event, project) { + // TODO + } } function runPage(project) { From a50186fbcd898a7e40aeafc408f3c4574e4c2971 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 28 Sep 2022 09:31:27 +0200 Subject: [PATCH 002/459] addProto --- httpdocs/js/webots-cloud.js | 62 ++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 5c8256de7..57a4ddd63 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1044,7 +1044,67 @@ document.addEventListener('DOMContentLoaded', function() { } function addProto() { - // TODO + let content = {}; + content.innerHTML = + `
    + +
    + + + + +
    +
    Blob reference in a public GitHub repository, including tag information, for example:
    + + https://github.com/cyberbotics/webots/blob/R2022b/projects/robots/dji/mavic/protos/Mavic2Pro.proto + + WARNING: your proto must be from version R2022b or newer. +
    +
    `; + let modal = ModalDialog.run('Add a proto', content.innerHTML, 'Cancel', 'Add'); + let input = modal.querySelector('#proto-file'); + input.focus(); + input.selectionStart = input.selectionEnd = input.value.length; + modal.querySelector('form').addEventListener('submit', function(event) { + event.preventDefault(); + modal.querySelector('button[type="submit"]').classList.add('is-loading'); + const protoFile = modal.querySelector('#proto-file').value.trim(); + if (!protoFile.startsWith('https://github.com/')) { + modal.error('The world file should start with "https://github.com/".'); + return; + } + const content = { + method: 'post', + body: JSON.stringify({ + url: protoFile + }) + }; + fetch('/ajax/proto/create.php', content) + .then(function(response) { + return response.json(); + }) + .then(function(data) { + if (data.error) { + let errorMsg = data.error; + if (errorMsg.startsWith('YAML file error:')) { + errorMsg = errorMsg + + ``; + } + modal.error(errorMsg); + } else { + modal.close(); + const tr = '
    ' + simulationRow(data) + ''; + document.querySelector('section[data-content="simulation"] > div > table > tbody').insertAdjacentHTML( + 'beforeend', tr); + const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); + updatePagination('proto', page, total); + project.load(`/proto${(page > 1) ? ('?p=' + page) : ''}`); + } + }); + }); } function listAnimations(type, page, sortBy, searchString) { From fb9c63853cabbbf597bbe760b6b0dcbcfdec2f7e Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 28 Sep 2022 15:20:03 +0200 Subject: [PATCH 003/459] proto ajax folder --- httpdocs/ajax/proto/list.php | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 httpdocs/ajax/proto/list.php diff --git a/httpdocs/ajax/proto/list.php b/httpdocs/ajax/proto/list.php new file mode 100644 index 000000000..51ede220f --- /dev/null +++ b/httpdocs/ajax/proto/list.php @@ -0,0 +1,56 @@ +connect_errno) + error("Can't connect to MySQL database: $mysqli->connect_error"); + $mysqli->set_charset('utf8'); + if (isset($data->url)) { + $url = $data->url; + $query = "UPDATE proto SET viewed = viewed + 1 WHERE url LIKE \"$url\""; + $mysqli->query($query) or error($mysqli->error); + die('{"status":"updated"}'); + } + $sortBy = isset($data->sortBy) && $data->sortBy != "default" && $data->sortBy != "undefined" ? + $mysqli->escape_string($data->sortBy) : "viewed-desc"; + $parameter = explode("-", $sortBy)[0]; + $order = explode("-", $sortBy)[1]; + if ($parameter == "title" || $parameter == "Version") { + if ($order == "asc") + $order = "desc"; + else + $order = "asc"; + } + $branch = basename(dirname(__FILE__, 4)); + $condition = "branch=\"$branch\""; + if (isset($data->search)) { + $searchString = $mysqli->escape_string($data->search); + $condition .= " AND LOWER(title) LIKE LOWER('%$searchString%')"; + } + $offset = isset($data->offset) ? intval($data->offset) : 0; + $limit = isset($data->limit) ? intval($data->limit) : 10; + $query = "SELECT * FROM project WHERE $condition ORDER BY $parameter $order LIMIT $limit OFFSET $offset"; + $result = $mysqli->query($query) or error($mysqli->error); + $projects = array(); + while($row = $result->fetch_array(MYSQLI_ASSOC)) { + settype($row['id'], 'integer'); + settype($row['viewed'], 'integer'); + settype($row['stars'], 'integer'); + settype($row['competitors'], 'integer'); + $row['title'] = htmlentities($row['title']); + $row['description'] = htmlentities($row['description']); + $row['version'] = htmlentities($row['version']); + array_push($projects, $row); + } + $result = $mysqli->query("SELECT COUNT(*) AS count FROM project WHERE $condition") or error($mysqli->error); + $count = $result->fetch_array(MYSQLI_ASSOC); + $answer = new StdClass; + $answer->projects = $projects; + $answer->total = intval($count['count']); + die(json_encode($answer)); + ?> From 2ab891bada177c15ee13543dca721a6c43ddbb07 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 28 Sep 2022 17:04:58 +0200 Subject: [PATCH 004/459] create and list --- httpdocs/ajax/proto/create.php | 118 +++++++++++++++++++++++++++++++++ httpdocs/ajax/proto/list.php | 17 +++-- 2 files changed, 126 insertions(+), 9 deletions(-) create mode 100644 httpdocs/ajax/proto/create.php diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php new file mode 100644 index 000000000..f9a5189a1 --- /dev/null +++ b/httpdocs/ajax/proto/create.php @@ -0,0 +1,118 @@ +connect_errno) + error("Can't connect to MySQL database: $mysqli->connect_error"); +$mysqli->set_charset('utf8'); +$url = $mysqli->escape_string($data->url); +$id = isset($data->id) ? intval($data->id) : 0; + +# check content +$check_url = proto_check_url($url); +if (!is_array($check_url)) + error($check_url); +list($username, $repository, $tag_or_branch, $folder, $world) = $check_url; +$world_url = "https://raw.githubusercontent.com/$username/$repository/$tag_or_branch$folder/worlds/$world"; +$world_content = @file_get_contents($world_url); +if ($world_content === false) { + $query = "DELETE FROM proto WHERE id=$id"; + $mysqli->query($query) or error($mysqli->error); + if ($mysqli->affected_rows === 0) + error("Failed to delete proto with world file '$world'"); + error("Failed to fetch world file $world"); +} + +# check and retrieve information from webots.yaml file +$check_yaml = proto_check_yaml($check_url); +if (!is_array($check_yaml)) { + $query = "DELETE FROM proto WHERE id=$id"; + $mysqli->query($query) or error($mysqli->error); + error($check_yaml); +} +list($type, $benchmark, $competition) = $check_yaml; + +# retrieve the name and info (description) from the header. +$info = false; +$name = ''; +$description = ''; +$line = strtok($world_content, "\r\n"); +$version = $mysqli->escape_string(substr($line, 10, 6)); // "#VRML_SIM R2022b utf8" -> "R2022b" +$line = strtok("\r\n"); +while ($line !== false) { + $line == trim(line); + if ($line[0] === '#') { + if (strtolower(substr($line, 0, 9)) !== '# license' && strtolower(substr($line, 0, 8)) !== '#license' && + strtolower(substr($line, 0, 10)) !== '# template' && strtolower(substr($line, 0, 9)) !== '#template' && substr($line, 0, 5) !== '#VRML') { + if ($description !== '') + $description .= "\n"; + $description .= $mysqli->escape_string(substr($line, 2); + } + } + elseif (substr($line, 0, 5) === 'PROTO') + $name = trim(substr($line, 5)); + if ($name[-1] === '[') + $name = trim(substr($line, 0, -1)); + $line = strtok("\r\n"); +} + +$auth = "Authorization: Basic " . base64_encode("$github_oauth_client_id:$github_oauth_client_secret"); +$context = stream_context_create(['http' => ['method' => 'GET', 'header' => ['User-Agent: PHP', $auth]]]); +$info_json = @file_get_contents("https://api.github.com/repos/$username/$repository", false, $context); +$info = json_decode($info_json); +$stars = intval($info->{'stargazers_count'}); +$competitors = 0; +$query = "SELECT viewed FROM proto WHERE url=\"$url\" AND id=$id"; +$result = $mysqli->query($query) or error($mysqli->error); +$row = $result->fetch_array(MYSQLI_ASSOC); +$viewed = ($result && $row) ? $row['viewed'] : 0; +$branch = basename(dirname(__FILE__, 4)); +if ($id === 0) + $query = "INSERT IGNORE INTO proto(url, viewed, stars, name, description, version, competitors, type, branch) " + ."VALUES(\"$url\", $viewed, $stars, \"$name\", \"$description\", \"$version\", $competitors, \"$type\", \"$branch\")"; +else + $query = "UPDATE proto SET viewed=$viewed, stars=$stars, name=\"$name\", description=\"$description\", " + ."version=\"$version\", competitors=$competitors, type=\"$type\", updated=NOW() " + ."WHERE url=\"$url\" AND id=$id"; +$mysqli->query($query) or error($mysqli->error); +if ($mysqli->affected_rows != 1) { + if ($id === 0) + error("This proto already exists"); + else + error("Failed to update the proto"); +} + +# return answer +$search = isset($data->search) ? $data->search : ""; +$condition = "branch=\"$branch\""; +if ($search != "") + $condition .= " AND LOWER(title) LIKE LOWER('%$search%')"; + +$result = $mysqli->query("SELECT COUNT(*) AS count FROM proto WHERE $condition") or error($mysqli->error); +$count = $result->fetch_array(MYSQLI_ASSOC); +$total = intval($count['count']); + +$answer = array(); +$answer['id'] = ($id === 0) ? $mysqli->insert_id : $id; +$answer['url'] = $url; +$answer['viewed'] = $viewed; +$answer['stars'] = $stars; +$answer['title'] = $title; +$answer['type'] = $type; +$answer['description'] = $description; +$answer['version'] = $version; +$answer['competitors'] = $competitors; +$answer['updated'] = date("Y-m-d H:i:s"); +$answer['total'] = $total; +die(json_encode($answer)); +?> diff --git a/httpdocs/ajax/proto/list.php b/httpdocs/ajax/proto/list.php index 51ede220f..71f972a4d 100644 --- a/httpdocs/ajax/proto/list.php +++ b/httpdocs/ajax/proto/list.php @@ -1,4 +1,4 @@ -escape_string($data->sortBy) : "viewed-desc"; $parameter = explode("-", $sortBy)[0]; $order = explode("-", $sortBy)[1]; - if ($parameter == "title" || $parameter == "Version") { + if ($parameter == "name" || $parameter == "version") { if ($order == "asc") $order = "desc"; else @@ -34,23 +34,22 @@ function error($message) { } $offset = isset($data->offset) ? intval($data->offset) : 0; $limit = isset($data->limit) ? intval($data->limit) : 10; - $query = "SELECT * FROM project WHERE $condition ORDER BY $parameter $order LIMIT $limit OFFSET $offset"; + $query = "SELECT * FROM proto WHERE $condition ORDER BY $parameter $order LIMIT $limit OFFSET $offset"; $result = $mysqli->query($query) or error($mysqli->error); - $projects = array(); + $protos = array(); while($row = $result->fetch_array(MYSQLI_ASSOC)) { settype($row['id'], 'integer'); settype($row['viewed'], 'integer'); settype($row['stars'], 'integer'); - settype($row['competitors'], 'integer'); - $row['title'] = htmlentities($row['title']); + $row['name'] = htmlentities($row['name']); $row['description'] = htmlentities($row['description']); $row['version'] = htmlentities($row['version']); - array_push($projects, $row); + array_push($protos, $row); } - $result = $mysqli->query("SELECT COUNT(*) AS count FROM project WHERE $condition") or error($mysqli->error); + $result = $mysqli->query("SELECT COUNT(*) AS count FROM proto WHERE $condition") or error($mysqli->error); $count = $result->fetch_array(MYSQLI_ASSOC); $answer = new StdClass; - $answer->projects = $projects; + $answer->protos = $protos; $answer->total = intval($count['count']); die(json_encode($answer)); ?> From 8b6996049a93d23058629567240bf6d9dbf3e66e Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 28 Sep 2022 17:09:40 +0200 Subject: [PATCH 005/459] debug print --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 57a4ddd63..9d7df509c 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1081,6 +1081,7 @@ document.addEventListener('DOMContentLoaded', function() { }; fetch('/ajax/proto/create.php', content) .then(function(response) { + console.log(response.text()) return response.json(); }) .then(function(data) { From 0d074265b0d636adde31f4272aa29bf2df1559bc Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 28 Sep 2022 17:10:46 +0200 Subject: [PATCH 006/459] missing parenthesis --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index f9a5189a1..062ceb49b 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -56,7 +56,7 @@ function error($message) { strtolower(substr($line, 0, 10)) !== '# template' && strtolower(substr($line, 0, 9)) !== '#template' && substr($line, 0, 5) !== '#VRML') { if ($description !== '') $description .= "\n"; - $description .= $mysqli->escape_string(substr($line, 2); + $description .= $mysqli->escape_string(substr($line, 2)); } } elseif (substr($line, 0, 5) === 'PROTO') From d3c8b138c2862d6ae6d087ef467441c75829e7f3 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 08:03:24 +0200 Subject: [PATCH 007/459] debug --- httpdocs/ajax/project/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/project/create.php b/httpdocs/ajax/project/create.php index 620ce6321..116391b00 100644 --- a/httpdocs/ajax/project/create.php +++ b/httpdocs/ajax/project/create.php @@ -97,7 +97,7 @@ function error($message) { $mysqli->query($query) or error($mysqli->error); if ($mysqli->affected_rows != 1) { if ($id === 0) - error("This simulation already exists"); + error("This simulation already exists branch=$branch"); else error("Failed to update the simulation"); } From e4da440b9411df84f16a1c02755041b254d5e071 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 08:18:40 +0200 Subject: [PATCH 008/459] remove debug --- httpdocs/ajax/project/create.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/project/create.php b/httpdocs/ajax/project/create.php index 116391b00..7ce6b76fe 100644 --- a/httpdocs/ajax/project/create.php +++ b/httpdocs/ajax/project/create.php @@ -97,9 +97,9 @@ function error($message) { $mysqli->query($query) or error($mysqli->error); if ($mysqli->affected_rows != 1) { if ($id === 0) - error("This simulation already exists branch=$branch"); + error("This simulation already exists branch."); else - error("Failed to update the simulation"); + error("Failed to update the simulation."); } # return answer From d445b63e8123c2185e5d7d25ac849ed598dfc9fa Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 08:20:07 +0200 Subject: [PATCH 009/459] typo --- httpdocs/ajax/project/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/project/create.php b/httpdocs/ajax/project/create.php index 7ce6b76fe..457bbbe99 100644 --- a/httpdocs/ajax/project/create.php +++ b/httpdocs/ajax/project/create.php @@ -97,7 +97,7 @@ function error($message) { $mysqli->query($query) or error($mysqli->error); if ($mysqli->affected_rows != 1) { if ($id === 0) - error("This simulation already exists branch."); + error("This simulation already exists."); else error("Failed to update the simulation."); } From fbc0613e69511e4788f8a2fb3c0103919cb97149 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 08:31:40 +0200 Subject: [PATCH 010/459] proto sql --- database/webots-cloud.sql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/database/webots-cloud.sql b/database/webots-cloud.sql index 301190f75..259a6d325 100644 --- a/database/webots-cloud.sql +++ b/database/webots-cloud.sql @@ -82,4 +82,21 @@ CREATE TABLE `server_branch` ( ALTER TABLE `server_branch` ADD PRIMARY KEY (`id`,`branch`); +CREATE TABLE `proto` ( + `id` int(11) NOT NULL, + `url` varchar(2048) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, + `stars` int(11) NOT NULL, + `name` varchar(256) CHARACTER SET utf8mb4 NOT NULL, + `description` varchar(2048) CHARACTER SET utf8mb4 NOT NULL, + `version` varchar(16) NOT NULL, + `branch` varchar(256) CHARACTER SET utf8mb4 NOT NULL, + `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `viewed` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +ALTER TABLE `proto` + ADD PRIMARY KEY (`id`), + ADD UNIQUE KEY `url_branch` (`url`,`branch`) USING BTREE; + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; + COMMIT; From 69d6935d9b5ae238ab8e26f829d55dcd53613b8f Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 09:02:51 +0200 Subject: [PATCH 011/459] simulation.php -> github_asset.php --- httpdocs/ajax/project/create.php | 2 +- httpdocs/ajax/proto/create.php | 2 +- php/{simulation.php => github_asset.php} | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) rename php/{simulation.php => github_asset.php} (91%) diff --git a/httpdocs/ajax/project/create.php b/httpdocs/ajax/project/create.php index 457bbbe99..d8ab5b196 100644 --- a/httpdocs/ajax/project/create.php +++ b/httpdocs/ajax/project/create.php @@ -10,7 +10,7 @@ function error($message) { $data = json_decode($json); require '../../../php/github_oauth.php'; require '../../../php/database.php'; -require '../../../php/simulation.php'; +require '../../../php/github_asset.php'; $mysqli = new mysqli($database_host, $database_username, $database_password, $database_name); if ($mysqli->connect_errno) error("Can't connect to MySQL database: $mysqli->connect_error"); diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 062ceb49b..bae1fac29 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -10,7 +10,7 @@ function error($message) { $data = json_decode($json); require '../../../php/github_oauth.php'; require '../../../php/database.php'; -require '../../../php/proto.php'; +require '../../../php/github_asset.php'; $mysqli = new mysqli($database_host, $database_username, $database_password, $database_name); if ($mysqli->connect_errno) error("Can't connect to MySQL database: $mysqli->connect_error"); diff --git a/php/simulation.php b/php/github_asset.php similarity index 91% rename from php/simulation.php rename to php/github_asset.php index 7e850e336..9f844d091 100644 --- a/php/simulation.php +++ b/php/github_asset.php @@ -4,6 +4,18 @@ function simulation_check_url($url) { return "The URL should start with 'https://github.com/'"; if (substr($url, -4) != '.wbt') return "The URL should end with '.wbt': " . substr($url, -4); + return check_url($url); +} + +function proto_check_url($url) { + if (substr($url, 0, 19) !== 'https://github.com/') + return "The URL should start with 'https://github.com/'"; + if (substr($url, -6) != '.proto') + return "The URL should end with '.proto': " . substr($url, -6); + return check_url($url); +} + +function check_url($url) { $exploded = explode('/', substr($url, 19)); $count = count($exploded); if ($count < 6) From aab65011a2f2ac899064821fa80938d6b76b694d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 09:17:32 +0200 Subject: [PATCH 012/459] protos folder --- php/github_asset.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/php/github_asset.php b/php/github_asset.php index 9f844d091..a4d2c00cc 100644 --- a/php/github_asset.php +++ b/php/github_asset.php @@ -12,10 +12,10 @@ function proto_check_url($url) { return "The URL should start with 'https://github.com/'"; if (substr($url, -6) != '.proto') return "The URL should end with '.proto': " . substr($url, -6); - return check_url($url); + return check_url($url, true); } -function check_url($url) { +function check_url($url, $proto = false) { $exploded = explode('/', substr($url, 19)); $count = count($exploded); if ($count < 6) @@ -40,11 +40,20 @@ function check_url($url) { return 'Wrong folder name'; if ($folder !== '') $folder = "/$folder"; - $worlds_folder = $exploded[$count - 2]; - if ($worlds_folder != 'worlds') - return 'Missing \'/worlds/\' folder in URL'; - $world = $exploded[$count - 1]; - return array($username, $repository, $tag_or_branch, $folder, $world); + + $world_or_proto; + $worlds_or_protos_folder = $exploded[$count - 2]; + if ($proto) { + if ($worlds_or_protos_folder != 'protos') + return 'Missing \'/protos/\' folder in URL'; + $world_or_proto = $exploded[$count - 1]; + } else { + if ($worlds_or_protos_folder != 'worlds') + return 'Missing \'/worlds/\' folder in URL'; + $world_or_proto = $exploded[$count - 1]; + } + + return array($username, $repository, $tag_or_branch, $folder, $world_or_proto); } function simulation_check_yaml($check_url) { From a9455c1d104ffb27cb02fe55bbd7c5c450e522c7 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 09:21:07 +0200 Subject: [PATCH 013/459] world->proto --- httpdocs/ajax/proto/create.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index bae1fac29..e5e25760c 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -22,15 +22,15 @@ function error($message) { $check_url = proto_check_url($url); if (!is_array($check_url)) error($check_url); -list($username, $repository, $tag_or_branch, $folder, $world) = $check_url; -$world_url = "https://raw.githubusercontent.com/$username/$repository/$tag_or_branch$folder/worlds/$world"; -$world_content = @file_get_contents($world_url); -if ($world_content === false) { +list($username, $repository, $tag_or_branch, $folder, $proto) = $check_url; +$proto_url = "https://raw.githubusercontent.com/$username/$repository/$tag_or_branch$folder/protos/$proto"; +$proto_content = @file_get_contents($proto_url); +if ($proto_content === false) { $query = "DELETE FROM proto WHERE id=$id"; $mysqli->query($query) or error($mysqli->error); if ($mysqli->affected_rows === 0) - error("Failed to delete proto with world file '$world'"); - error("Failed to fetch world file $world"); + error("Failed to delete proto with proto file '$proto'"); + error("Failed to fetch proto file $proto"); } # check and retrieve information from webots.yaml file @@ -46,7 +46,7 @@ function error($message) { $info = false; $name = ''; $description = ''; -$line = strtok($world_content, "\r\n"); +$line = strtok($proto_content, "\r\n"); $version = $mysqli->escape_string(substr($line, 10, 6)); // "#VRML_SIM R2022b utf8" -> "R2022b" $line = strtok("\r\n"); while ($line !== false) { From 96e81e3a0c152ce84e099f416dc67eeb516cbd28 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 09:35:48 +0200 Subject: [PATCH 014/459] yaml --- database/webots-cloud.sql | 4 ++-- httpdocs/ajax/project/create.php | 2 +- httpdocs/ajax/proto/create.php | 11 ++++------- php/github_asset.php | 4 ++-- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/database/webots-cloud.sql b/database/webots-cloud.sql index 259a6d325..3baa2f0ce 100644 --- a/database/webots-cloud.sql +++ b/database/webots-cloud.sql @@ -36,6 +36,7 @@ ALTER TABLE `server` CREATE TABLE `project` ( `id` int(11) NOT NULL, `url` varchar(2048) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, + `viewed` int(11) NOT NULL, `stars` int(11) NOT NULL, `title` varchar(256) NOT NULL, `description` varchar(2048) NOT NULL, @@ -43,8 +44,7 @@ CREATE TABLE `project` ( `type` enum('demo','competition','benchmark','') NOT NULL, `branch` varchar(256) CHARACTER SET utf8 NOT NULL DEFAULT 'main', `competitors` int(11) NOT NULL, - `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `viewed` int(11) NOT NULL + `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ALTER TABLE `project` diff --git a/httpdocs/ajax/project/create.php b/httpdocs/ajax/project/create.php index d8ab5b196..34fcfe2c4 100644 --- a/httpdocs/ajax/project/create.php +++ b/httpdocs/ajax/project/create.php @@ -34,7 +34,7 @@ function error($message) { } # check and retrieve information from webots.yaml file -$check_yaml = simulation_check_yaml($check_url); +$check_yaml = github_check_yaml($check_url, $proto = false); if (!is_array($check_yaml)) { $query = "DELETE FROM project WHERE id=$id"; $mysqli->query($query) or error($mysqli->error); diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index e5e25760c..c958ff68b 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -34,13 +34,12 @@ function error($message) { } # check and retrieve information from webots.yaml file -$check_yaml = proto_check_yaml($check_url); +$check_yaml = github_check_yaml($check_url, true); if (!is_array($check_yaml)) { $query = "DELETE FROM proto WHERE id=$id"; $mysqli->query($query) or error($mysqli->error); error($check_yaml); } -list($type, $benchmark, $competition) = $check_yaml; # retrieve the name and info (description) from the header. $info = false; @@ -78,11 +77,11 @@ function error($message) { $viewed = ($result && $row) ? $row['viewed'] : 0; $branch = basename(dirname(__FILE__, 4)); if ($id === 0) - $query = "INSERT IGNORE INTO proto(url, viewed, stars, name, description, version, competitors, type, branch) " - ."VALUES(\"$url\", $viewed, $stars, \"$name\", \"$description\", \"$version\", $competitors, \"$type\", \"$branch\")"; + $query = "INSERT IGNORE INTO proto(url, viewed, stars, name, description, version, branch) " + ."VALUES(\"$url\", $viewed, $stars, \"$name\", \"$description\", \"$version\", \"$branch\")"; else $query = "UPDATE proto SET viewed=$viewed, stars=$stars, name=\"$name\", description=\"$description\", " - ."version=\"$version\", competitors=$competitors, type=\"$type\", updated=NOW() " + ."version=\"$version\", updated=NOW() " ."WHERE url=\"$url\" AND id=$id"; $mysqli->query($query) or error($mysqli->error); if ($mysqli->affected_rows != 1) { @@ -108,10 +107,8 @@ function error($message) { $answer['viewed'] = $viewed; $answer['stars'] = $stars; $answer['title'] = $title; -$answer['type'] = $type; $answer['description'] = $description; $answer['version'] = $version; -$answer['competitors'] = $competitors; $answer['updated'] = date("Y-m-d H:i:s"); $answer['total'] = $total; die(json_encode($answer)); diff --git a/php/github_asset.php b/php/github_asset.php index a4d2c00cc..f6e20e4b8 100644 --- a/php/github_asset.php +++ b/php/github_asset.php @@ -56,14 +56,14 @@ function check_url($url, $proto = false) { return array($username, $repository, $tag_or_branch, $folder, $world_or_proto); } -function simulation_check_yaml($check_url) { +function project_check_yaml($check_url) { # yaml error return function yaml_error($msg) { return "YAML file error: $msg"; } # get file from github - list($username, $repository, $version, $folder, $world) = $check_url; + list($username, $repository, $version, $folder, $world_or_proto) = $check_url; $yaml_url = "https://raw.githubusercontent.com/$username/$repository/$version$folder/webots.yaml"; $yaml_content = @file_get_contents($yaml_url); if ($yaml_content === false) { From 960233a6309c57f101035a306551fb2d0f112b7f Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 09:36:23 +0200 Subject: [PATCH 015/459] name --- php/github_asset.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/github_asset.php b/php/github_asset.php index f6e20e4b8..528d3eb26 100644 --- a/php/github_asset.php +++ b/php/github_asset.php @@ -56,7 +56,7 @@ function check_url($url, $proto = false) { return array($username, $repository, $tag_or_branch, $folder, $world_or_proto); } -function project_check_yaml($check_url) { +function github_check_yaml($check_url) { # yaml error return function yaml_error($msg) { return "YAML file error: $msg"; From d4790301a002a16b2c82648747897674fd8f416f Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 09:47:19 +0200 Subject: [PATCH 016/459] yaml --- httpdocs/ajax/proto/create.php | 2 +- php/github_asset.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index c958ff68b..681b7513f 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -49,7 +49,7 @@ function error($message) { $version = $mysqli->escape_string(substr($line, 10, 6)); // "#VRML_SIM R2022b utf8" -> "R2022b" $line = strtok("\r\n"); while ($line !== false) { - $line == trim(line); + $line == trim($line); if ($line[0] === '#') { if (strtolower(substr($line, 0, 9)) !== '# license' && strtolower(substr($line, 0, 8)) !== '#license' && strtolower(substr($line, 0, 10)) !== '# template' && strtolower(substr($line, 0, 9)) !== '#template' && substr($line, 0, 5) !== '#VRML') { diff --git a/php/github_asset.php b/php/github_asset.php index 528d3eb26..665ee0cb1 100644 --- a/php/github_asset.php +++ b/php/github_asset.php @@ -56,7 +56,7 @@ function check_url($url, $proto = false) { return array($username, $repository, $tag_or_branch, $folder, $world_or_proto); } -function github_check_yaml($check_url) { +function github_check_yaml($check_url, $proto) { # yaml error return function yaml_error($msg) { return "YAML file error: $msg"; @@ -103,7 +103,7 @@ function yaml_error($msg) { return yaml_error("competitor type only requires one scenario (benchmark or competition)"); elseif ($benchmark === '' && $competition === '') return yaml_error("competitor type requires a scenario (benchmark or competition)"); - } elseif ($type === '') + } elseif ($type === '' && $proto === false) return yaml_error("type not defined."); # return array with YAML file info From a4b3f6b957a67bd22a7a11e4a2a072176749ad70 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 09:48:27 +0200 Subject: [PATCH 017/459] title --- httpdocs/ajax/proto/create.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 681b7513f..8dd2b265a 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -95,7 +95,7 @@ function error($message) { $search = isset($data->search) ? $data->search : ""; $condition = "branch=\"$branch\""; if ($search != "") - $condition .= " AND LOWER(title) LIKE LOWER('%$search%')"; + $condition .= " AND LOWER(name) LIKE LOWER('%$search%')"; $result = $mysqli->query("SELECT COUNT(*) AS count FROM proto WHERE $condition") or error($mysqli->error); $count = $result->fetch_array(MYSQLI_ASSOC); @@ -106,7 +106,7 @@ function error($message) { $answer['url'] = $url; $answer['viewed'] = $viewed; $answer['stars'] = $stars; -$answer['title'] = $title; +$answer['name'] = $name; $answer['description'] = $description; $answer['version'] = $version; $answer['updated'] = date("Y-m-d H:i:s"); From 262980638097ca5b69394bf3943bf1f4aec6102d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 09:52:59 +0200 Subject: [PATCH 018/459] remove debug print --- httpdocs/js/webots-cloud.js | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 9d7df509c..57a4ddd63 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1081,7 +1081,6 @@ document.addEventListener('DOMContentLoaded', function() { }; fetch('/ajax/proto/create.php', content) .then(function(response) { - console.log(response.text()) return response.json(); }) .then(function(data) { From c68a931d86253d0923a131fcb1a798bc84f7648e Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 09:55:36 +0200 Subject: [PATCH 019/459] fix name --- httpdocs/ajax/proto/create.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 8dd2b265a..f6ef237bc 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -58,10 +58,10 @@ function error($message) { $description .= $mysqli->escape_string(substr($line, 2)); } } - elseif (substr($line, 0, 5) === 'PROTO') - $name = trim(substr($line, 5)); + elseif (substr($line, 0, 6) === 'PROTO ') + $name = trim(substr($line, 6)); if ($name[-1] === '[') - $name = trim(substr($line, 0, -1)); + $name = trim(substr($name, 0, -1)); $line = strtok("\r\n"); } From 75714030f94d9898cf107fcebc4799f577195547 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 10:10:20 +0200 Subject: [PATCH 020/459] debug print --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 57a4ddd63..9d7df509c 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1081,6 +1081,7 @@ document.addEventListener('DOMContentLoaded', function() { }; fetch('/ajax/proto/create.php', content) .then(function(response) { + console.log(response.text()) return response.json(); }) .then(function(data) { From 5812ce8cd7242109e9b368a98eecf5b40c216a87 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 10:17:18 +0200 Subject: [PATCH 021/459] test empty --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index f6ef237bc..900c460bb 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -60,7 +60,7 @@ function error($message) { } elseif (substr($line, 0, 6) === 'PROTO ') $name = trim(substr($line, 6)); - if ($name[-1] === '[') + if (!empty($name) && $name[-1] === '[') $name = trim(substr($name, 0, -1)); $line = strtok("\r\n"); } From a3692b7d4795fcd02d358568eb68d61bf4dca3e9 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 10:18:26 +0200 Subject: [PATCH 022/459] remove debug --- httpdocs/js/webots-cloud.js | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 9d7df509c..57a4ddd63 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1081,7 +1081,6 @@ document.addEventListener('DOMContentLoaded', function() { }; fetch('/ajax/proto/create.php', content) .then(function(response) { - console.log(response.text()) return response.json(); }) .then(function(data) { From 20a921274a2a8f7dce611675665f8d40c746d966 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 10:21:50 +0200 Subject: [PATCH 023/459] update not found --- httpdocs/404.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/404.php b/httpdocs/404.php index e87f44684..84d2499d6 100644 --- a/httpdocs/404.php +++ b/httpdocs/404.php @@ -2,7 +2,7 @@ $uri = strtok($_SERVER['REQUEST_URI'], '?'); if (strlen($uri) == 8 && in_array($uri[1], array('A', 'S'))) $found = file_exists('storage' . $uri); -elseif (in_array($uri, array('/settings', '/terms-of-service', '/privacy-policy', '/scene', '/animation', '/demo', '/server', '/simulation'))) +elseif (in_array($uri, array('/settings', '/terms-of-service', '/privacy-policy', '/scene', '/animation', '/demo', '/server', '/simulation', 'proto'))) $found = true; else $found = false; From a30d849c689c118464ad6f85ddeb8537681619c2 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 10:22:29 +0200 Subject: [PATCH 024/459] typo --- httpdocs/404.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/404.php b/httpdocs/404.php index 84d2499d6..e45c719f7 100644 --- a/httpdocs/404.php +++ b/httpdocs/404.php @@ -2,7 +2,7 @@ $uri = strtok($_SERVER['REQUEST_URI'], '?'); if (strlen($uri) == 8 && in_array($uri[1], array('A', 'S'))) $found = file_exists('storage' . $uri); -elseif (in_array($uri, array('/settings', '/terms-of-service', '/privacy-policy', '/scene', '/animation', '/demo', '/server', '/simulation', 'proto'))) +elseif (in_array($uri, array('/settings', '/terms-of-service', '/privacy-policy', '/scene', '/animation', '/demo', '/server', '/simulation', '/proto'))) $found = true; else $found = false; From bcd63d706aebfdb4029ec49dcfa5f957b2af680a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 10:24:03 +0200 Subject: [PATCH 025/459] typo --- httpdocs/ajax/proto/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/list.php b/httpdocs/ajax/proto/list.php index 71f972a4d..cb5de8dc6 100644 --- a/httpdocs/ajax/proto/list.php +++ b/httpdocs/ajax/proto/list.php @@ -30,7 +30,7 @@ function error($message) { $condition = "branch=\"$branch\""; if (isset($data->search)) { $searchString = $mysqli->escape_string($data->search); - $condition .= " AND LOWER(title) LIKE LOWER('%$searchString%')"; + $condition .= " AND LOWER(name) LIKE LOWER('%$searchString%')"; } $offset = isset($data->offset) ? intval($data->offset) : 0; $limit = isset($data->limit) ? intval($data->limit) : 10; From 1327d7501ccd12d06c254bf6872445d1331fafaa Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 11:24:26 +0200 Subject: [PATCH 026/459] list --- httpdocs/js/webots-cloud.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 57a4ddd63..04d3fae8b 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1182,7 +1182,38 @@ document.addEventListener('DOMContentLoaded', function() { } function listProtos(page, sortBy, searchString) { - // TODO + let offset = (page - 1) * pageLimit; + fetch('/ajax/proto/list.php', {method: 'post', + body: JSON.stringify({offset: offset, limit: pageLimit, sortBy: sortBy, search: searchString})}) + .then(function(response) { + return response.json(); + }) + .then(function(data) { + if (data.error) + ModalDialog.run('Proto listing error', data.error); + else { + if (data.total === 0 && searchString) { + const message = 'Your search - ' + searchString + ' - did not match any protos.'; + document.getElementById('proto-empty-search-text').innerHTML = message; + document.getElementById('proto-empty-search').style.display = 'flex'; + } else + document.getElementById('proto-empty-search').style.display = 'none'; + let line = ``; + for (let i = 0; i < data.protos.length; i++) // compute the GitHub repo URL from the simulation URL. + line += '' + simulationRow(data.protos[i]) + ''; + project.content.querySelector('section[data-content="proto"] > div > table > tbody').innerHTML = line; + for (let i = 0; i < data.protos.length; i++) { + let id = data.protos[i].id; + project.content.querySelector('#sync-' + id).addEventListener('click', synchronizeSimulation); + if (project.content.querySelector('#delete-' + id) !== null) + project.content.querySelector('#delete-' + id) + .addEventListener('click', function(event) { deleteProto(event, project); }); + } + const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); + updatePagination('proto', page, total); + document.getElementById('proto-search-input').value = searchString; + } + }); } function listServers(page) { From ff396a7d540c176996ebe18679cb76ebfb568163 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 11:29:23 +0200 Subject: [PATCH 027/459] debug print --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 04d3fae8b..8acf79524 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1186,6 +1186,7 @@ document.addEventListener('DOMContentLoaded', function() { fetch('/ajax/proto/list.php', {method: 'post', body: JSON.stringify({offset: offset, limit: pageLimit, sortBy: sortBy, search: searchString})}) .then(function(response) { + console.log(response.text()) return response.json(); }) .then(function(data) { From 7ecb4ca8502248746215ae8896d0c79521e2f4ec Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 11:31:08 +0200 Subject: [PATCH 028/459] move debug --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 8acf79524..b778c262b 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1186,10 +1186,10 @@ document.addEventListener('DOMContentLoaded', function() { fetch('/ajax/proto/list.php', {method: 'post', body: JSON.stringify({offset: offset, limit: pageLimit, sortBy: sortBy, search: searchString})}) .then(function(response) { - console.log(response.text()) return response.json(); }) .then(function(data) { + console.log(data) if (data.error) ModalDialog.run('Proto listing error', data.error); else { From 40ea88d6bb413ba719c4d971181e7462009d9baf Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 11:36:15 +0200 Subject: [PATCH 029/459] rename --- httpdocs/js/webots-cloud.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index b778c262b..00612111a 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -292,7 +292,7 @@ document.addEventListener('DOMContentLoaded', function() { return row; } - function simulationRow(data) { + function githubRow(data, proto = false) { const admin = project.email ? project.email.endsWith('@cyberbotics.com') : false; const words = data.url.substring(19).split('/'); const dotIndex = data.url.lastIndexOf('/') + 1; @@ -338,10 +338,6 @@ document.addEventListener('DOMContentLoaded', function() { return row; } - function protoRow(data) { - // TODO: - } - function percent(value) { const level = 150 + value; let red, green; @@ -832,7 +828,7 @@ document.addEventListener('DOMContentLoaded', function() { project.load(`/simulation${(page > 1) ? ('?p=' + page) : ''}`); } else { let tr = document.createElement('tr'); - tr.innerHTML = simulationRow(data); + tr.innerHTML = githubRow(data); parent.replaceChild(tr, old); parent.querySelector('#sync-' + data.id).addEventListener('click', synchronizeSimulation); if (parent.querySelector('#delete-' + id) !== null) @@ -1032,7 +1028,7 @@ document.addEventListener('DOMContentLoaded', function() { modal.error(errorMsg); } else { modal.close(); - const tr = '' + simulationRow(data) + ''; + const tr = '' + githubRow(data) + ''; document.querySelector('section[data-content="simulation"] > div > table > tbody').insertAdjacentHTML( 'beforeend', tr); const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); @@ -1096,7 +1092,7 @@ document.addEventListener('DOMContentLoaded', function() { modal.error(errorMsg); } else { modal.close(); - const tr = '' + simulationRow(data) + ''; + const tr = '' + githubRow(data) + ''; document.querySelector('section[data-content="simulation"] > div > table > tbody').insertAdjacentHTML( 'beforeend', tr); const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); @@ -1165,7 +1161,7 @@ document.addEventListener('DOMContentLoaded', function() { document.getElementById('simulation-empty-search').style.display = 'none'; let line = ``; for (let i = 0; i < data.projects.length; i++) // compute the GitHub repo URL from the simulation URL. - line += '' + simulationRow(data.projects[i]) + ''; + line += '' + githubRow(data.projects[i]) + ''; project.content.querySelector('section[data-content="simulation"] > div > table > tbody').innerHTML = line; for (let i = 0; i < data.projects.length; i++) { let id = data.projects[i].id; @@ -1201,7 +1197,7 @@ document.addEventListener('DOMContentLoaded', function() { document.getElementById('proto-empty-search').style.display = 'none'; let line = ``; for (let i = 0; i < data.protos.length; i++) // compute the GitHub repo URL from the simulation URL. - line += '' + simulationRow(data.protos[i]) + ''; + line += '' + githubRow(data.protos[i]) + ''; project.content.querySelector('section[data-content="proto"] > div > table > tbody').innerHTML = line; for (let i = 0; i < data.protos.length; i++) { let id = data.protos[i].id; From d97cbcba3695b746efed6307a4d2aaf53691415a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 11:36:42 +0200 Subject: [PATCH 030/459] remove debug --- httpdocs/js/webots-cloud.js | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 00612111a..7706f39a0 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1185,7 +1185,6 @@ document.addEventListener('DOMContentLoaded', function() { return response.json(); }) .then(function(data) { - console.log(data) if (data.error) ModalDialog.run('Proto listing error', data.error); else { From b32b4df4f0d24b823822209941403fc1d6bdaf30 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 14:02:27 +0200 Subject: [PATCH 031/459] list --- httpdocs/js/webots-cloud.js | 49 +++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 7706f39a0..358759975 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -292,7 +292,7 @@ document.addEventListener('DOMContentLoaded', function() { return row; } - function githubRow(data, proto = false) { + function simulationRow(data) { const admin = project.email ? project.email.endsWith('@cyberbotics.com') : false; const words = data.url.substring(19).split('/'); const dotIndex = data.url.lastIndexOf('/') + 1; @@ -315,7 +315,7 @@ document.addEventListener('DOMContentLoaded', function() { icon = 'question'; const type = ``; const deleteIcon = ``; + title="Delete simulation as administrator">`; const deleteProject = admin ? `` : ``; const versionUrl = `https://github.com/cyberbotics/webots/releases/tag/${data.version}`; let row = `` : ``; + const versionUrl = `https://github.com/cyberbotics/webots/releases/tag/${data.version}`; + let row = ``; + row += `` + + `` + + `` + + `` + + `${deleteProject}`; + return row; + } + function percent(value) { const level = 150 + value; let red, green; @@ -828,7 +863,7 @@ document.addEventListener('DOMContentLoaded', function() { project.load(`/simulation${(page > 1) ? ('?p=' + page) : ''}`); } else { let tr = document.createElement('tr'); - tr.innerHTML = githubRow(data); + tr.innerHTML = simulationRow(data); parent.replaceChild(tr, old); parent.querySelector('#sync-' + data.id).addEventListener('click', synchronizeSimulation); if (parent.querySelector('#delete-' + id) !== null) @@ -1028,7 +1063,7 @@ document.addEventListener('DOMContentLoaded', function() { modal.error(errorMsg); } else { modal.close(); - const tr = '' + githubRow(data) + ''; + const tr = '' + simulationRow(data) + ''; document.querySelector('section[data-content="simulation"] > div > table > tbody').insertAdjacentHTML( 'beforeend', tr); const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); @@ -1092,7 +1127,7 @@ document.addEventListener('DOMContentLoaded', function() { modal.error(errorMsg); } else { modal.close(); - const tr = '' + githubRow(data) + ''; + const tr = '' + simulationRow(data) + ''; document.querySelector('section[data-content="simulation"] > div > table > tbody').insertAdjacentHTML( 'beforeend', tr); const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); @@ -1161,7 +1196,7 @@ document.addEventListener('DOMContentLoaded', function() { document.getElementById('simulation-empty-search').style.display = 'none'; let line = ``; for (let i = 0; i < data.projects.length; i++) // compute the GitHub repo URL from the simulation URL. - line += '' + githubRow(data.projects[i]) + ''; + line += '' + simulationRow(data.projects[i]) + ''; project.content.querySelector('section[data-content="simulation"] > div > table > tbody').innerHTML = line; for (let i = 0; i < data.projects.length; i++) { let id = data.projects[i].id; @@ -1196,7 +1231,7 @@ document.addEventListener('DOMContentLoaded', function() { document.getElementById('proto-empty-search').style.display = 'none'; let line = ``; for (let i = 0; i < data.protos.length; i++) // compute the GitHub repo URL from the simulation URL. - line += '' + githubRow(data.protos[i]) + ''; + line += '' + simulationRow(data.protos[i]) + ''; project.content.querySelector('section[data-content="proto"] > div > table > tbody').innerHTML = line; for (let i = 0; i < data.protos.length; i++) { let id = data.protos[i].id; From 066cc7ead6e4c760e610c65f53532bab4ea0e344 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 14:02:58 +0200 Subject: [PATCH 032/459] proto raw --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 358759975..a329baae6 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -339,6 +339,7 @@ document.addEventListener('DOMContentLoaded', function() { } function protoRow(data) { + console.log("protoRooow") const admin = project.email ? project.email.endsWith('@cyberbotics.com') : false; const words = data.url.substring(19).split('/'); const dotIndex = data.url.lastIndexOf('/') + 1; From 2c5b9e910a6790bcec1876459dec2eee1d84ac75 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 14:03:50 +0200 Subject: [PATCH 033/459] function --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index a329baae6..29dc284a9 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1128,7 +1128,7 @@ document.addEventListener('DOMContentLoaded', function() { modal.error(errorMsg); } else { modal.close(); - const tr = '' + simulationRow(data) + ''; + const tr = '' + protoRow(data) + ''; document.querySelector('section[data-content="simulation"] > div > table > tbody').insertAdjacentHTML( 'beforeend', tr); const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); From a70ab97d92d958cf3832d0917bc5be1e6f852a8d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 14:14:56 +0200 Subject: [PATCH 034/459] function --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 29dc284a9..6b9fed9f4 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1232,7 +1232,7 @@ document.addEventListener('DOMContentLoaded', function() { document.getElementById('proto-empty-search').style.display = 'none'; let line = ``; for (let i = 0; i < data.protos.length; i++) // compute the GitHub repo URL from the simulation URL. - line += '' + simulationRow(data.protos[i]) + ''; + line += '' + protoRow(data.protos[i]) + ''; project.content.querySelector('section[data-content="proto"] > div > table > tbody').innerHTML = line; for (let i = 0; i < data.protos.length; i++) { let id = data.protos[i].id; From 739826680540170a614d1d791218bb986a8b638b Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 14:23:05 +0200 Subject: [PATCH 035/459] name -> title --- database/webots-cloud.sql | 2 +- httpdocs/ajax/proto/create.php | 20 ++++++++++---------- httpdocs/ajax/proto/list.php | 6 +++--- httpdocs/js/webots-cloud.js | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/database/webots-cloud.sql b/database/webots-cloud.sql index 3baa2f0ce..00af1b616 100644 --- a/database/webots-cloud.sql +++ b/database/webots-cloud.sql @@ -86,7 +86,7 @@ CREATE TABLE `proto` ( `id` int(11) NOT NULL, `url` varchar(2048) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, `stars` int(11) NOT NULL, - `name` varchar(256) CHARACTER SET utf8mb4 NOT NULL, + `title` varchar(256) CHARACTER SET utf8mb4 NOT NULL, `description` varchar(2048) CHARACTER SET utf8mb4 NOT NULL, `version` varchar(16) NOT NULL, `branch` varchar(256) CHARACTER SET utf8mb4 NOT NULL, diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 900c460bb..659560899 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -41,9 +41,9 @@ function error($message) { error($check_yaml); } -# retrieve the name and info (description) from the header. +# retrieve the title and info (description) from the header. $info = false; -$name = ''; +$title = ''; $description = ''; $line = strtok($proto_content, "\r\n"); $version = $mysqli->escape_string(substr($line, 10, 6)); // "#VRML_SIM R2022b utf8" -> "R2022b" @@ -59,9 +59,9 @@ function error($message) { } } elseif (substr($line, 0, 6) === 'PROTO ') - $name = trim(substr($line, 6)); - if (!empty($name) && $name[-1] === '[') - $name = trim(substr($name, 0, -1)); + $title = trim(substr($line, 6)); + if (!empty($title) && $title[-1] === '[') + $title = trim(substr($title, 0, -1)); $line = strtok("\r\n"); } @@ -77,10 +77,10 @@ function error($message) { $viewed = ($result && $row) ? $row['viewed'] : 0; $branch = basename(dirname(__FILE__, 4)); if ($id === 0) - $query = "INSERT IGNORE INTO proto(url, viewed, stars, name, description, version, branch) " - ."VALUES(\"$url\", $viewed, $stars, \"$name\", \"$description\", \"$version\", \"$branch\")"; + $query = "INSERT IGNORE INTO proto(url, viewed, stars, title, description, version, branch) " + ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\")"; else - $query = "UPDATE proto SET viewed=$viewed, stars=$stars, name=\"$name\", description=\"$description\", " + $query = "UPDATE proto SET viewed=$viewed, stars=$stars, title=\"$title\", description=\"$description\", " ."version=\"$version\", updated=NOW() " ."WHERE url=\"$url\" AND id=$id"; $mysqli->query($query) or error($mysqli->error); @@ -95,7 +95,7 @@ function error($message) { $search = isset($data->search) ? $data->search : ""; $condition = "branch=\"$branch\""; if ($search != "") - $condition .= " AND LOWER(name) LIKE LOWER('%$search%')"; + $condition .= " AND LOWER(title) LIKE LOWER('%$search%')"; $result = $mysqli->query("SELECT COUNT(*) AS count FROM proto WHERE $condition") or error($mysqli->error); $count = $result->fetch_array(MYSQLI_ASSOC); @@ -106,7 +106,7 @@ function error($message) { $answer['url'] = $url; $answer['viewed'] = $viewed; $answer['stars'] = $stars; -$answer['name'] = $name; +$answer['title'] = $title; $answer['description'] = $description; $answer['version'] = $version; $answer['updated'] = date("Y-m-d H:i:s"); diff --git a/httpdocs/ajax/proto/list.php b/httpdocs/ajax/proto/list.php index cb5de8dc6..ea9d60108 100644 --- a/httpdocs/ajax/proto/list.php +++ b/httpdocs/ajax/proto/list.php @@ -20,7 +20,7 @@ function error($message) { $mysqli->escape_string($data->sortBy) : "viewed-desc"; $parameter = explode("-", $sortBy)[0]; $order = explode("-", $sortBy)[1]; - if ($parameter == "name" || $parameter == "version") { + if ($parameter == "title" || $parameter == "version") { if ($order == "asc") $order = "desc"; else @@ -30,7 +30,7 @@ function error($message) { $condition = "branch=\"$branch\""; if (isset($data->search)) { $searchString = $mysqli->escape_string($data->search); - $condition .= " AND LOWER(name) LIKE LOWER('%$searchString%')"; + $condition .= " AND LOWER(title) LIKE LOWER('%$searchString%')"; } $offset = isset($data->offset) ? intval($data->offset) : 0; $limit = isset($data->limit) ? intval($data->limit) : 10; @@ -41,7 +41,7 @@ function error($message) { settype($row['id'], 'integer'); settype($row['viewed'], 'integer'); settype($row['stars'], 'integer'); - $row['name'] = htmlentities($row['name']); + $row['title'] = htmlentities($row['title']); $row['description'] = htmlentities($row['description']); $row['version'] = htmlentities($row['version']); array_push($protos, $row); diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 6b9fed9f4..d9d2e849c 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -347,7 +347,7 @@ document.addEventListener('DOMContentLoaded', function() { 'raw.githubusercontent.com').replace('/blob', '').replace('.proto', '.jpg'); const defaultThumbnailUrl = document.location.origin + '/images/thumbnail_not_available.jpg'; const repository = `https://github.com/${words[0]}/${words[1]}`; - const name = data.name === '' ? 'anonymous' : data.name; + const title = data.title === '' ? 'anonymous' : data.title; const updated = data.updated.replace(' ', `
    ` ); @@ -356,8 +356,8 @@ document.addEventListener('DOMContentLoaded', function() { const deleteProject = admin ? `
    ` : ``; const versionUrl = `https://github.com/cyberbotics/webots/releases/tag/${data.version}`; let row = `` : ``; - const versionUrl = `https://github.com/cyberbotics/webots/releases/tag/${data.version}`; - let row = ``; - row += `` + - `` + - `` + - `` + - `` + - `${deleteProject}`; - return row; - } - - function protoRow(data) { - console.log("protoRooow") - const admin = project.email ? project.email.endsWith('@cyberbotics.com') : false; - const words = data.url.substring(19).split('/'); - const dotIndex = data.url.lastIndexOf('/') + 1; - const thumbnailUrl = (data.url.slice(0, dotIndex) + '.' + data.url.slice(dotIndex)).replace('github.com', - 'raw.githubusercontent.com').replace('/blob', '').replace('.proto', '.jpg'); + thumbnailUrl.replace('.wbt', '.jpg'); const defaultThumbnailUrl = document.location.origin + '/images/thumbnail_not_available.jpg'; const repository = `https://github.com/${words[0]}/${words[1]}`; const title = data.title === '' ? 'anonymous' : data.title; const updated = data.updated.replace(' ', `
    ` ); + let icon; + let type; + if (proto) { + if (data.type === 'demo') + icon = 'chalkboard-teacher'; + else if (data.type === 'benchmark') + icon = 'award'; + else if (data.type === 'competition') + icon = 'trophy'; + else + icon = 'question'; + type = ``; + } const deleteIcon = ``; + title="Delete row as administrator">`; const deleteProject = admin ? `` : ``; const versionUrl = `https://github.com/cyberbotics/webots/releases/tag/${data.version}`; let row = `` + `` + - `` + - `` + + ``; + if (!proto) + row += ``; + row += `` + `${deleteProject}`; return row; } From 6490f77ad911fc90e988142fcd0b5074b0b1904a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 14:39:58 +0200 Subject: [PATCH 037/459] unify --- httpdocs/js/webots-cloud.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 1f760c92d..3a803c211 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -836,7 +836,7 @@ document.addEventListener('DOMContentLoaded', function() { project.load(`/simulation${(page > 1) ? ('?p=' + page) : ''}`); } else { let tr = document.createElement('tr'); - tr.innerHTML = simulationRow(data); + tr.innerHTML = githubRow(data); parent.replaceChild(tr, old); parent.querySelector('#sync-' + data.id).addEventListener('click', synchronizeSimulation); if (parent.querySelector('#delete-' + id) !== null) @@ -1036,7 +1036,7 @@ document.addEventListener('DOMContentLoaded', function() { modal.error(errorMsg); } else { modal.close(); - const tr = '' + simulationRow(data) + ''; + const tr = '' + githubRow(data) + ''; document.querySelector('section[data-content="simulation"] > div > table > tbody').insertAdjacentHTML( 'beforeend', tr); const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); @@ -1100,7 +1100,7 @@ document.addEventListener('DOMContentLoaded', function() { modal.error(errorMsg); } else { modal.close(); - const tr = '' + protoRow(data) + ''; + const tr = '' + githubRow(data) + ''; document.querySelector('section[data-content="simulation"] > div > table > tbody').insertAdjacentHTML( 'beforeend', tr); const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); @@ -1169,7 +1169,7 @@ document.addEventListener('DOMContentLoaded', function() { document.getElementById('simulation-empty-search').style.display = 'none'; let line = ``; for (let i = 0; i < data.projects.length; i++) // compute the GitHub repo URL from the simulation URL. - line += '' + simulationRow(data.projects[i]) + ''; + line += '' + githubRow(data.projects[i]) + ''; project.content.querySelector('section[data-content="simulation"] > div > table > tbody').innerHTML = line; for (let i = 0; i < data.projects.length; i++) { let id = data.projects[i].id; @@ -1204,7 +1204,7 @@ document.addEventListener('DOMContentLoaded', function() { document.getElementById('proto-empty-search').style.display = 'none'; let line = ``; for (let i = 0; i < data.protos.length; i++) // compute the GitHub repo URL from the simulation URL. - line += '' + protoRow(data.protos[i]) + ''; + line += '' + githubRow(data.protos[i]) + ''; project.content.querySelector('section[data-content="proto"] > div > table > tbody').innerHTML = line; for (let i = 0; i < data.protos.length; i++) { let id = data.protos[i].id; From f6a9cb03f2ca6974f5f307142e95cd97ac84a130 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 14:41:58 +0200 Subject: [PATCH 038/459] debug --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 3a803c211..e02955b95 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -805,6 +805,7 @@ document.addEventListener('DOMContentLoaded', function() { //TODO do it for proto as well function synchronizeSimulation(event) { + console.log(event) const searchString = getSearch('simulation'); const id = event.target.id.substring(5); event.target.classList.add('fa-spin'); From 24aadf03b7ef0012aaf54064cb88e28a0ee54361 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 15:08:39 +0200 Subject: [PATCH 039/459] sync --- httpdocs/js/webots-cloud.js | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index e02955b95..3e5bc7714 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -804,13 +804,23 @@ document.addEventListener('DOMContentLoaded', function() { } //TODO do it for proto as well - function synchronizeSimulation(event) { - console.log(event) - const searchString = getSearch('simulation'); + function synchronizeSimulation(event, proto) { + let searchString; + let script; + let type; + if (proto) { + searchString = getSearch('proto'); + script = 'ajax/proto/create.php' + type = 'proto'; + } else { + searchString = getSearch('simulation'); + script = 'ajax/project/create.php' + type = 'simulation'; + } const id = event.target.id.substring(5); event.target.classList.add('fa-spin'); const url = event.target.getAttribute('data-url'); - fetch('ajax/project/create.php', {method: 'post', body: JSON.stringify({url: url, id: id, search: searchString})}) + fetch(script, {method: 'post', body: JSON.stringify({url: url, id: id, search: searchString})}) .then(function(response) { return response.json(); }) @@ -834,18 +844,24 @@ document.addEventListener('DOMContentLoaded', function() { dialog.close(); }); event.target.classList.remove('fa-spin'); - project.load(`/simulation${(page > 1) ? ('?p=' + page) : ''}`); + project.load(`/` + type + `{(page > 1) ? ('?p=' + page) : ''}`); } else { let tr = document.createElement('tr'); tr.innerHTML = githubRow(data); parent.replaceChild(tr, old); parent.querySelector('#sync-' + data.id).addEventListener('click', synchronizeSimulation); - if (parent.querySelector('#delete-' + id) !== null) - parent.querySelector('#delete-' + id).addEventListener('click', - function(event) { deleteSimulation(event, project); }); + if (parent.querySelector('#delete-' + id) !== null) { + if (proto) + parent.querySelector('#delete-' + id).addEventListener('click', + function(event) { deleteProto(event, project); }); + else + parent.querySelector('#delete-' + id).addEventListener('click', + function(event) { deleteSimulation(event, project); }); + } + event.target.classList.remove('fa-spin'); const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); - updatePagination('simulation', page, total); + updatePagination(type, page, total); } }); } From 71d13a044e681eb98965b538248b8fbfba1f53d8 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 15:18:01 +0200 Subject: [PATCH 040/459] sync protos --- httpdocs/js/webots-cloud.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 3e5bc7714..9f4df4842 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -803,8 +803,7 @@ document.addEventListener('DOMContentLoaded', function() { } } - //TODO do it for proto as well - function synchronizeSimulation(event, proto) { + function synchronizeGithub(event, proto) { let searchString; let script; let type; @@ -849,7 +848,7 @@ document.addEventListener('DOMContentLoaded', function() { let tr = document.createElement('tr'); tr.innerHTML = githubRow(data); parent.replaceChild(tr, old); - parent.querySelector('#sync-' + data.id).addEventListener('click', synchronizeSimulation); + parent.querySelector('#sync-' + data.id).addEventListener('click', _ => synchronizeGithub(_, proto)); if (parent.querySelector('#delete-' + id) !== null) { if (proto) parent.querySelector('#delete-' + id).addEventListener('click', @@ -1190,7 +1189,7 @@ document.addEventListener('DOMContentLoaded', function() { project.content.querySelector('section[data-content="simulation"] > div > table > tbody').innerHTML = line; for (let i = 0; i < data.projects.length; i++) { let id = data.projects[i].id; - project.content.querySelector('#sync-' + id).addEventListener('click', synchronizeSimulation); + project.content.querySelector('#sync-' + id).addEventListener('click', synchronizeGithub); if (project.content.querySelector('#delete-' + id) !== null) project.content.querySelector('#delete-' + id) .addEventListener('click', function(event) { deleteSimulation(event, project); }); @@ -1225,7 +1224,7 @@ document.addEventListener('DOMContentLoaded', function() { project.content.querySelector('section[data-content="proto"] > div > table > tbody').innerHTML = line; for (let i = 0; i < data.protos.length; i++) { let id = data.protos[i].id; - project.content.querySelector('#sync-' + id).addEventListener('click', synchronizeSimulation); + project.content.querySelector('#sync-' + id).addEventListener('click', _ => synchronizeGithub(_, true)); if (project.content.querySelector('#delete-' + id) !== null) project.content.querySelector('#delete-' + id) .addEventListener('click', function(event) { deleteProto(event, project); }); From e29c08488fa32e632bd89168d40deba38b58d3f4 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 15:22:57 +0200 Subject: [PATCH 041/459] typo --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 9f4df4842..158b0e87a 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -310,7 +310,7 @@ document.addEventListener('DOMContentLoaded', function() { ); let icon; let type; - if (proto) { + if (!proto) { if (data.type === 'demo') icon = 'chalkboard-teacher'; else if (data.type === 'benchmark') From ba6f1ccc6a1b8704d6e0f69b032f977ca92298be Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 15:23:44 +0200 Subject: [PATCH 042/459] debug --- httpdocs/js/webots-cloud.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 158b0e87a..63f87a66c 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -339,8 +339,10 @@ document.addEventListener('DOMContentLoaded', function() { `` + ``; - if (!proto) + if (!proto) { row += ``; + console.log("euh") + } row += `` + `${deleteProject}`; return row; From 056b40e4a1509135518f2e1237686046a404d89a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 15:24:49 +0200 Subject: [PATCH 043/459] synch proto --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 63f87a66c..62c68d9f5 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -848,7 +848,7 @@ document.addEventListener('DOMContentLoaded', function() { project.load(`/` + type + `{(page > 1) ? ('?p=' + page) : ''}`); } else { let tr = document.createElement('tr'); - tr.innerHTML = githubRow(data); + tr.innerHTML = githubRow(data, proto); parent.replaceChild(tr, old); parent.querySelector('#sync-' + data.id).addEventListener('click', _ => synchronizeGithub(_, proto)); if (parent.querySelector('#delete-' + id) !== null) { From ea175a379f76b70e5e428a96b7c7c79bb0627040 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 15:25:53 +0200 Subject: [PATCH 044/459] specify if proto --- httpdocs/js/webots-cloud.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 62c68d9f5..94e041faa 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1118,7 +1118,7 @@ document.addEventListener('DOMContentLoaded', function() { modal.error(errorMsg); } else { modal.close(); - const tr = '' + githubRow(data) + ''; + const tr = '' + githubRow(data, true) + ''; document.querySelector('section[data-content="simulation"] > div > table > tbody').insertAdjacentHTML( 'beforeend', tr); const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); @@ -1222,7 +1222,7 @@ document.addEventListener('DOMContentLoaded', function() { document.getElementById('proto-empty-search').style.display = 'none'; let line = ``; for (let i = 0; i < data.protos.length; i++) // compute the GitHub repo URL from the simulation URL. - line += '' + githubRow(data.protos[i]) + ''; + line += '' + githubRow(data.protos[i], true) + ''; project.content.querySelector('section[data-content="proto"] > div > table > tbody').innerHTML = line; for (let i = 0; i < data.protos.length; i++) { let id = data.protos[i].id; From d0819a404d15230b2da181c188940b2703e9ba2c Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 15:31:54 +0200 Subject: [PATCH 045/459] delete --- httpdocs/ajax/proto/delete.php | 21 +++++++++++++++++++++ httpdocs/js/webots-cloud.js | 20 +++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 httpdocs/ajax/proto/delete.php diff --git a/httpdocs/ajax/proto/delete.php b/httpdocs/ajax/proto/delete.php new file mode 100644 index 000000000..58c2af556 --- /dev/null +++ b/httpdocs/ajax/proto/delete.php @@ -0,0 +1,21 @@ +connect_errno) + error("Can't connect to MySQL database: $mysqli->connect_error"); +$mysqli->set_charset('utf8'); +$user = isset($data->user) ? intval($data->user) : 0; +$password = isset($data->password) ? $mysqli->escape_string($data->password) : ''; +$id = isset($data->id) ? intval($data->id) : 0; +$query = "DELETE FROM proto WHERE id=$id AND EXISTS (SELECT * FROM user WHERE id=$user AND password='$password' AND email LIKE '%@cyberbotics.com')"; +$mysqli->query($query) or error($mysqli->error); +if ($mysqli->affected_rows === 0) + error("Could not delete proto"); +die('{"status":1}'); +?> diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 94e041faa..d8b64d310 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1323,7 +1323,25 @@ document.addEventListener('DOMContentLoaded', function() { } function deleteProto(event, project) { - // TODO + const id = event.target.id.substring(7); + let dialog = ModalDialog.run(`Really delete proto?`, '

    There is no way to recover deleted data.

    ', 'Cancel', + `Delete proto`, 'is-danger'); + dialog.querySelector('form').addEventListener('submit', function(event) { + event.preventDefault(); + dialog.querySelector('button[type="submit"]').classList.add('is-loading'); + fetch('ajax/proto/delete.php', {method: 'post', + body: JSON.stringify({user: project.id, password: project.password, id: id})}) + .then(function(response) { + return response.json(); + }) + .then(function(data) { + dialog.close(); + if (data.error) + ModalDialog.run(`Proto deletion error`, data.error); + else if (data.status === 1) + project.load(`/proto${(page > 1) ? ('?p=' + page) : ''}`); + }); + }); } } From a2512ba7545e06b2274776eef5db8febd063100a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 15:32:58 +0200 Subject: [PATCH 046/459] cleanup --- httpdocs/js/webots-cloud.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index d8b64d310..a6db26e3f 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -339,10 +339,8 @@ document.addEventListener('DOMContentLoaded', function() { `
    ` + ``; - if (!proto) { + if (!proto) row += ``; - console.log("euh") - } row += `` + `${deleteProject}`; return row; From 46de04938e5803f00d9c9d894cd4469a269ce03e Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 15:48:25 +0200 Subject: [PATCH 047/459] fix thumbnail --- httpdocs/js/webots-cloud.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index a6db26e3f..d9fc6fc70 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -299,9 +299,9 @@ document.addEventListener('DOMContentLoaded', function() { let thumbnailUrl = (data.url.slice(0, dotIndex) + '.' + data.url.slice(dotIndex)).replace('github.com', 'raw.githubusercontent.com').replace('/blob', ''); if (proto) - thumbnailUrl.replace('.proto', '.jpg'); + thumbnailUrl = thumbnailUrl.replace('.proto', '.jpg'); else - thumbnailUrl.replace('.wbt', '.jpg'); + thumbnailUrl = thumbnailUrl.replace('.wbt', '.jpg'); const defaultThumbnailUrl = document.location.origin + '/images/thumbnail_not_available.jpg'; const repository = `https://github.com/${words[0]}/${words[1]}`; const title = data.title === '' ? 'anonymous' : data.title; From ecf7d5195fa7cbc16265c0b18f0fca016f97850b Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 10 Oct 2022 08:17:22 +0200 Subject: [PATCH 048/459] proto --- httpdocs/js/project.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 3cb3d882a..c67690f7e 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -141,6 +141,8 @@ export default class Project extends User { else Project.webotsView.loadScene(`${reference}/scene.x3d`, this._isMobileDevice(), `${reference}/thumbnail.jpg`); resolve(); + } else if (url.endWith('.proto')) { + console.log("proto") } else { that.setupWebotsView('run'); let dotIndex = url.lastIndexOf('/') + 1; From 3c794bc53b0ba960968b43bfa431d9b4375261dc Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 10 Oct 2022 08:18:14 +0200 Subject: [PATCH 049/459] typo --- httpdocs/js/project.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index c67690f7e..81b1749f0 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -141,7 +141,7 @@ export default class Project extends User { else Project.webotsView.loadScene(`${reference}/scene.x3d`, this._isMobileDevice(), `${reference}/thumbnail.jpg`); resolve(); - } else if (url.endWith('.proto')) { + } else if (url.endsWith('.proto')) { console.log("proto") } else { that.setupWebotsView('run'); From 8503f993c94c0ae1e4bb77931d3e2ec116b6e330 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 10 Oct 2022 08:19:18 +0200 Subject: [PATCH 050/459] debug print --- httpdocs/js/project.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 81b1749f0..ba1698424 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -144,6 +144,7 @@ export default class Project extends User { } else if (url.endsWith('.proto')) { console.log("proto") } else { + console.log(url) that.setupWebotsView('run'); let dotIndex = url.lastIndexOf('/') + 1; let thumbnailUrl = (url.slice(0, dotIndex) + '.' + url.slice(dotIndex)) From c8e483c6106c48706bc6135508e3a70ce7a49181 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 10 Oct 2022 08:20:43 +0200 Subject: [PATCH 051/459] debug print --- httpdocs/js/project.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index ba1698424..231c1b3fb 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -133,6 +133,7 @@ export default class Project extends User { script.src = src; script.onload = () => { if (data) { + console.log(data) reference = 'storage' + data.url.substring(data.url.lastIndexOf('/')); that.setupWebotsView(data.duration > 0 ? 'animation' : 'scene', data); if (data.duration > 0) @@ -144,7 +145,6 @@ export default class Project extends User { } else if (url.endsWith('.proto')) { console.log("proto") } else { - console.log(url) that.setupWebotsView('run'); let dotIndex = url.lastIndexOf('/') + 1; let thumbnailUrl = (url.slice(0, dotIndex) + '.' + url.slice(dotIndex)) From a3773fd2022dff73d6b1d4c9cc9f50332965849a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 10 Oct 2022 08:32:16 +0200 Subject: [PATCH 052/459] get proto branch --- httpdocs/js/project.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 231c1b3fb..7dab44d4d 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -109,8 +109,8 @@ export default class Project extends User { const url = this.findGetParameter('url'); const mode = this.findGetParameter('mode'); if (!version || version === 'undefined') { - if (window.location.hostname === 'testing.webots.cloud') - version = 'testing'; + if (window.location.hostname === 'proto.webots.cloud') + version = 'proto'; else version = data ? data.version : this.findGetParameter('version'); } @@ -133,7 +133,6 @@ export default class Project extends User { script.src = src; script.onload = () => { if (data) { - console.log(data) reference = 'storage' + data.url.substring(data.url.lastIndexOf('/')); that.setupWebotsView(data.duration > 0 ? 'animation' : 'scene', data); if (data.duration > 0) @@ -143,7 +142,10 @@ export default class Project extends User { Project.webotsView.loadScene(`${reference}/scene.x3d`, this._isMobileDevice(), `${reference}/thumbnail.jpg`); resolve(); } else if (url.endsWith('.proto')) { - console.log("proto") + that.setupWebotsView('proto'); + const thumbnailUrl = url.replace('.proto', '.jpg'); + Project.webotsView.loadProto(url, undefined, thumbnailUrl); + resolve(); } else { that.setupWebotsView('run'); let dotIndex = url.lastIndexOf('/') + 1; @@ -170,6 +172,11 @@ export default class Project extends User { this._isMobileDevice(), `${reference}/thumbnail.jpg`); else Project.webotsView.loadScene(`${reference}/scene.x3d`, this._isMobileDevice(), `${reference}/thumbnail.jpg`); + } else if (url.endsWith('.proto')) { + that.setupWebotsView('proto'); + const thumbnailUrl = url.replace('.proto', '.jpg'); + Project.webotsView.loadProto(url, undefined, thumbnailUrl); + resolve(); } else { that.setupWebotsView('run'); let dotIndex = url.lastIndexOf('/') + 1; From 2a826655d35f13b3d767d66dfa6bfb90a2753621 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 10 Oct 2022 08:34:43 +0200 Subject: [PATCH 053/459] debug --- httpdocs/js/project.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 7dab44d4d..64cf5c579 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -157,7 +157,8 @@ export default class Project extends User { resolve(); } }; - script.onerror = () => { + script.onerror = _ => { + console.log(_) console.warn( 'Could not find Webots version, reloading with R2022b instead. This could cause some unwanted behaviour.'); script.remove(); From 15a970cb02e92a2f2cf03bfbba6ab26bd07b4163 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 10 Oct 2022 08:37:11 +0200 Subject: [PATCH 054/459] resolve --- httpdocs/js/project.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 64cf5c579..6b286b7da 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -145,7 +145,6 @@ export default class Project extends User { that.setupWebotsView('proto'); const thumbnailUrl = url.replace('.proto', '.jpg'); Project.webotsView.loadProto(url, undefined, thumbnailUrl); - resolve(); } else { that.setupWebotsView('run'); let dotIndex = url.lastIndexOf('/') + 1; @@ -158,7 +157,6 @@ export default class Project extends User { } }; script.onerror = _ => { - console.log(_) console.warn( 'Could not find Webots version, reloading with R2022b instead. This could cause some unwanted behaviour.'); script.remove(); From bed941d07c5e2fe55c0f5be8033b9a7c72bd473b Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 10 Oct 2022 08:51:28 +0200 Subject: [PATCH 055/459] proto --- httpdocs/js/project.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 6b286b7da..d3b918840 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -142,9 +142,10 @@ export default class Project extends User { Project.webotsView.loadScene(`${reference}/scene.x3d`, this._isMobileDevice(), `${reference}/thumbnail.jpg`); resolve(); } else if (url.endsWith('.proto')) { - that.setupWebotsView('proto'); + console.log("proto") + // that.setupWebotsView('proto'); const thumbnailUrl = url.replace('.proto', '.jpg'); - Project.webotsView.loadProto(url, undefined, thumbnailUrl); + // Project.webotsView.loadProto(url, undefined, thumbnailUrl); } else { that.setupWebotsView('run'); let dotIndex = url.lastIndexOf('/') + 1; From 5a6f1d3fb17c2a53842045ef49bccd687e518d26 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 10 Oct 2022 08:53:05 +0200 Subject: [PATCH 056/459] resolve --- httpdocs/js/project.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index d3b918840..ac057f8a3 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -144,8 +144,9 @@ export default class Project extends User { } else if (url.endsWith('.proto')) { console.log("proto") // that.setupWebotsView('proto'); - const thumbnailUrl = url.replace('.proto', '.jpg'); + // const thumbnailUrl = url.replace('.proto', '.jpg'); // Project.webotsView.loadProto(url, undefined, thumbnailUrl); + resolve(); } else { that.setupWebotsView('run'); let dotIndex = url.lastIndexOf('/') + 1; From f806b4ab5d11ecfe344aa0bd852b418662c11de9 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 10 Oct 2022 08:54:15 +0200 Subject: [PATCH 057/459] debug --- httpdocs/js/project.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index ac057f8a3..70c341e19 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -158,12 +158,12 @@ export default class Project extends User { resolve(); } }; - script.onerror = _ => { - console.warn( - 'Could not find Webots version, reloading with R2022b instead. This could cause some unwanted behaviour.'); - script.remove(); - that.runWebotsView(data, 'R2022b'); // if release not found, default to R2022b - }; + // script.onerror = _ => { + // console.warn( + // 'Could not find Webots version, reloading with R2022b instead. This could cause some unwanted behaviour.'); + // script.remove(); + // that.runWebotsView(data, 'R2022b'); // if release not found, default to R2022b + // }; document.body.appendChild(script); } else if (data) { reference = 'storage' + data.url.substring(data.url.lastIndexOf('/')); From 667521f547e62b0d6a2b92feb95963379c46c4f8 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 10 Oct 2022 08:58:44 +0200 Subject: [PATCH 058/459] proto --- httpdocs/js/project.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 70c341e19..cab7f4929 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -174,6 +174,7 @@ export default class Project extends User { else Project.webotsView.loadScene(`${reference}/scene.x3d`, this._isMobileDevice(), `${reference}/thumbnail.jpg`); } else if (url.endsWith('.proto')) { + console.log("proto") that.setupWebotsView('proto'); const thumbnailUrl = url.replace('.proto', '.jpg'); Project.webotsView.loadProto(url, undefined, thumbnailUrl); From b4d7a06faa2befeba25029891d52f64f8144a474 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 10 Oct 2022 09:01:29 +0200 Subject: [PATCH 059/459] version --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 58d3ed95c..7efd1f96e 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -327,7 +327,7 @@ document.addEventListener('DOMContentLoaded', function() { const versionUrl = `https://github.com/cyberbotics/webots/releases/tag/${data.version}`; let row = ` - ` : ``; const versionUrl = `https://github.com/cyberbotics/webots/releases/tag/${data.version}`; - const second_column = (data.type === 'competition') ? data.participants : data.viewed; + const secondColumn = (data.type === 'competition') ? data.participants : data.viewed; let row = ` - +`; const link = participant.private ? `${participant.name}` : `${participant.name}`; - const title = (metric == 'ranking') - ? `Game won by ${upper_name} over ${participant.name}` + const title = (metric === 'ranking') + ? `Game won by ${upperName} over ${participant.name}` : `Performance of ${participant.name}`; - upper_name = participant.name; + upperName = participant.name; const button = (metric === 'ranking' && ranking === 1) ? `🏆` : `
    ${deleteIcon} ${data.viewed}`; @@ -338,6 +338,41 @@ document.addEventListener('DOMContentLoaded', function() { return row; } + function protoRow(data) { + const admin = project.email ? project.email.endsWith('@cyberbotics.com') : false; + const words = data.url.substring(19).split('/'); + const dotIndex = data.url.lastIndexOf('/') + 1; + const thumbnailUrl = (data.url.slice(0, dotIndex) + '.' + data.url.slice(dotIndex)).replace('github.com', + 'raw.githubusercontent.com').replace('/blob', '').replace('.proto', '.jpg'); + const defaultThumbnailUrl = document.location.origin + '/images/thumbnail_not_available.jpg'; + const repository = `https://github.com/${words[0]}/${words[1]}`; + const name = data.name === '' ? 'anonymous' : data.name; + const updated = data.updated.replace(' ', + `
    ` + ); + const deleteIcon = ``; + const deleteProject = admin ? `
    ${deleteIcon} ${data.viewed}`; + row += ` + ${name} +
    +
    + +

    ${data.description}

    +
    +
    +
    ${words[3]} ${data.stars}${data.version}${updated}
    ${deleteIcon} ${data.viewed}`; - row += ` - ${name} + row += ` + ${title}
    From 5df51c80d24e48fc61392ec9d5ea4c387edfdf0a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Thu, 29 Sep 2022 14:33:58 +0200 Subject: [PATCH 036/459] synchronize --- httpdocs/js/webots-cloud.js | 76 ++++++++++++------------------------- 1 file changed, 24 insertions(+), 52 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index d9d2e849c..1f760c92d 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -292,67 +292,37 @@ document.addEventListener('DOMContentLoaded', function() { return row; } - function simulationRow(data) { + function githubRow(data, proto) { const admin = project.email ? project.email.endsWith('@cyberbotics.com') : false; const words = data.url.substring(19).split('/'); const dotIndex = data.url.lastIndexOf('/') + 1; - const thumbnailUrl = (data.url.slice(0, dotIndex) + '.' + data.url.slice(dotIndex)).replace('github.com', - 'raw.githubusercontent.com').replace('/blob', '').replace('.wbt', '.jpg'); - const defaultThumbnailUrl = document.location.origin + '/images/thumbnail_not_available.jpg'; - const repository = `https://github.com/${words[0]}/${words[1]}`; - const title = data.title === '' ? 'anonymous' : data.title; - const updated = data.updated.replace(' ', - `
    ` - ); - let icon; - if (data.type === 'demo') - icon = 'chalkboard-teacher'; - else if (data.type === 'benchmark') - icon = 'award'; - else if (data.type === 'competition') - icon = 'trophy'; + let thumbnailUrl = (data.url.slice(0, dotIndex) + '.' + data.url.slice(dotIndex)).replace('github.com', + 'raw.githubusercontent.com').replace('/blob', ''); + if (proto) + thumbnailUrl.replace('.proto', '.jpg'); else - icon = 'question'; - const type = ``; - const deleteIcon = ``; - const deleteProject = admin ? `
    ${deleteIcon} ${data.viewed}`; - row += ` - ${title} -
    -
    - -

    ${data.description}

    -
    -
    -
    ${words[3]} ${data.stars}${data.version}${type}${updated}${deleteIcon} ${data.viewed}`; @@ -368,8 +338,10 @@ document.addEventListener('DOMContentLoaded', function() { row += `${words[3]} ${data.stars}${data.version}${updated}${data.version}${type}${updated}
    ${data.stars}${data.version}${type}${updated}
    ${data.stars}${data.version}${type}${updated} ${data.viewed}`; row += ` - ${title} + ${title}
    From b958aa33ab6a2a91186c0b988075a17257e827e4 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 10 Oct 2022 10:44:51 +0200 Subject: [PATCH 060/459] proto --- httpdocs/js/project.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index cab7f4929..ce64f37a9 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -143,9 +143,9 @@ export default class Project extends User { resolve(); } else if (url.endsWith('.proto')) { console.log("proto") - // that.setupWebotsView('proto'); - // const thumbnailUrl = url.replace('.proto', '.jpg'); - // Project.webotsView.loadProto(url, undefined, thumbnailUrl); + that.setupWebotsView('proto'); + const thumbnailUrl = url.replace('.proto', '.jpg'); + Project.webotsView.loadProto(url, undefined, thumbnailUrl); resolve(); } else { that.setupWebotsView('run'); From d8a88c104ee9d558d11ccf655778a9815cbeb06a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 10 Oct 2022 14:15:08 +0200 Subject: [PATCH 061/459] uncomment --- httpdocs/js/project.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index ce64f37a9..29a6ce351 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -142,7 +142,6 @@ export default class Project extends User { Project.webotsView.loadScene(`${reference}/scene.x3d`, this._isMobileDevice(), `${reference}/thumbnail.jpg`); resolve(); } else if (url.endsWith('.proto')) { - console.log("proto") that.setupWebotsView('proto'); const thumbnailUrl = url.replace('.proto', '.jpg'); Project.webotsView.loadProto(url, undefined, thumbnailUrl); @@ -158,12 +157,12 @@ export default class Project extends User { resolve(); } }; - // script.onerror = _ => { - // console.warn( - // 'Could not find Webots version, reloading with R2022b instead. This could cause some unwanted behaviour.'); - // script.remove(); - // that.runWebotsView(data, 'R2022b'); // if release not found, default to R2022b - // }; + script.onerror = _ => { + console.warn( + 'Could not find Webots version, reloading with R2022b instead. This could cause some unwanted behaviour.'); + script.remove(); + that.runWebotsView(data, 'R2022b'); // if release not found, default to R2022b + }; document.body.appendChild(script); } else if (data) { reference = 'storage' + data.url.substring(data.url.lastIndexOf('/')); @@ -174,7 +173,6 @@ export default class Project extends User { else Project.webotsView.loadScene(`${reference}/scene.x3d`, this._isMobileDevice(), `${reference}/thumbnail.jpg`); } else if (url.endsWith('.proto')) { - console.log("proto") that.setupWebotsView('proto'); const thumbnailUrl = url.replace('.proto', '.jpg'); Project.webotsView.loadProto(url, undefined, thumbnailUrl); From 42d19326ab310a9d5cb973900ba9b274375a5031 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 10 Oct 2022 14:29:51 +0200 Subject: [PATCH 062/459] load from raw.githubusercontent --- httpdocs/js/project.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 29a6ce351..3f3497a14 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -143,8 +143,11 @@ export default class Project extends User { resolve(); } else if (url.endsWith('.proto')) { that.setupWebotsView('proto'); - const thumbnailUrl = url.replace('.proto', '.jpg'); - Project.webotsView.loadProto(url, undefined, thumbnailUrl); + let urlArray = url.substring(19).split('/'); + urlArray.splice(2, 1); + let rawGithubUrl = 'https://raw.githubusercontent.com/' + urlArray.join('/'); + const thumbnailUrl = rawGithubUrl.replace('.proto', '.jpg'); + Project.webotsView.loadProto(rawGithubUrl, undefined, thumbnailUrl); resolve(); } else { that.setupWebotsView('run'); @@ -174,8 +177,11 @@ export default class Project extends User { Project.webotsView.loadScene(`${reference}/scene.x3d`, this._isMobileDevice(), `${reference}/thumbnail.jpg`); } else if (url.endsWith('.proto')) { that.setupWebotsView('proto'); - const thumbnailUrl = url.replace('.proto', '.jpg'); - Project.webotsView.loadProto(url, undefined, thumbnailUrl); + let urlArray = url.substring(19).split('/'); + urlArray.splice(2, 1); + let rawGithubUrl = 'https://raw.githubusercontent.com/' + urlArray.join('/'); + const thumbnailUrl = rawGithubUrl.replace('.proto', '.jpg'); + Project.webotsView.loadProto(rawGithubUrl, undefined, thumbnailUrl); resolve(); } else { that.setupWebotsView('run'); From 7c1c3113b1b0fca515369ff89e39c4575c14501a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 25 Oct 2022 10:29:42 +0200 Subject: [PATCH 063/459] debug print --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 7efd1f96e..90c622cea 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1203,6 +1203,7 @@ document.addEventListener('DOMContentLoaded', function() { fetch('/ajax/proto/list.php', {method: 'post', body: JSON.stringify({offset: offset, limit: pageLimit, sortBy: sortBy, search: searchString})}) .then(function(response) { + console.log(response.text()) return response.json(); }) .then(function(data) { From cb189258b1bdfc8af740c69c0efce9974012a63c Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 25 Oct 2022 10:33:41 +0200 Subject: [PATCH 064/459] rename --- httpdocs/js/webots-cloud.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 90c622cea..bcb0bfdf7 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -585,11 +585,11 @@ document.addEventListener('DOMContentLoaded', function() { -
    Title + Branch/Tag Date: Tue, 25 Oct 2022 10:34:25 +0200 Subject: [PATCH 065/459] remove debug print --- httpdocs/js/webots-cloud.js | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index bcb0bfdf7..f6fc88b0a 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1203,7 +1203,6 @@ document.addEventListener('DOMContentLoaded', function() { fetch('/ajax/proto/list.php', {method: 'post', body: JSON.stringify({offset: offset, limit: pageLimit, sortBy: sortBy, search: searchString})}) .then(function(response) { - console.log(response.text()) return response.json(); }) .then(function(data) { From d249b209693847508c3e57a5c585404aac71e2f1 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 25 Oct 2022 10:50:59 +0200 Subject: [PATCH 066/459] debug log --- httpdocs/js/project.js | 2 ++ httpdocs/js/webots-cloud.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 3f3497a14..ca525cd58 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -104,6 +104,7 @@ export default class Project extends User { document.querySelector('#main-container').classList.add('webotsView'); } runWebotsView(data, version) { + console.log(data) let that = this; let reference; const url = this.findGetParameter('url'); @@ -212,6 +213,7 @@ export default class Project extends User { }); } _updateSimulationViewCount(url) { + console.log("update view count " + url) fetch('/ajax/project/list.php', {method: 'post', body: JSON.stringify({url: url})}) .then(function(response) { return response.json(); diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index f6fc88b0a..31d83ec5a 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -802,11 +802,11 @@ document.addEventListener('DOMContentLoaded', function() { let type; if (proto) { searchString = getSearch('proto'); - script = 'ajax/proto/create.php' + script = 'ajax/proto/create.php'; type = 'proto'; } else { searchString = getSearch('simulation'); - script = 'ajax/project/create.php' + script = 'ajax/project/create.php'; type = 'simulation'; } const id = event.target.id.substring(5); From b7c0e4cdbe874de7ca1864948bef1aa9b4969b76 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 25 Oct 2022 10:53:48 +0200 Subject: [PATCH 067/459] link toward proto views --- httpdocs/js/project.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index ca525cd58..caf0dbb9e 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -104,7 +104,6 @@ export default class Project extends User { document.querySelector('#main-container').classList.add('webotsView'); } runWebotsView(data, version) { - console.log(data) let that = this; let reference; const url = this.findGetParameter('url'); @@ -118,7 +117,7 @@ export default class Project extends User { const src = 'https://cyberbotics.com/wwi/' + version + '/WebotsView.js'; if (!data) - that._updateSimulationViewCount(url); + that._updateProtoAndSimulationViewCount(url); let promise = new Promise((resolve, reject) => { let script = document.getElementById('webots-view-version'); @@ -212,9 +211,9 @@ export default class Project extends User { } }); } - _updateSimulationViewCount(url) { - console.log("update view count " + url) - fetch('/ajax/project/list.php', {method: 'post', body: JSON.stringify({url: url})}) + _updateProtoAndSimulationViewCount(url) { + let phpFile = url.endsWith('.wbt') ? '/ajax/project/list.php' : '/ajax/proto/list.php'; + fetch(phpFile, {method: 'post', body: JSON.stringify({url: url})}) .then(function(response) { return response.json(); }) From 933b92e968af99952688891e36e1f62f05eca046 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 9 Jan 2023 15:00:45 +0100 Subject: [PATCH 068/459] fix typo --- httpdocs/js/webots-cloud.js | 40 ++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index d3a463969..5d45436df 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -205,7 +205,6 @@ document.addEventListener('DOMContentLoaded', function () { if (project.email && project.email.endsWith('@cyberbotics.com')) { project.content.querySelector('section[data-content="simulation"] > div > table > thead > tr') .appendChild(document.createElement('th')); - } project.content.querySelector('section[data-content="proto"] > div > table > thead > tr') .appendChild(document.createElement('th')); @@ -881,7 +880,7 @@ document.addEventListener('DOMContentLoaded', function () { updateSearchIcon('animation'); updateSearchIcon('simulation'); updateSearchIcon('competition'); - updaeSearchIcon('proto'); + updateSearchIcon('proto'); } } @@ -1447,24 +1446,25 @@ document.addEventListener('DOMContentLoaded', function () { }); }); } - function whatIsCompetitionPopUp() { - let content = {}; - content.innerHTML = - `
    - A competition is a simulation scenario which proposes a challenge. - A robot has to address a problem and its behavior is evaluated against a performance metric. -

    - The performance metric may be either absolute or relative: -

    - An absolute performance metric is a scalar value measuring the performance of a robot on a given task. - For example, the time spent running a 100 meters race is an absolute performance metric. -

    - A relative performance metric is a ranking of the performance of a robots against others. - For example, the tennis ATP ranking is a relative performance metric. -

    - To create your own competition, follow the instructions on this repository. -
    `; - ModalDialog.run(`What is a competition?`, content.innerHTML); + + function whatIsCompetitionPopUp() { + let content = {}; + content.innerHTML = + `
    + A competition is a simulation scenario which proposes a challenge. + A robot has to address a problem and its behavior is evaluated against a performance metric. +

    + The performance metric may be either absolute or relative: +

    + An absolute performance metric is a scalar value measuring the performance of a robot on a given task. + For example, the time spent running a 100 meters race is an absolute performance metric. +

    + A relative performance metric is a ranking of the performance of a robots against others. + For example, the tennis ATP ranking is a relative performance metric. +

    + To create your own competition, follow the instructions on this repository. +
    `; + ModalDialog.run(`What is a competition?`, content.innerHTML); } } From 782a9d8781214dfc581c9418a417a71ac2191ece Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 9 Jan 2023 15:09:21 +0100 Subject: [PATCH 069/459] typo --- httpdocs/js/webots-cloud.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 5d45436df..c71e39f67 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -320,11 +320,11 @@ document.addEventListener('DOMContentLoaded', function () { if (data.type === 'demo' || proto) { const dotIndex = data.url.lastIndexOf('/') + 1; thumbnailUrl = (data.url.slice(0, dotIndex) + '.' + data.url.slice(dotIndex)).replace('github.com', - 'raw.githubusercontent.com').replace('/blob', '') + 'raw.githubusercontent.com').replace('/blob', ''); if (proto) - thumbnailUrl = thumbnail_not_available.replace('.proto', '.jpg'); + thumbnailUrl = thumbnailUrl.replace('.proto', '.jpg'); else - thumbnailUrl = thumbnail_not_available.replace('.wbt', '.jpg'); + thumbnailUrl = thumbnailUrl.replace('.wbt', '.jpg'); } else if (data.type === 'competition') { const [, , , username, repo, , branch] = data.url.split('/'); thumbnailUrl = `https://raw.githubusercontent.com/${username}/${repo}/${branch}/preview/thumbnail.jpg`; From f8714618fcd29d1b6184d1f8ddbf98a5f33affdc Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 9 Jan 2023 15:42:26 +0100 Subject: [PATCH 070/459] right version --- httpdocs/js/project.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index b8194d43d..62d15bc85 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -126,7 +126,7 @@ export default class Project extends User { else version = data ? data.version : this.findGetParameter('version'); } - version = 'benchmark'; + version = 'proto'; const src = 'https://cyberbotics.com/wwi/' + version + '/WebotsView.js'; if (!data) From 7e75a0732c9b7badca06cba1368dd0a6e8ebdf4a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 9 Jan 2023 15:49:55 +0100 Subject: [PATCH 071/459] debug --- httpdocs/js/project.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 62d15bc85..e5182b218 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -215,6 +215,7 @@ export default class Project extends User { Project.webotsView.loadScene(`${reference}/scene.x3d`, this._isMobileDevice(), `${reference}/thumbnail.jpg`); resolve(); } else if (url.endsWith('.proto')) { + console.log("proto") this.setupWebotsView('proto'); let urlArray = url.substring(19).split('/'); urlArray.splice(2, 1); From 288001267785cfeb54d6991b010767cb9b53b1ce Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 9 Jan 2023 15:50:43 +0100 Subject: [PATCH 072/459] debug --- httpdocs/js/project.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index e5182b218..6740daa46 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -116,6 +116,7 @@ export default class Project extends User { } } runWebotsView(data, version) { + console.log("runWebotsView") let that = this; let reference; const url = this.findGetParameter('url'); @@ -215,7 +216,6 @@ export default class Project extends User { Project.webotsView.loadScene(`${reference}/scene.x3d`, this._isMobileDevice(), `${reference}/thumbnail.jpg`); resolve(); } else if (url.endsWith('.proto')) { - console.log("proto") this.setupWebotsView('proto'); let urlArray = url.substring(19).split('/'); urlArray.splice(2, 1); From 23cb4ea04e4c4127813cbb8be151b20db87786cb Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 9 Jan 2023 15:55:31 +0100 Subject: [PATCH 073/459] run --- httpdocs/js/project.js | 1 - httpdocs/js/webots-cloud.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 6740daa46..62d15bc85 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -116,7 +116,6 @@ export default class Project extends User { } } runWebotsView(data, version) { - console.log("runWebotsView") let that = this; let reference; const url = this.findGetParameter('url'); diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index c71e39f67..60d9d0945 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1472,7 +1472,7 @@ document.addEventListener('DOMContentLoaded', function () { // discriminate between demos and competition using search parameters let searchParams = new URLSearchParams(window.location.search); let type = searchParams.get('type'); - if (type === 'demo') + if (type === 'demo' || typeof type === 'undefined') // if type is undefined then it is a proto. project.runWebotsView(); else if (type === 'competition') { let url = searchParams.get('url'); From 6d137043486d31322477a263326bb20bace7929f Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 9 Jan 2023 15:56:22 +0100 Subject: [PATCH 074/459] debug --- httpdocs/js/project.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 62d15bc85..6740daa46 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -116,6 +116,7 @@ export default class Project extends User { } } runWebotsView(data, version) { + console.log("runWebotsView") let that = this; let reference; const url = this.findGetParameter('url'); From 6fe698e85fb6269f284f3cbc2db7296b0e395ea6 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 9 Jan 2023 15:57:13 +0100 Subject: [PATCH 075/459] debug --- httpdocs/js/project.js | 1 - httpdocs/js/webots-cloud.js | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 6740daa46..62d15bc85 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -116,7 +116,6 @@ export default class Project extends User { } } runWebotsView(data, version) { - console.log("runWebotsView") let that = this; let reference; const url = this.findGetParameter('url'); diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 60d9d0945..f1d020c50 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1469,6 +1469,7 @@ document.addEventListener('DOMContentLoaded', function () { } function runPage(project) { + console.log("runPage") // discriminate between demos and competition using search parameters let searchParams = new URLSearchParams(window.location.search); let type = searchParams.get('type'); From be7e956f803e0934010484197b1429fc30f817e7 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 9 Jan 2023 15:59:59 +0100 Subject: [PATCH 076/459] debug --- httpdocs/js/webots-cloud.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index f1d020c50..31aed7bee 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1469,11 +1469,10 @@ document.addEventListener('DOMContentLoaded', function () { } function runPage(project) { - console.log("runPage") // discriminate between demos and competition using search parameters let searchParams = new URLSearchParams(window.location.search); let type = searchParams.get('type'); - if (type === 'demo' || typeof type === 'undefined') // if type is undefined then it is a proto. + if (type === 'demo' || type === 'undefined') // if type is undefined then it is a proto. project.runWebotsView(); else if (type === 'competition') { let url = searchParams.get('url'); From 1f53719659af37fda9f1bfce65d9d6555b53dfe4 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 9 Jan 2023 16:52:09 +0100 Subject: [PATCH 077/459] debug --- httpdocs/js/webots-cloud.js | 72 ++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 31aed7bee..85c285abd 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1472,7 +1472,7 @@ document.addEventListener('DOMContentLoaded', function () { // discriminate between demos and competition using search parameters let searchParams = new URLSearchParams(window.location.search); let type = searchParams.get('type'); - if (type === 'demo' || type === 'undefined') // if type is undefined then it is a proto. + if (type === 'demo') project.runWebotsView(); else if (type === 'competition') { let url = searchParams.get('url'); @@ -1490,6 +1490,76 @@ document.addEventListener('DOMContentLoaded', function () { mainContainer(project); break; } + } else // proto + protoContainer(project); + + function protoContainer(proto) { + const contentHtml = + `
    + +
    +
    +
    +
    +

    +
    +
    +
    + +
    +
    +
    +

    Preview

    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +

    Leaderboard

    +
    +
    +
    +
    +
    +
    +
    `; + const template = document.createElement('template'); + template.innerHTML = contentHtml; + // document.querySelector('section.is-active').innerHTML = contentHtml; + project.setup('proto', template.content); } function mainContainer(project) { From 2466cb0700b3d1b8f2858bf8a2cc566d7ef4f183 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 9 Jan 2023 16:57:29 +0100 Subject: [PATCH 078/459] debug --- httpdocs/js/webots-cloud.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 85c285abd..b4f114abb 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1524,12 +1524,6 @@ document.addEventListener('DOMContentLoaded', function () {

    Information

    -
    - ${information} -
    - - Try Competition - Register From d1782ec3fc0bbe7bbb20ed6a9c44a1652944a42a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 9 Jan 2023 17:00:48 +0100 Subject: [PATCH 079/459] debug --- httpdocs/js/webots-cloud.js | 38 ++++--------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index b4f114abb..159f3c708 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1494,6 +1494,7 @@ document.addEventListener('DOMContentLoaded', function () { protoContainer(project); function protoContainer(proto) { + console.log(proto) const contentHtml = `
      @@ -1509,46 +1510,15 @@ document.addEventListener('DOMContentLoaded', function () {
    • Competition
    • +
    • + Proto +
    • Server
    -
    -
    -

    -
    -
    -
    - -
    -
    -
    -

    Preview

    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -

    Leaderboard

    -
    -
    -
    -
    -
    -
    `; const template = document.createElement('template'); template.innerHTML = contentHtml; From a2908d373bd14efc5eeed446db91638bb59fac69 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 9 Jan 2023 17:08:50 +0100 Subject: [PATCH 080/459] debug --- httpdocs/js/webots-cloud.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 159f3c708..55e51336e 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1470,8 +1470,8 @@ document.addEventListener('DOMContentLoaded', function () { function runPage(project) { // discriminate between demos and competition using search parameters - let searchParams = new URLSearchParams(window.location.search); - let type = searchParams.get('type'); + const searchParams = new URLSearchParams(window.location.search); + const type = searchParams.get('type'); if (type === 'demo') project.runWebotsView(); else if (type === 'competition') { @@ -1490,10 +1490,14 @@ document.addEventListener('DOMContentLoaded', function () { mainContainer(project); break; } - } else // proto - protoContainer(project); + } else { // proto + console.log(searchParams) + const urlParts = searchParams.get('url').split('/'); + const protoName = urlParts[urlParts.length - 1].split('.proto')[0]; + protoContainer(project, protoName); + } - function protoContainer(proto) { + function protoContainer(proto, protoName) { console.log(proto) const contentHtml = `
    @@ -1519,6 +1523,7 @@ document.addEventListener('DOMContentLoaded', function () {
    +

    ${protoName}

    `; const template = document.createElement('template'); template.innerHTML = contentHtml; From 12b16fb1e449fcf76303874d3111a3ee0abd72a6 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 9 Jan 2023 17:11:33 +0100 Subject: [PATCH 081/459] debug --- httpdocs/js/webots-cloud.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 55e51336e..a203bff52 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1511,10 +1511,10 @@ document.addEventListener('DOMContentLoaded', function () {
  • Simulation
  • -
  • +
  • Competition
  • -
  • +
  • Proto
  • @@ -1523,7 +1523,9 @@ document.addEventListener('DOMContentLoaded', function () {
    -

    ${protoName}

    +
    +

    ${protoName}

    +
    `; const template = document.createElement('template'); template.innerHTML = contentHtml; From 4a806f211432b0643ae906a455eca00648d410e8 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 08:10:58 +0100 Subject: [PATCH 082/459] test --- httpdocs/js/webots-cloud.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index a203bff52..3d511b7f3 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1524,7 +1524,9 @@ document.addEventListener('DOMContentLoaded', function () {
    -

    ${protoName}

    +
    +

    ${protoName}

    +
    `; const template = document.createElement('template'); From 25f5177a7c157d2d51e80aa755a6042aeea1e7ac Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 08:11:47 +0100 Subject: [PATCH 083/459] doc --- httpdocs/js/webots-cloud.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 3d511b7f3..d64dd4990 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1524,9 +1524,7 @@ document.addEventListener('DOMContentLoaded', function () {
    -
    -

    ${protoName}

    -
    +

    ${protoName}

    `; const template = document.createElement('template'); From 04e3016df29de6a6d9f58434ba7252b406bed3d2 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 08:12:13 +0100 Subject: [PATCH 084/459] test --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index d64dd4990..a9152d058 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1524,7 +1524,7 @@ document.addEventListener('DOMContentLoaded', function () {
    -

    ${protoName}

    +

    ${protoName}

    `; const template = document.createElement('template'); From 1cb5549bd1b1df64891b1ff75d1eb43b23905dbe Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 08:15:17 +0100 Subject: [PATCH 085/459] test --- httpdocs/js/project.js | 11 +++++++++++ httpdocs/js/webots-cloud.js | 1 + 2 files changed, 12 insertions(+) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 62d15bc85..ea6c58f89 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -115,6 +115,16 @@ export default class Project extends User { Project.webotsView = document.querySelector('webots-view'); } } + setupProtoWebotsView() { + if (Project.webotsView) { + Project.webotsView.close(); + document.getElementById('proto-webots-container').innerHTML = ''; + document.getElementById('proto-webots-container').appendChild(Project.webotsView); + } else { + document.getElementById('proto-webots-container').innerHTML = ''; + Project.webotsView = document.querySelector('webots-view'); + } + } runWebotsView(data, version) { let that = this; let reference; @@ -220,6 +230,7 @@ export default class Project extends User { urlArray.splice(2, 1); let rawGithubUrl = 'https://raw.githubusercontent.com/' + urlArray.join('/'); const thumbnailUrl = rawGithubUrl.replace('.proto', '.jpg'); + this.setupProtoWebotsView(); Project.webotsView.loadProto(rawGithubUrl, undefined, thumbnailUrl); resolve(); } else { // demo simulation diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index a9152d058..e57328b9c 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1525,6 +1525,7 @@ document.addEventListener('DOMContentLoaded', function () {

    ${protoName}

    +
    `; const template = document.createElement('template'); From 7e0bd7a3f73545fe3d62fcd44cc3d1a7a01039e3 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 08:16:14 +0100 Subject: [PATCH 086/459] typo --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index e57328b9c..3ba21de83 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1525,7 +1525,7 @@ document.addEventListener('DOMContentLoaded', function () {

    ${protoName}

    -
    +
    `; const template = document.createElement('template'); From 8a4002cc2a3c7dd8cfcec9f7b47a986615c80cee Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 08:24:32 +0100 Subject: [PATCH 087/459] log --- httpdocs/js/project.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 53919fbfe..30494b385 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -225,6 +225,7 @@ export default class Project extends User { let rawGithubUrl = 'https://raw.githubusercontent.com/' + urlArray.join('/'); const thumbnailUrl = rawGithubUrl.replace('.proto', '.jpg'); this.setupProtoWebotsView(); + console.log("setupProtoview") Project.webotsView.loadProto(rawGithubUrl, undefined, thumbnailUrl); resolve(); } else { // demo simulation From c161023f7cd8b339e62f2a2f636e9c5aff0523f0 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 08:30:45 +0100 Subject: [PATCH 088/459] debug --- httpdocs/js/project.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 30494b385..a4384c258 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -126,6 +126,7 @@ export default class Project extends User { } } runWebotsView(data, version) { + console.log("runWebotsView") if (!version || version === 'undefined') { if (window.location.hostname === 'proto.webots.cloud') version = 'proto'; From 37ea8a9fc2a942ca68c9043c36be3d4d47935952 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 08:32:19 +0100 Subject: [PATCH 089/459] run --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 2a340f094..783882c79 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1530,6 +1530,7 @@ document.addEventListener('DOMContentLoaded', function() { template.innerHTML = contentHtml; // document.querySelector('section.is-active').innerHTML = contentHtml; project.setup('proto', template.content); + project.runWebotsView(); } function mainContainer(project) { From 626f7dcedfb047dca02f8841836f158b32b60734 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 08:43:11 +0100 Subject: [PATCH 090/459] proto --- httpdocs/js/project.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index a4384c258..e57030c72 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -220,7 +220,7 @@ export default class Project extends User { Project.webotsView.loadScene(`${reference}/scene.x3d`, this._isMobileDevice(), `${reference}/thumbnail.jpg`); resolve(); } else if (url.endsWith('.proto')) { - this.setupWebotsView('proto'); + // this.setupWebotsView('proto'); let urlArray = url.substring(19).split('/'); urlArray.splice(2, 1); let rawGithubUrl = 'https://raw.githubusercontent.com/' + urlArray.join('/'); From 88e98dadad6c8856419c6db0c745a64c6d89664d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 08:55:13 +0100 Subject: [PATCH 091/459] debug --- httpdocs/js/project.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index e57030c72..844f36a7b 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -225,7 +225,7 @@ export default class Project extends User { urlArray.splice(2, 1); let rawGithubUrl = 'https://raw.githubusercontent.com/' + urlArray.join('/'); const thumbnailUrl = rawGithubUrl.replace('.proto', '.jpg'); - this.setupProtoWebotsView(); + // this.setupProtoWebotsView(); console.log("setupProtoview") Project.webotsView.loadProto(rawGithubUrl, undefined, thumbnailUrl); resolve(); From 82205b4abca380d7cdfddd02809e2aed9fbd14fd Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 08:57:53 +0100 Subject: [PATCH 092/459] project --- httpdocs/js/project.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 844f36a7b..e57030c72 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -225,7 +225,7 @@ export default class Project extends User { urlArray.splice(2, 1); let rawGithubUrl = 'https://raw.githubusercontent.com/' + urlArray.join('/'); const thumbnailUrl = rawGithubUrl.replace('.proto', '.jpg'); - // this.setupProtoWebotsView(); + this.setupProtoWebotsView(); console.log("setupProtoview") Project.webotsView.loadProto(rawGithubUrl, undefined, thumbnailUrl); resolve(); From 6ee34a8a4fb397c7cd41b5a7951aa4b8eba3e561 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 08:58:41 +0100 Subject: [PATCH 093/459] id --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 783882c79..aade59abe 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1523,7 +1523,7 @@ document.addEventListener('DOMContentLoaded', function() {

    ${protoName}

    -
    +
    `; const template = document.createElement('template'); From 30b81cfe97c9d9bd27e01874eb21fd9845621869 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 09:00:53 +0100 Subject: [PATCH 094/459] css --- httpdocs/css/webots-cloud.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 069c08bf3..a7ed91020 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -333,3 +333,10 @@ nav.pagination > a[disabled] { opacity: 1; color: #aaa; } + +/* Proto */ + +#proto-webots-container { + width: 100%; + aspect-ratio: 16 / 9; +} From da6df68eb5943cdb6af2f380189247a2888dce1d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 09:04:03 +0100 Subject: [PATCH 095/459] class --- httpdocs/css/webots-cloud.css | 5 +++++ httpdocs/js/webots-cloud.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index a7ed91020..d0825c1fd 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -336,6 +336,11 @@ nav.pagination > a[disabled] { /* Proto */ +.proto-title { + text-align: center; + padding-bottom: 50px; +} + #proto-webots-container { width: 100%; aspect-ratio: 16 / 9; diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index aade59abe..f7af6c4b7 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1522,7 +1522,7 @@ document.addEventListener('DOMContentLoaded', function() {
    -

    ${protoName}

    +

    ${protoName}

    `; From acd5732f35b2ab691815eae3827ae92a188ef420 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 09:06:10 +0100 Subject: [PATCH 096/459] title --- httpdocs/css/webots-cloud.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index d0825c1fd..92e43a866 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -339,6 +339,8 @@ nav.pagination > a[disabled] { .proto-title { text-align: center; padding-bottom: 50px; + font-size: 3rem; + font-weight: 600; } #proto-webots-container { From ffa5cf53c1b99f989e70c05d6cc30fc765f1cb03 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 09:40:00 +0100 Subject: [PATCH 097/459] url --- httpdocs/js/webots-cloud.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index f7af6c4b7..4429f490b 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1490,13 +1490,14 @@ document.addEventListener('DOMContentLoaded', function() { mainContainer(project); break; } - } else { // proto - const urlParts = searchParams.get('url').split('/'); + } else // proto + protoContainer(project, searchParams); + + function protoContainer(proto, searchParams) { + const url = searchParams.get('url'); + const urlParts = url.split('/'); const protoName = urlParts[urlParts.length - 1].split('.proto')[0]; - protoContainer(project, protoName); - } - function protoContainer(proto, protoName) { const contentHtml = `
      @@ -1524,6 +1525,7 @@ document.addEventListener('DOMContentLoaded', function() {

      ${protoName}

      +
    `; const template = document.createElement('template'); @@ -1531,6 +1533,14 @@ document.addEventListener('DOMContentLoaded', function() { // document.querySelector('section.is-active').innerHTML = contentHtml; project.setup('proto', template.content); project.runWebotsView(); + const prefix = url.substr(0, url.lastIndexOf('/')); + console.log(prefix) + + loadMd(url); + } + + function loadMd(url) { + } function mainContainer(project) { From 073a68a60e3d5efca42940c4ce9e0d041a4eea0f Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 09:44:32 +0100 Subject: [PATCH 098/459] md url --- httpdocs/js/webots-cloud.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 4429f490b..00f6f5cd4 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1534,13 +1534,12 @@ document.addEventListener('DOMContentLoaded', function() { project.setup('proto', template.content); project.runWebotsView(); const prefix = url.substr(0, url.lastIndexOf('/')); - console.log(prefix) - - loadMd(url); + const mdUrl = prefix + '/docs/' + protoName + '.md'; + loadMd(mdUrl); } function loadMd(url) { - + console.log(url) } function mainContainer(project) { From b2822a58a11f7bcf0f1a356a6c0c25cffa55ede6 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 09:49:02 +0100 Subject: [PATCH 099/459] lowercase --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 00f6f5cd4..8ed57501c 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1534,7 +1534,7 @@ document.addEventListener('DOMContentLoaded', function() { project.setup('proto', template.content); project.runWebotsView(); const prefix = url.substr(0, url.lastIndexOf('/')); - const mdUrl = prefix + '/docs/' + protoName + '.md'; + const mdUrl = prefix + '/docs/' + protoName.toLowerCase() + '.md'; loadMd(mdUrl); } From 0694b3ca5228bb67cad7080c275183bab78db403 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 09:50:16 +0100 Subject: [PATCH 100/459] fetch --- httpdocs/js/webots-cloud.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 8ed57501c..277218687 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1539,6 +1539,9 @@ document.addEventListener('DOMContentLoaded', function() { } function loadMd(url) { + fetch(url).then(answer => { + console.log(answer) + }) console.log(url) } From 3001514f07e881b6d85ceab3854c39c804908c65 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 09:53:45 +0100 Subject: [PATCH 101/459] url --- httpdocs/js/webots-cloud.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 277218687..734a38f0e 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1534,7 +1534,11 @@ document.addEventListener('DOMContentLoaded', function() { project.setup('proto', template.content); project.runWebotsView(); const prefix = url.substr(0, url.lastIndexOf('/')); - const mdUrl = prefix + '/docs/' + protoName.toLowerCase() + '.md'; + let mdUrl = prefix + '/docs/' + protoName.toLowerCase() + '.md'; + if (mdUrl.contains('github.com')) { + mdUrl.replace('github.com', 'raw.githubusercontent.com'); + mdUrl.replace('blob/', ''); + } loadMd(mdUrl); } From 97c4885c0af29df7b1d27be179b905f9df268948 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 09:54:17 +0100 Subject: [PATCH 102/459] typo --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 734a38f0e..81b5012a0 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1535,7 +1535,7 @@ document.addEventListener('DOMContentLoaded', function() { project.runWebotsView(); const prefix = url.substr(0, url.lastIndexOf('/')); let mdUrl = prefix + '/docs/' + protoName.toLowerCase() + '.md'; - if (mdUrl.contains('github.com')) { + if (mdUrl.includes('github.com')) { mdUrl.replace('github.com', 'raw.githubusercontent.com'); mdUrl.replace('blob/', ''); } From c4e432e6c7fcd9c4a4863c6fa22dcf6385320fe7 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 09:57:32 +0100 Subject: [PATCH 103/459] replace --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 81b5012a0..35adfde5b 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1538,6 +1538,7 @@ document.addEventListener('DOMContentLoaded', function() { if (mdUrl.includes('github.com')) { mdUrl.replace('github.com', 'raw.githubusercontent.com'); mdUrl.replace('blob/', ''); + console.log("REPLACE") } loadMd(mdUrl); } From b7a8a067cd56e88c0223606c765a07301b5926ee Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 09:58:41 +0100 Subject: [PATCH 104/459] url --- httpdocs/js/webots-cloud.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 35adfde5b..8e69631ef 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1536,9 +1536,8 @@ document.addEventListener('DOMContentLoaded', function() { const prefix = url.substr(0, url.lastIndexOf('/')); let mdUrl = prefix + '/docs/' + protoName.toLowerCase() + '.md'; if (mdUrl.includes('github.com')) { - mdUrl.replace('github.com', 'raw.githubusercontent.com'); - mdUrl.replace('blob/', ''); - console.log("REPLACE") + mdUrl = mdUrl.replace('github.com', 'raw.githubusercontent.com'); + mdUrl = mdUrl.replace('blob/', ''); } loadMd(mdUrl); } From 8f8f6583c017c603998391b8d38c848b5c85c5b6 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 10:06:05 +0100 Subject: [PATCH 105/459] function --- httpdocs/js/webots-cloud.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 8e69631ef..0e4dd1d9d 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1,5 +1,6 @@ import Project from './project.js'; import ModalDialog from './modal_dialog.js'; +import {populateProtoViewDiv} from 'https://cyberbotics.ch/wwi/proto/viewer.js'; document.addEventListener('DOMContentLoaded', function() { let scenePage = 1; @@ -1543,9 +1544,13 @@ document.addEventListener('DOMContentLoaded', function() { } function loadMd(url) { - fetch(url).then(answer => { - console.log(answer) - }) + fetch(url) + .then(response => response.text()) + .then(content => populateProtoViewDiv(content)) + .catch(error => { + console.error('Error: ' + error); + // TODO load from comments + }); console.log(url) } From 41921c284ec68c0f838b5b4772ea7622c11fe2f3 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 10:07:37 +0100 Subject: [PATCH 106/459] url --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 0e4dd1d9d..ec2ebaa38 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1,6 +1,6 @@ import Project from './project.js'; import ModalDialog from './modal_dialog.js'; -import {populateProtoViewDiv} from 'https://cyberbotics.ch/wwi/proto/viewer.js'; +import {populateProtoViewDiv} from 'https://cyberbotics.com/wwi/proto/viewer.js'; document.addEventListener('DOMContentLoaded', function() { let scenePage = 1; From e974827ef236d9a89026a2313c31d1ff7671e6f0 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 10:13:02 +0100 Subject: [PATCH 107/459] scripts --- httpdocs/index.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/httpdocs/index.html b/httpdocs/index.html index 42fecd552..c4e530487 100644 --- a/httpdocs/index.html +++ b/httpdocs/index.html @@ -19,6 +19,9 @@
    + + + From 0b152936ecd8df3588f35a8dc0ddc18174c39f00 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 10:28:29 +0100 Subject: [PATCH 108/459] proto-viewr --- httpdocs/index.html | 3 --- httpdocs/js/webots-cloud.js | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/httpdocs/index.html b/httpdocs/index.html index c4e530487..42fecd552 100644 --- a/httpdocs/index.html +++ b/httpdocs/index.html @@ -19,9 +19,6 @@
    - - - diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index ec2ebaa38..109a5a258 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1,6 +1,6 @@ import Project from './project.js'; import ModalDialog from './modal_dialog.js'; -import {populateProtoViewDiv} from 'https://cyberbotics.com/wwi/proto/viewer.js'; +import {populateProtoViewDiv} from 'https://cyberbotics.com/wwi/proto/proto-viewer.js'; document.addEventListener('DOMContentLoaded', function() { let scenePage = 1; From 71fb319c1aad9f5f9c54e6a53a752fe2d20a29ef Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 10:28:55 +0100 Subject: [PATCH 109/459] typo --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 109a5a258..020a75f29 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1,6 +1,6 @@ import Project from './project.js'; import ModalDialog from './modal_dialog.js'; -import {populateProtoViewDiv} from 'https://cyberbotics.com/wwi/proto/proto-viewer.js'; +import {populateProtoViewDiv} from 'https://cyberbotics.com/wwi/proto/protoViewer.js'; document.addEventListener('DOMContentLoaded', function() { let scenePage = 1; From 04845a9732f9bbb90d59cb6fc7a47ae72ebc4a3d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 10:29:38 +0100 Subject: [PATCH 110/459] typo --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 020a75f29..109a5a258 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1,6 +1,6 @@ import Project from './project.js'; import ModalDialog from './modal_dialog.js'; -import {populateProtoViewDiv} from 'https://cyberbotics.com/wwi/proto/protoViewer.js'; +import {populateProtoViewDiv} from 'https://cyberbotics.com/wwi/proto/proto-viewer.js'; document.addEventListener('DOMContentLoaded', function() { let scenePage = 1; From 65435f2bd97dc0fe8f39d6877c31f87fb542faa1 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 10:39:18 +0100 Subject: [PATCH 111/459] _ --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 109a5a258..0977acbe8 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1,6 +1,6 @@ import Project from './project.js'; import ModalDialog from './modal_dialog.js'; -import {populateProtoViewDiv} from 'https://cyberbotics.com/wwi/proto/proto-viewer.js'; +import {populateProtoViewDiv} from 'https://cyberbotics.com/wwi/proto/proto_viewer.js'; document.addEventListener('DOMContentLoaded', function() { let scenePage = 1; From b5a25698e80871f9d53907000613399e1ab31638 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 10:47:37 +0100 Subject: [PATCH 112/459] scripts --- httpdocs/index.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/httpdocs/index.html b/httpdocs/index.html index 42fecd552..a150774d4 100644 --- a/httpdocs/index.html +++ b/httpdocs/index.html @@ -21,4 +21,11 @@
    + + + + + + + From c5653dd6dd3b75e059510852ebc4103f12ee3fbd Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 10:56:16 +0100 Subject: [PATCH 113/459] scritp --- httpdocs/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/index.html b/httpdocs/index.html index a150774d4..8c5d55e22 100644 --- a/httpdocs/index.html +++ b/httpdocs/index.html @@ -28,4 +28,5 @@ + From a09cb9475f9e3273057745c88644466d5cda6d95 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 11:05:54 +0100 Subject: [PATCH 114/459] test --- httpdocs/index.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/httpdocs/index.html b/httpdocs/index.html index 8c5d55e22..379df20e2 100644 --- a/httpdocs/index.html +++ b/httpdocs/index.html @@ -16,17 +16,17 @@ + + + + + + + +
    - - - - - - - - From 95ad11a2af72bbecc952b4fd9ccc356f366b1a49 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 11:16:20 +0100 Subject: [PATCH 115/459] js --- httpdocs/index.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/httpdocs/index.html b/httpdocs/index.html index 379df20e2..5ed07d03a 100644 --- a/httpdocs/index.html +++ b/httpdocs/index.html @@ -16,17 +16,17 @@ - - - - - - - -
    + + + + + + + + From 696a5fe2b409de9439b5caee052288689ec5f209 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 11:42:22 +0100 Subject: [PATCH 116/459] prefix --- httpdocs/js/webots-cloud.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 0977acbe8..b37030449 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1546,8 +1546,10 @@ document.addEventListener('DOMContentLoaded', function() { function loadMd(url) { fetch(url) .then(response => response.text()) - .then(content => populateProtoViewDiv(content)) - .catch(error => { + .then(content => { + const prefix = url.substr(0, url.lastIndexOf('/') + 1); + populateProtoViewDiv(content, prefix); + }).catch(error => { console.error('Error: ' + error); // TODO load from comments }); From ef4d7b1f56f381a97954af8bf83a2f88e9505ce0 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 12:17:17 +0100 Subject: [PATCH 117/459] title --- httpdocs/css/webots-cloud.css | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 92e43a866..92bc0a8be 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -337,10 +337,13 @@ nav.pagination > a[disabled] { /* Proto */ .proto-title { - text-align: center; - padding-bottom: 50px; - font-size: 3rem; - font-weight: 600; + font-family: 'Roboto'; + font-style: normal; + font-weight: normal; + color: #0e6f8c; + clear: both; + margin: 20px auto; + word-wrap: break-word; } #proto-webots-container { From 96b20387d4a7cfbaa422aed93e323477f37c36ea Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 12:29:56 +0100 Subject: [PATCH 118/459] css --- httpdocs/css/webots-cloud.css | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 92bc0a8be..eb11a1e27 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -350,3 +350,55 @@ nav.pagination > a[disabled] { width: 100%; aspect-ratio: 16 / 9; } + +.modal-window-load-image { + margin: auto; + display: block; + cursor: pointer; + padding: 60px 120px; + background-color: white; + -webkit-box-shadow: 0px 0px 10px 0px rgba(255,255,255,0.5); + -moz-box-shadow: 0px 0px 10px 0px rgba(255,255,255,0.5); + box-shadow: 0px 0px 10px 0px rgba(255,255,255,0.5); + border-radius: 6px; +} + +.modal-window-image-content { + margin: auto; + max-height: 80%; + max-width: 90%; + display: block; + cursor: pointer; + transition: 0.05s; + background-color: white; +} + +.modal-window-close-button { + position: absolute; + top: 10px; + right: 35px; + color: #f1f1f1; + font-size: 30px; + font-weight: bold; + transition: 0.2s; +} + +.modal-window-close-button:hover, +.modal-window-close-button:focus { + color: #bbb; + text-decoration: none; + cursor: pointer; +} + +.modal-window-caption { + margin: auto; + display: block; + max-width: 700px; + text-align: center; + color: #ccc; + padding: 10px 0; + -webkit-animation-name: zoom; + -webkit-animation-duration: 0.6s; + animation-name: zoom; + animation-duration: 0.4s; +} From 5c49b12e8458d126a371ca6b0a1cb2d25760a845 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 12:30:59 +0100 Subject: [PATCH 119/459] css --- httpdocs/css/webots-cloud.css | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index eb11a1e27..275b90878 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -337,13 +337,7 @@ nav.pagination > a[disabled] { /* Proto */ .proto-title { - font-family: 'Roboto'; - font-style: normal; - font-weight: normal; - color: #0e6f8c; - clear: both; - margin: 20px auto; - word-wrap: break-word; + text-align: center; } #proto-webots-container { @@ -351,6 +345,20 @@ nav.pagination > a[disabled] { aspect-ratio: 16 / 9; } +.webots-doc .modal-window { + display: none; + position: fixed; + z-index: 100; + padding-top: 60px; + left: 0; + top: 0; + width: 100%; + height: 100%; + overflow: auto; + background-color: rgb(0,0,0); + background-color: rgba(0,0,0,0.9); +} + .modal-window-load-image { margin: auto; display: block; From 766de610f2a3cb9f50cd37da2c60c0eb8bc6c54e Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 12:32:20 +0100 Subject: [PATCH 120/459] typo --- httpdocs/css/webots-cloud.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 275b90878..1efb87cba 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -345,7 +345,7 @@ nav.pagination > a[disabled] { aspect-ratio: 16 / 9; } -.webots-doc .modal-window { +.modal-window { display: none; position: fixed; z-index: 100; From 0880e302e15c016221b0a38db7cd5f952153c189 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 13:46:13 +0100 Subject: [PATCH 121/459] css --- httpdocs/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/index.html b/httpdocs/index.html index 5ed07d03a..82d63842e 100644 --- a/httpdocs/index.html +++ b/httpdocs/index.html @@ -15,6 +15,7 @@ + @@ -22,7 +23,6 @@ - From 97a0d4115f221fb67ee9f8029af029611d8ad719 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 13:47:32 +0100 Subject: [PATCH 122/459] css --- httpdocs/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/index.html b/httpdocs/index.html index 82d63842e..e4461a5a0 100644 --- a/httpdocs/index.html +++ b/httpdocs/index.html @@ -15,7 +15,7 @@ - + From 746214faf1069c6bbcca83e96cae005e48225801 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 13:49:33 +0100 Subject: [PATCH 123/459] css --- httpdocs/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/index.html b/httpdocs/index.html index e4461a5a0..a1d244ecb 100644 --- a/httpdocs/index.html +++ b/httpdocs/index.html @@ -15,7 +15,7 @@ - + From b2590ae7d7cb3798da931098f224aee4cdaa88f2 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 13:57:07 +0100 Subject: [PATCH 124/459] css --- httpdocs/css/webots-cloud.css | 38 ++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 1efb87cba..ccb866c38 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -336,7 +336,7 @@ nav.pagination > a[disabled] { /* Proto */ -.proto-title { +.proto-doc .proto-title { text-align: center; } @@ -410,3 +410,39 @@ nav.pagination > a[disabled] { animation-name: zoom; animation-duration: 0.4s; } + +.proto-doc figcaption:hover .anchor-link, +.proto-doc h1:hover .anchor-link, +.proto-doc h2:hover .anchor-link, +.proto-doc h3:hover .anchor-link, +.proto-doc h4:hover .anchor-link, +.proto-doc h5:hover .anchor-link, +.proto-doc h6:hover .anchor-link { + opacity: 1; +} + +.proto-doc .anchor-link-image { + padding-left: 20px; + background: url(images/anchor.png) left center no-repeat; + background-size: 20px; +} +.proto-doc .anchor-link { + opacity: 0; + \-webkit-transition: opacity 0.2s ease-in-out 0.1s; + \-moz-transition: opacity 0.2s ease-in-out 0.1s; + \-ms-transition: opacity 0.2s ease-in-out 0.1s; +} + +.proto-doc h3 { + font-size: 26px; +} + +.proto-doc h1, .proto-doc h2, .proto-doc h3, .proto-doc h4, .proto-doc h5, .proto-doc h6 { + font-family: 'Roboto'; + font-style: normal; + font-weight: normal; + color: #0e6f8c; + clear: both; + margin: 20px auto; + word-wrap: break-word; +} From 2a381359d9b00821a4f6ea15715e82964d231e15 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 14:42:38 +0100 Subject: [PATCH 125/459] css --- httpdocs/css/webots-cloud.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index ccb866c38..74e272a92 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -446,3 +446,9 @@ nav.pagination > a[disabled] { margin: 20px auto; word-wrap: break-word; } + +.proto-doc ul, { + margin: 0.5em 1em; + padding-left: 1em; + list-style-type: circle; +} From c99591564f967f9d3d3198c984efae49c9fcd6b3 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 14:43:56 +0100 Subject: [PATCH 126/459] css --- httpdocs/css/webots-cloud.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 74e272a92..ebe0c396b 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -447,7 +447,7 @@ nav.pagination > a[disabled] { word-wrap: break-word; } -.proto-doc ul, { +.proto-doc ul { margin: 0.5em 1em; padding-left: 1em; list-style-type: circle; From 9f5b26669524d0b06a4ccb01bc13cbcbeb48f8a9 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 14:47:41 +0100 Subject: [PATCH 127/459] css --- httpdocs/css/webots-cloud.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index ebe0c396b..9a9098db7 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -423,7 +423,7 @@ nav.pagination > a[disabled] { .proto-doc .anchor-link-image { padding-left: 20px; - background: url(images/anchor.png) left center no-repeat; + background: url("https://raw.githubusercontent.com/cyberbotics/released/docs/css/images/anchor.png") left center no-repeat; background-size: 20px; } .proto-doc .anchor-link { @@ -450,5 +450,5 @@ nav.pagination > a[disabled] { .proto-doc ul { margin: 0.5em 1em; padding-left: 1em; - list-style-type: circle; + list-style-type: disc; } From 7b6bc3797aaae3a5fddf848211bc80dfb2573ce7 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 14:48:41 +0100 Subject: [PATCH 128/459] released> --- httpdocs/css/webots-cloud.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 9a9098db7..ad1d2912e 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -423,7 +423,7 @@ nav.pagination > a[disabled] { .proto-doc .anchor-link-image { padding-left: 20px; - background: url("https://raw.githubusercontent.com/cyberbotics/released/docs/css/images/anchor.png") left center no-repeat; + background: url("https://raw.githubusercontent.com/cyberbotics/webots/released/docs/css/images/anchor.png") left center no-repeat; background-size: 20px; } .proto-doc .anchor-link { From 84a9ad2f008ee6e836d1d498f91103d2129429cb Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 14:50:31 +0100 Subject: [PATCH 129/459] anchor --- httpdocs/css/webots-cloud.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index ad1d2912e..07cf3da0e 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -433,6 +433,12 @@ nav.pagination > a[disabled] { \-ms-transition: opacity 0.2s ease-in-out 0.1s; } +.proto-doc .anchor-header { + position: relative; + left: -20px; + padding: 9px 0px; +} + .proto-doc h3 { font-size: 26px; } From fe31c505c372dbedb80b1a755f748623fb411bf5 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 15:04:05 +0100 Subject: [PATCH 130/459] remove debug --- httpdocs/js/project.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index e57030c72..e1ccea5a1 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -126,7 +126,6 @@ export default class Project extends User { } } runWebotsView(data, version) { - console.log("runWebotsView") if (!version || version === 'undefined') { if (window.location.hostname === 'proto.webots.cloud') version = 'proto'; @@ -226,7 +225,6 @@ export default class Project extends User { let rawGithubUrl = 'https://raw.githubusercontent.com/' + urlArray.join('/'); const thumbnailUrl = rawGithubUrl.replace('.proto', '.jpg'); this.setupProtoWebotsView(); - console.log("setupProtoview") Project.webotsView.loadProto(rawGithubUrl, undefined, thumbnailUrl); resolve(); } else { // demo simulation From 6e3cc632632f8840ebb3486092d7d0a3452ec6f2 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 15:14:14 +0100 Subject: [PATCH 131/459] css --- httpdocs/css/webots-cloud.css | 6 ++++++ httpdocs/js/webots-cloud.js | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 07cf3da0e..8ca02c0d1 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -458,3 +458,9 @@ nav.pagination > a[disabled] { padding-left: 1em; list-style-type: disc; } + +.proto-doc .illustrated-section { + overflow: hidden; + padding: 10px 0px; + margin: 20px 10px; +} diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index b37030449..ed1e40b7f 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1553,7 +1553,6 @@ document.addEventListener('DOMContentLoaded', function() { console.error('Error: ' + error); // TODO load from comments }); - console.log(url) } function mainContainer(project) { From 0850dd589b325b19abc820869f4bb9d860276b6f Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 15:31:28 +0100 Subject: [PATCH 132/459] css --- httpdocs/css/webots-cloud.css | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 8ca02c0d1..92be92293 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -336,8 +336,11 @@ nav.pagination > a[disabled] { /* Proto */ -.proto-doc .proto-title { +.proto-title { text-align: center; + font-weight: 600; + line-height: 1.125; + font-size: 3rem; } #proto-webots-container { From 855bfe15b8a375ede32e58ad96ad14b5aa49b763 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 15:32:50 +0100 Subject: [PATCH 133/459] css --- httpdocs/css/webots-cloud.css | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 92be92293..7d0d0e5cf 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -341,6 +341,7 @@ nav.pagination > a[disabled] { font-weight: 600; line-height: 1.125; font-size: 3rem; + padding-bottom: 40px; } #proto-webots-container { From f9e0e67b09e90bf4ebd5cd6cb010f34ab862b4ab Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 15:34:00 +0100 Subject: [PATCH 134/459] css --- httpdocs/css/webots-cloud.css | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 7d0d0e5cf..0aa000678 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -444,23 +444,23 @@ nav.pagination > a[disabled] { } .proto-doc h3 { - font-size: 26px; + font-size: 26px; } .proto-doc h1, .proto-doc h2, .proto-doc h3, .proto-doc h4, .proto-doc h5, .proto-doc h6 { - font-family: 'Roboto'; - font-style: normal; - font-weight: normal; - color: #0e6f8c; - clear: both; - margin: 20px auto; - word-wrap: break-word; + font-family: 'Roboto'; + font-style: normal; + font-weight: normal; + color: #0e6f8c; + clear: both; + margin: 20px auto; + word-wrap: break-word; } .proto-doc ul { - margin: 0.5em 1em; - padding-left: 1em; - list-style-type: disc; + margin: 0.5em 1em; + padding-left: 1em; + list-style-type: disc; } .proto-doc .illustrated-section { @@ -468,3 +468,14 @@ nav.pagination > a[disabled] { padding: 10px 0px; margin: 20px 10px; } + +.proto-doc .illustrated-section img { + max-width: 30%; + min-width: 120px; + float: left; + padding: 3px 10px 0px 0px; +} + +.proto-doc .illustrated-section p { + margin: 0px; +} From 790ca49aa2730eab2c31522b8664b2eb9d0b6fa2 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 15:41:28 +0100 Subject: [PATCH 135/459] css --- httpdocs/css/webots-cloud.css | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 0aa000678..831f83635 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -447,6 +447,10 @@ nav.pagination > a[disabled] { font-size: 26px; } +.proto-doc h4 { + font-size: 18px; +} + .proto-doc h1, .proto-doc h2, .proto-doc h3, .proto-doc h4, .proto-doc h5, .proto-doc h6 { font-family: 'Roboto'; font-style: normal; @@ -479,3 +483,11 @@ nav.pagination > a[disabled] { .proto-doc .illustrated-section p { margin: 0px; } + +.proto-doc p > code, .webots-doc li > code { + color: #222; + background: #eee; + padding: 2px 6px; + border-radius: 4px; + white-space: normal; +} From 767a38afc83b9cfe34b7ba7ec72c858223c99e81 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 15:46:54 +0100 Subject: [PATCH 136/459] css --- httpdocs/css/webots-cloud.css | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 831f83635..96ac78d52 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -1,3 +1,38 @@ +@font-face { + font-family: "Roboto"; + font-style: normal; + font-weight: 400; + src: url("https://raw.githubusercontent.com/cyberbotics/webots/docs/css/fonts/Roboto-Regular.ttf") format("truetype"); +} + +@font-face { + font-family: "Roboto"; + font-style: italic; + font-weight: 400; + src: url("https://raw.githubusercontent.com/cyberbotics/webots/docs/css/fonts/Roboto-Italic.ttf") format("truetype"); +} + +@font-face { + font-family: "Roboto"; + font-style: normal; + font-weight: 700; + src: url("https://raw.githubusercontent.com/cyberbotics/webots/docs/css/fonts/Roboto-Bold.ttf") format("truetype"); +} + +@font-face { + font-family: "Roboto"; + font-style: italic; + font-weight: 700; + src: url("https://raw.githubusercontent.com/cyberbotics/webots/docs/css/fonts/Roboto-BoldItalic.ttf") format("truetype"); +} + +@font-face { + font-family: "Roboto Mono"; + font-style: normal; + src: url("https://raw.githubusercontent.com/cyberbotics/webots/docs/css/fonts/Roboto-Mono.ttf") format("truetype"); +} + + html { height: 100%; overflow-y: auto; @@ -415,6 +450,17 @@ nav.pagination > a[disabled] { animation-duration: 0.4s; } +.proto-doc p { + font-family: "Roboto"; + color: black; + margin-left: 10px; + margin-right: 10px; + font-size: 16px; + text-align: justify; + line-height: 140%; + word-wrap: break-word; +} + .proto-doc figcaption:hover .anchor-link, .proto-doc h1:hover .anchor-link, .proto-doc h2:hover .anchor-link, @@ -490,4 +536,7 @@ nav.pagination > a[disabled] { padding: 2px 6px; border-radius: 4px; white-space: normal; + font-size: 15px; + font-family: "Roboto Mono", monospace; + word-wrap: break-word; } From 6b35831677e94562ea5383533070cdff2b9e0ed3 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 15:48:05 +0100 Subject: [PATCH 137/459] typo --- httpdocs/css/webots-cloud.css | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 96ac78d52..c598b586a 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -2,34 +2,34 @@ font-family: "Roboto"; font-style: normal; font-weight: 400; - src: url("https://raw.githubusercontent.com/cyberbotics/webots/docs/css/fonts/Roboto-Regular.ttf") format("truetype"); + src: url("https://raw.githubusercontent.com/cyberbotics/webots/released/docs/css/fonts/Roboto-Regular.ttf") format("truetype"); } @font-face { font-family: "Roboto"; font-style: italic; font-weight: 400; - src: url("https://raw.githubusercontent.com/cyberbotics/webots/docs/css/fonts/Roboto-Italic.ttf") format("truetype"); + src: url("https://raw.githubusercontent.com/cyberbotics/webots/released/docs/css/fonts/Roboto-Italic.ttf") format("truetype"); } @font-face { font-family: "Roboto"; font-style: normal; font-weight: 700; - src: url("https://raw.githubusercontent.com/cyberbotics/webots/docs/css/fonts/Roboto-Bold.ttf") format("truetype"); + src: url("https://raw.githubusercontent.com/cyberbotics/webots/released/docs/css/fonts/Roboto-Bold.ttf") format("truetype"); } @font-face { font-family: "Roboto"; font-style: italic; font-weight: 700; - src: url("https://raw.githubusercontent.com/cyberbotics/webots/docs/css/fonts/Roboto-BoldItalic.ttf") format("truetype"); + src: url("https://raw.githubusercontent.com/cyberbotics/webots/released/docs/css/fonts/Roboto-BoldItalic.ttf") format("truetype"); } @font-face { font-family: "Roboto Mono"; font-style: normal; - src: url("https://raw.githubusercontent.com/cyberbotics/webots/docs/css/fonts/Roboto-Mono.ttf") format("truetype"); + src: url("https://raw.githubusercontent.com/cyberbotics/webots/released/docs/css/fonts/Roboto-Mono.ttf") format("truetype"); } From 26876df19650d9d191bafe4d4068f661fbd2ffdc Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 15:52:22 +0100 Subject: [PATCH 138/459] css --- httpdocs/css/webots-cloud.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index c598b586a..0be288957 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -530,7 +530,7 @@ nav.pagination > a[disabled] { margin: 0px; } -.proto-doc p > code, .webots-doc li > code { +.proto-doc p > code, .proto-doc li > code { color: #222; background: #eee; padding: 2px 6px; From ba88440409b5f01b8f26f7c0a60cc05050b983dd Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 10 Jan 2023 16:00:20 +0100 Subject: [PATCH 139/459] css --- httpdocs/css/webots-cloud.css | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 0be288957..1e42d2285 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -540,3 +540,14 @@ nav.pagination > a[disabled] { font-family: "Roboto Mono", monospace; word-wrap: break-word; } + +.proto-doc { + padding-top: 50px; +} + +.proto-doc iframe { + width: 70%; + height: 400px; + margin: 30px auto; + display: block; +} From b3149d0ff9a0f623d492014e5bab33e15c20fe20 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 08:31:02 +0100 Subject: [PATCH 140/459] prepare for generate md --- httpdocs/js/webots-cloud.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index ed1e40b7f..75461693a 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1534,27 +1534,36 @@ document.addEventListener('DOMContentLoaded', function() { // document.querySelector('section.is-active').innerHTML = contentHtml; project.setup('proto', template.content); project.runWebotsView(); + loadMd(url); + } + + function loadMd(url) { const prefix = url.substr(0, url.lastIndexOf('/')); + const protoName = url.substr(url.lastIndexOf('/') + 1); let mdUrl = prefix + '/docs/' + protoName.toLowerCase() + '.md'; if (mdUrl.includes('github.com')) { mdUrl = mdUrl.replace('github.com', 'raw.githubusercontent.com'); mdUrl = mdUrl.replace('blob/', ''); } - loadMd(mdUrl); - } - function loadMd(url) { fetch(url) .then(response => response.text()) .then(content => { const prefix = url.substr(0, url.lastIndexOf('/') + 1); populateProtoViewDiv(content, prefix); - }).catch(error => { - console.error('Error: ' + error); - // TODO load from comments + }).catch(() => { + // No md file, so we read the description from the proto file + fetch(url) + .then(response => response.text()) + .then(content => { + generateMd(content); + }); }); } + function generateMd(proto) { + } + function mainContainer(project) { let simulationUrl = new URL(window.location); simulationUrl.searchParams.append('context', 'try'); From b72fa71787c61b0e2d36865ad969d16b45cf0952 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 08:39:13 +0100 Subject: [PATCH 141/459] url --- httpdocs/js/webots-cloud.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 75461693a..ce39b477b 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1538,20 +1538,18 @@ document.addEventListener('DOMContentLoaded', function() { } function loadMd(url) { - const prefix = url.substr(0, url.lastIndexOf('/')); + const prefix = url.substr(0, url.lastIndexOf('/') + 1); const protoName = url.substr(url.lastIndexOf('/') + 1); - let mdUrl = prefix + '/docs/' + protoName.toLowerCase() + '.md'; + let mdUrl = prefix + 'docs/' + protoName.toLowerCase() + '.md'; if (mdUrl.includes('github.com')) { mdUrl = mdUrl.replace('github.com', 'raw.githubusercontent.com'); mdUrl = mdUrl.replace('blob/', ''); } - fetch(url) + fetch(mdUrl) .then(response => response.text()) - .then(content => { - const prefix = url.substr(0, url.lastIndexOf('/') + 1); - populateProtoViewDiv(content, prefix); - }).catch(() => { + .then(content => populateProtoViewDiv(content, prefix)) + .catch(() => { // No md file, so we read the description from the proto file fetch(url) .then(response => response.text()) From 5ad53310a935c1f8a4e955b6ac2fbe240dea71c7 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 08:41:41 +0100 Subject: [PATCH 142/459] url --- httpdocs/js/webots-cloud.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index ce39b477b..c2b62578f 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1548,8 +1548,9 @@ document.addEventListener('DOMContentLoaded', function() { fetch(mdUrl) .then(response => response.text()) - .then(content => populateProtoViewDiv(content, prefix)) - .catch(() => { + .then(content => { + populateProtoViewDiv(content, prefix); + }).catch(() => { // No md file, so we read the description from the proto file fetch(url) .then(response => response.text()) From 8d68c1813ec6d0a4524c2d6aca5f8e680d73ae56 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 08:45:56 +0100 Subject: [PATCH 143/459] proto --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index c2b62578f..2655766fc 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1539,7 +1539,7 @@ document.addEventListener('DOMContentLoaded', function() { function loadMd(url) { const prefix = url.substr(0, url.lastIndexOf('/') + 1); - const protoName = url.substr(url.lastIndexOf('/') + 1); + const protoName = url.substr(url.lastIndexOf('/') + 1).replace('.proto', ''); let mdUrl = prefix + 'docs/' + protoName.toLowerCase() + '.md'; if (mdUrl.includes('github.com')) { mdUrl = mdUrl.replace('github.com', 'raw.githubusercontent.com'); From 455392b9e463e82fbaf397b1d67a3af326142433 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 08:47:33 +0100 Subject: [PATCH 144/459] font --- httpdocs/css/webots-cloud.css | 40 +---------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 1e42d2285..e72eccac7 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -1,38 +1,3 @@ -@font-face { - font-family: "Roboto"; - font-style: normal; - font-weight: 400; - src: url("https://raw.githubusercontent.com/cyberbotics/webots/released/docs/css/fonts/Roboto-Regular.ttf") format("truetype"); -} - -@font-face { - font-family: "Roboto"; - font-style: italic; - font-weight: 400; - src: url("https://raw.githubusercontent.com/cyberbotics/webots/released/docs/css/fonts/Roboto-Italic.ttf") format("truetype"); -} - -@font-face { - font-family: "Roboto"; - font-style: normal; - font-weight: 700; - src: url("https://raw.githubusercontent.com/cyberbotics/webots/released/docs/css/fonts/Roboto-Bold.ttf") format("truetype"); -} - -@font-face { - font-family: "Roboto"; - font-style: italic; - font-weight: 700; - src: url("https://raw.githubusercontent.com/cyberbotics/webots/released/docs/css/fonts/Roboto-BoldItalic.ttf") format("truetype"); -} - -@font-face { - font-family: "Roboto Mono"; - font-style: normal; - src: url("https://raw.githubusercontent.com/cyberbotics/webots/released/docs/css/fonts/Roboto-Mono.ttf") format("truetype"); -} - - html { height: 100%; overflow-y: auto; @@ -451,7 +416,6 @@ nav.pagination > a[disabled] { } .proto-doc p { - font-family: "Roboto"; color: black; margin-left: 10px; margin-right: 10px; @@ -498,10 +462,9 @@ nav.pagination > a[disabled] { } .proto-doc h1, .proto-doc h2, .proto-doc h3, .proto-doc h4, .proto-doc h5, .proto-doc h6 { - font-family: 'Roboto'; font-style: normal; font-weight: normal; - color: #0e6f8c; + color: #007acc; clear: both; margin: 20px auto; word-wrap: break-word; @@ -537,7 +500,6 @@ nav.pagination > a[disabled] { border-radius: 4px; white-space: normal; font-size: 15px; - font-family: "Roboto Mono", monospace; word-wrap: break-word; } From 9f7c1fd87b6155be09e294ac67103fb6070002dd Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 08:58:03 +0100 Subject: [PATCH 145/459] hyperlink color --- httpdocs/css/webots-cloud.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index e72eccac7..f36abbd2c 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -513,3 +513,7 @@ nav.pagination > a[disabled] { margin: 30px auto; display: block; } + +proto-doc a { + color: #007acc; +} From cc3a6ae482230ad31d07c457b210ddb1ffa2ada0 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 09:00:19 +0100 Subject: [PATCH 146/459] redirect --- httpdocs/js/webots-cloud.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 2655766fc..90afbe632 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1538,9 +1538,9 @@ document.addEventListener('DOMContentLoaded', function() { } function loadMd(url) { - const prefix = url.substr(0, url.lastIndexOf('/') + 1); + const prefix = url.substr(0, url.lastIndexOf('/') + 1) + 'docs/'; const protoName = url.substr(url.lastIndexOf('/') + 1).replace('.proto', ''); - let mdUrl = prefix + 'docs/' + protoName.toLowerCase() + '.md'; + let mdUrl = prefix + protoName.toLowerCase() + '.md'; if (mdUrl.includes('github.com')) { mdUrl = mdUrl.replace('github.com', 'raw.githubusercontent.com'); mdUrl = mdUrl.replace('blob/', ''); From 2683725b74710dc6d4aa8d4a34742118b4ff859a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 09:02:27 +0100 Subject: [PATCH 147/459] raw --- httpdocs/js/webots-cloud.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 90afbe632..9932f17f4 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -894,7 +894,7 @@ document.addEventListener('DOMContentLoaded', function() { script = 'ajax/proto/create.php'; typeName = 'proto'; } else { - typeName = document.location.pathname.substring(1); // either 'simulation' or 'competition' + typeName = document.location.pathname.substring(1); // either 'simulation' or 'competition' searchString = getSearch(typeName); script = 'ajax/project/create.php'; } @@ -1538,13 +1538,13 @@ document.addEventListener('DOMContentLoaded', function() { } function loadMd(url) { + if (url.includes('github.com')) { + url = url.replace('github.com', 'raw.githubusercontent.com'); + url = url.replace('blob/', ''); + } const prefix = url.substr(0, url.lastIndexOf('/') + 1) + 'docs/'; const protoName = url.substr(url.lastIndexOf('/') + 1).replace('.proto', ''); - let mdUrl = prefix + protoName.toLowerCase() + '.md'; - if (mdUrl.includes('github.com')) { - mdUrl = mdUrl.replace('github.com', 'raw.githubusercontent.com'); - mdUrl = mdUrl.replace('blob/', ''); - } + const mdUrl = prefix + protoName.toLowerCase() + '.md'; fetch(mdUrl) .then(response => response.text()) From 8ab4a3b9c08b836a96a665b605ada2dfa41f7f4a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 09:04:59 +0100 Subject: [PATCH 148/459] css --- httpdocs/css/webots-cloud.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index f36abbd2c..b6ead0c15 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -514,6 +514,6 @@ nav.pagination > a[disabled] { display: block; } -proto-doc a { +.proto-doc a { color: #007acc; } From c44390c25487e207c2c0f1212a1246e1e138a5ef Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 09:06:07 +0100 Subject: [PATCH 149/459] hover --- httpdocs/css/webots-cloud.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index b6ead0c15..bdbd9768c 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -517,3 +517,7 @@ nav.pagination > a[disabled] { .proto-doc a { color: #007acc; } + +.proto-doc a:hover { + color: darkblue; +} From 4a97e44907d84da2206bb446991a59eef1f03b76 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 09:11:43 +0100 Subject: [PATCH 150/459] proto position --- httpdocs/js/webots-cloud.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 9932f17f4..c4cd8f65b 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -37,11 +37,11 @@ document.addEventListener('DOMContentLoaded', function() { setup: homePage }, { - url: '/simulation', + url: '/proto', setup: homePage }, { - url: '/proto', + url: '/simulation', setup: homePage }, { @@ -417,14 +417,14 @@ document.addEventListener('DOMContentLoaded', function() {
  • Animation
  • +
  • + Proto +
  • Simulation
  • Competition -
  • - Proto -
  • Server
  • From 3ef4c90218ca5c8167f0a2c4c519346c73d74bdc Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 09:12:36 +0100 Subject: [PATCH 151/459] tab --- httpdocs/js/webots-cloud.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index c4cd8f65b..4725c52ee 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1508,15 +1508,15 @@ document.addEventListener('DOMContentLoaded', function() {
  • Animation
  • +
  • + Proto +
  • Simulation
  • Competition
  • -
  • - Proto -
  • Server
  • @@ -1601,6 +1601,9 @@ document.addEventListener('DOMContentLoaded', function() {
  • Animation
  • +
  • + Proto +
  • Simulation
  • From a5f38a9e55d0072ec0d6e69a4d82f1782437f186 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 09:47:31 +0100 Subject: [PATCH 152/459] print --- httpdocs/js/webots-cloud.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 4725c52ee..4b7844727 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1537,7 +1537,8 @@ document.addEventListener('DOMContentLoaded', function() { loadMd(url); } - function loadMd(url) { + function loadMd(protoUrl) { + let url = protoUrl; if (url.includes('github.com')) { url = url.replace('github.com', 'raw.githubusercontent.com'); url = url.replace('blob/', ''); @@ -1545,22 +1546,26 @@ document.addEventListener('DOMContentLoaded', function() { const prefix = url.substr(0, url.lastIndexOf('/') + 1) + 'docs/'; const protoName = url.substr(url.lastIndexOf('/') + 1).replace('.proto', ''); const mdUrl = prefix + protoName.toLowerCase() + '.md'; - - fetch(mdUrl) - .then(response => response.text()) + fetch(protoUrl).then(response => response.text()) .then(content => { - populateProtoViewDiv(content, prefix); - }).catch(() => { - // No md file, so we read the description from the proto file - fetch(url) + fetch(mdUrl) .then(response => response.text()) .then(content => { - generateMd(content); + let infoArray = createMdFromProto(content); + populateProtoViewDiv(content, prefix, infoArray); + }).catch(() => { + // No md file, so we read the description from the proto file + fetch(url) + .then(response => response.text()) + .then(content => { + createMdFromProto(content, true); + }); }); }); } - function generateMd(proto) { + function generateMd(proto, generateAll) { + console.log(proto) } function mainContainer(project) { From cf5e7045794729b8308144021293e742ce807c18 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 09:48:48 +0100 Subject: [PATCH 153/459] raw --- httpdocs/js/webots-cloud.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 4b7844727..c2ec91e5e 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1537,8 +1537,7 @@ document.addEventListener('DOMContentLoaded', function() { loadMd(url); } - function loadMd(protoUrl) { - let url = protoUrl; + function loadMd(url) { if (url.includes('github.com')) { url = url.replace('github.com', 'raw.githubusercontent.com'); url = url.replace('blob/', ''); @@ -1546,7 +1545,7 @@ document.addEventListener('DOMContentLoaded', function() { const prefix = url.substr(0, url.lastIndexOf('/') + 1) + 'docs/'; const protoName = url.substr(url.lastIndexOf('/') + 1).replace('.proto', ''); const mdUrl = prefix + protoName.toLowerCase() + '.md'; - fetch(protoUrl).then(response => response.text()) + fetch(url).then(response => response.text()) .then(content => { fetch(mdUrl) .then(response => response.text()) From 175e205c3a788243286dbdb58ea9b8017861af4f Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 09:49:10 +0100 Subject: [PATCH 154/459] name --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index c2ec91e5e..80c605cab 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1563,7 +1563,7 @@ document.addEventListener('DOMContentLoaded', function() { }); } - function generateMd(proto, generateAll) { + function createMdFromProto(proto, generateAll) { console.log(proto) } From 2c121242ad25c1c2249e5d65e732a7df7fc6435b Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 09:50:57 +0100 Subject: [PATCH 155/459] protot --- httpdocs/js/webots-cloud.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 80c605cab..4dec7cac6 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1546,18 +1546,18 @@ document.addEventListener('DOMContentLoaded', function() { const protoName = url.substr(url.lastIndexOf('/') + 1).replace('.proto', ''); const mdUrl = prefix + protoName.toLowerCase() + '.md'; fetch(url).then(response => response.text()) - .then(content => { + .then(proto => { fetch(mdUrl) .then(response => response.text()) .then(content => { - let infoArray = createMdFromProto(content); + let infoArray = createMdFromProto(proto); populateProtoViewDiv(content, prefix, infoArray); }).catch(() => { // No md file, so we read the description from the proto file fetch(url) .then(response => response.text()) .then(content => { - createMdFromProto(content, true); + createMdFromProto(proto, true); }); }); }); From 0ab8b4a8690e0f47e22e2dfb4ebb0c702c774c20 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 10:21:55 +0100 Subject: [PATCH 156/459] proto version --- httpdocs/js/webots-cloud.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 4dec7cac6..bd2797d41 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1564,7 +1564,21 @@ document.addEventListener('DOMContentLoaded', function() { } function createMdFromProto(proto, generateAll) { - console.log(proto) + // parse header + let version, license, licenseUrl; + for (const line of proto.split('\n')) { + if (!line.startsWith('#')) + break; + + if (line.startsWith('#VRML_SIM') || line.startsWith('# VRML_SIM')) + version = line.substring(line.indexOf('VRML_SIM')).split(' ')[0]; + else if (line.startsWith('# license')) { + + } else if (line.startsWith('#tags') || line.startsWith('# tags') || line.startsWith('# template language') || + line.startsWith('#template language') || line.startsWith('# documentation url') || + line.startsWith('#documentation url')) + continue; + } } function mainContainer(project) { From a52fb19833b21c199c686400b68e0430750827c6 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 10:24:59 +0100 Subject: [PATCH 157/459] log --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index bd2797d41..49f84b3e1 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1579,6 +1579,7 @@ document.addEventListener('DOMContentLoaded', function() { line.startsWith('#documentation url')) continue; } + console.log(version) } function mainContainer(project) { From ee99392097f6edb396ec5cd03ec46c3e42438cb1 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 10:27:42 +0100 Subject: [PATCH 158/459] index --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 49f84b3e1..bbe75b5e0 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1571,7 +1571,7 @@ document.addEventListener('DOMContentLoaded', function() { break; if (line.startsWith('#VRML_SIM') || line.startsWith('# VRML_SIM')) - version = line.substring(line.indexOf('VRML_SIM')).split(' ')[0]; + version = line.substring(line.indexOf('VRML_SIM') + 8).split(' ')[0]; else if (line.startsWith('# license')) { } else if (line.startsWith('#tags') || line.startsWith('# tags') || line.startsWith('# template language') || From 6572a35ddfccf8be720df7997b270cc7f03a7e9a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 10:31:05 +0100 Subject: [PATCH 159/459] log --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index bbe75b5e0..01f0a7554 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1571,7 +1571,7 @@ document.addEventListener('DOMContentLoaded', function() { break; if (line.startsWith('#VRML_SIM') || line.startsWith('# VRML_SIM')) - version = line.substring(line.indexOf('VRML_SIM') + 8).split(' ')[0]; + version = line.substring(line.indexOf('VRML_SIM') + 9).split(' ')[0]; else if (line.startsWith('# license')) { } else if (line.startsWith('#tags') || line.startsWith('# tags') || line.startsWith('# template language') || From 3a1187227aff6b7cb1c1d94108cab37c19686f53 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 10:37:53 +0100 Subject: [PATCH 160/459] license --- httpdocs/js/webots-cloud.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 01f0a7554..001d07839 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1572,14 +1572,16 @@ document.addEventListener('DOMContentLoaded', function() { if (line.startsWith('#VRML_SIM') || line.startsWith('# VRML_SIM')) version = line.substring(line.indexOf('VRML_SIM') + 9).split(' ')[0]; - else if (line.startsWith('# license')) { - - } else if (line.startsWith('#tags') || line.startsWith('# tags') || line.startsWith('# template language') || - line.startsWith('#template language') || line.startsWith('# documentation url') || - line.startsWith('#documentation url')) + else if (line.startsWith('# license:') || line.startsWith('#license:')) + license = line.substring(line.indexOf('license:') + 9).split(' ')[0]; + else if (line.startsWith('# license url:') || line.startsWith('#license url:')) + licenseUrl = line.substring(line.indexOf('license url:') + 13).split(' ')[0]; + else if (line.startsWith('#tags:') || line.startsWith('# tags:') || line.startsWith('# template language:') || + line.startsWith('#template language:') || line.startsWith('# documentation url:') || + line.startsWith('#documentation url:')) continue; } - console.log(version) + console.log(license + ': ' + licenseUrl) } function mainContainer(project) { From aeb7f7944e9b54223ffab1da4141f06dc542f285 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 10:40:42 +0100 Subject: [PATCH 161/459] license --- httpdocs/js/webots-cloud.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 001d07839..8e2f93e0c 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1573,9 +1573,9 @@ document.addEventListener('DOMContentLoaded', function() { if (line.startsWith('#VRML_SIM') || line.startsWith('# VRML_SIM')) version = line.substring(line.indexOf('VRML_SIM') + 9).split(' ')[0]; else if (line.startsWith('# license:') || line.startsWith('#license:')) - license = line.substring(line.indexOf('license:') + 9).split(' ')[0]; + license = line.substring(line.indexOf('license:') + 9); else if (line.startsWith('# license url:') || line.startsWith('#license url:')) - licenseUrl = line.substring(line.indexOf('license url:') + 13).split(' ')[0]; + licenseUrl = line.substring(line.indexOf('license url:') + 13); else if (line.startsWith('#tags:') || line.startsWith('# tags:') || line.startsWith('# template language:') || line.startsWith('#template language:') || line.startsWith('# documentation url:') || line.startsWith('#documentation url:')) From 6581713f0e352b334f097dd10f5aff93c2f1b4e6 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 11:07:14 +0100 Subject: [PATCH 162/459] insert --- httpdocs/css/webots-cloud.css | 5 ++++ httpdocs/js/webots-cloud.js | 52 ++++++++++++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index bdbd9768c..bd1cf016a 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -521,3 +521,8 @@ nav.pagination > a[disabled] { .proto-doc a:hover { color: darkblue; } + +.proto-info-array { + display: grid; + border: 1px solid black; +} diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 8e2f93e0c..52cf62f82 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1550,20 +1550,20 @@ document.addEventListener('DOMContentLoaded', function() { fetch(mdUrl) .then(response => response.text()) .then(content => { - let infoArray = createMdFromProto(proto); + let infoArray = createMdFromProto(url, proto); populateProtoViewDiv(content, prefix, infoArray); }).catch(() => { // No md file, so we read the description from the proto file fetch(url) .then(response => response.text()) .then(content => { - createMdFromProto(proto, true); + createMdFromProto(url, proto, true); }); }); }); } - function createMdFromProto(proto, generateAll) { + function createMdFromProto(protoURl, proto, generateAll) { // parse header let version, license, licenseUrl; for (const line of proto.split('\n')) { @@ -1580,8 +1580,52 @@ document.addEventListener('DOMContentLoaded', function() { line.startsWith('#template language:') || line.startsWith('# documentation url:') || line.startsWith('#documentation url:')) continue; + + const infoGrid = document.createElement('div'); + infoGrid.className = 'proto-info-array'; + + const versionP = document.createElement('p'); + versionP.textContent = 'Version:'; + versionP.style.gridRow = 1; + versionP.style.gridColumn = 1; + infoGrid.appendChild(versionP); + + const versionContentP = document.createElement('p'); + versionContentP.textContent = version; + versionContentP.style.gridRow = 1; + versionContentP.style.gridColumn = 2; + infoGrid.appendChild(versionContentP); + + const licenseP = document.createElement('p'); + licenseP.textContent = 'License:'; + licenseP.style.gridRow = 2; + licenseP.style.gridColumn = 1; + infoGrid.appendChild(licenseP); + + const licenseContentP = document.createElement('p'); + licenseContentP.textContent = license; + licenseContentP.style.gridRow = 2; + licenseContentP.style.gridColumn = 2; + infoGrid.appendChild(licenseContentP); + + const sourceP = document.createElement('p'); + sourceP.textContent = 'Source:'; + sourceP.style.gridRow = 3; + sourceP.style.gridColumn = 1; + infoGrid.appendChild(sourceP); + + const sourceContentP = document.createElement('p'); + sourceContentP.textContent = licenseUrl; + sourceContentP.style.gridRow = 3; + sourceContentP.style.gridColumn = 2; + infoGrid.appendChild(sourceContentP); + + if (generateAll) { + + } + + return infoGrid; } - console.log(license + ': ' + licenseUrl) } function mainContainer(project) { From bb13f42b7f7c46bf2864a0aa2bfd81700126e818 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 11:19:57 +0100 Subject: [PATCH 163/459] text --- httpdocs/css/webots-cloud.css | 2 ++ httpdocs/js/webots-cloud.js | 1 + 2 files changed, 3 insertions(+) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index bd1cf016a..34683e397 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -525,4 +525,6 @@ nav.pagination > a[disabled] { .proto-info-array { display: grid; border: 1px solid black; + width: max-content; + margin-bottom: 50px; } diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 52cf62f82..ef004e861 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1581,6 +1581,7 @@ document.addEventListener('DOMContentLoaded', function() { line.startsWith('#documentation url:')) continue; + console.log(version) const infoGrid = document.createElement('div'); infoGrid.className = 'proto-info-array'; From 9877ec2480aafe944f6309dc0c0c9c2ffb984ebd Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 11:20:16 +0100 Subject: [PATCH 164/459] license --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index ef004e861..c989089e5 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1581,7 +1581,7 @@ document.addEventListener('DOMContentLoaded', function() { line.startsWith('#documentation url:')) continue; - console.log(version) + console.log(license) const infoGrid = document.createElement('div'); infoGrid.className = 'proto-info-array'; From fe3af7cc856df630dc2c9b4e6937e3904369182f Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 11:21:24 +0100 Subject: [PATCH 165/459] proto --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index c989089e5..359739d78 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1581,7 +1581,7 @@ document.addEventListener('DOMContentLoaded', function() { line.startsWith('#documentation url:')) continue; - console.log(license) + console.log(protoURl) const infoGrid = document.createElement('div'); infoGrid.className = 'proto-info-array'; From dd6621ebda92df0fcd5bbe1667f3463b3fac1553 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 11:22:33 +0100 Subject: [PATCH 166/459] source --- httpdocs/js/webots-cloud.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 359739d78..751f4e04d 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1581,7 +1581,7 @@ document.addEventListener('DOMContentLoaded', function() { line.startsWith('#documentation url:')) continue; - console.log(protoURl) + console.log(proto) const infoGrid = document.createElement('div'); infoGrid.className = 'proto-info-array'; @@ -1616,7 +1616,7 @@ document.addEventListener('DOMContentLoaded', function() { infoGrid.appendChild(sourceP); const sourceContentP = document.createElement('p'); - sourceContentP.textContent = licenseUrl; + sourceContentP.textContent = protoURl; sourceContentP.style.gridRow = 3; sourceContentP.style.gridColumn = 2; infoGrid.appendChild(sourceContentP); From 7cd8e7814eb91ed810398cda831d9ece97b8e2f9 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 11:24:15 +0100 Subject: [PATCH 167/459] a --- httpdocs/js/webots-cloud.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 751f4e04d..10c9ce5ae 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1581,7 +1581,7 @@ document.addEventListener('DOMContentLoaded', function() { line.startsWith('#documentation url:')) continue; - console.log(proto) + console.log(licenseUrl) const infoGrid = document.createElement('div'); infoGrid.className = 'proto-info-array'; @@ -1615,8 +1615,9 @@ document.addEventListener('DOMContentLoaded', function() { sourceP.style.gridColumn = 1; infoGrid.appendChild(sourceP); - const sourceContentP = document.createElement('p'); - sourceContentP.textContent = protoURl; + const sourceContentP = document.createElement('a'); + sourceContentP.href = protoURl; + sourceContentP.target = '_blank'; sourceContentP.style.gridRow = 3; sourceContentP.style.gridColumn = 2; infoGrid.appendChild(sourceContentP); From 2dce226aebb710e92df61310d7df4c95eb87c477 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 11:27:26 +0100 Subject: [PATCH 168/459] href --- httpdocs/js/webots-cloud.js | 93 +++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 10c9ce5ae..01ee73d16 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1580,54 +1580,55 @@ document.addEventListener('DOMContentLoaded', function() { line.startsWith('#template language:') || line.startsWith('# documentation url:') || line.startsWith('#documentation url:')) continue; + } - console.log(licenseUrl) - const infoGrid = document.createElement('div'); - infoGrid.className = 'proto-info-array'; - - const versionP = document.createElement('p'); - versionP.textContent = 'Version:'; - versionP.style.gridRow = 1; - versionP.style.gridColumn = 1; - infoGrid.appendChild(versionP); - - const versionContentP = document.createElement('p'); - versionContentP.textContent = version; - versionContentP.style.gridRow = 1; - versionContentP.style.gridColumn = 2; - infoGrid.appendChild(versionContentP); - - const licenseP = document.createElement('p'); - licenseP.textContent = 'License:'; - licenseP.style.gridRow = 2; - licenseP.style.gridColumn = 1; - infoGrid.appendChild(licenseP); - - const licenseContentP = document.createElement('p'); - licenseContentP.textContent = license; - licenseContentP.style.gridRow = 2; - licenseContentP.style.gridColumn = 2; - infoGrid.appendChild(licenseContentP); - - const sourceP = document.createElement('p'); - sourceP.textContent = 'Source:'; - sourceP.style.gridRow = 3; - sourceP.style.gridColumn = 1; - infoGrid.appendChild(sourceP); - - const sourceContentP = document.createElement('a'); - sourceContentP.href = protoURl; - sourceContentP.target = '_blank'; - sourceContentP.style.gridRow = 3; - sourceContentP.style.gridColumn = 2; - infoGrid.appendChild(sourceContentP); - - if (generateAll) { - - } - - return infoGrid; + const infoGrid = document.createElement('div'); + infoGrid.className = 'proto-info-array'; + + const versionP = document.createElement('p'); + versionP.textContent = 'Version:'; + versionP.style.gridRow = 1; + versionP.style.gridColumn = 1; + infoGrid.appendChild(versionP); + + const versionContentP = document.createElement('p'); + versionContentP.textContent = version; + versionContentP.style.gridRow = 1; + versionContentP.style.gridColumn = 2; + infoGrid.appendChild(versionContentP); + + const licenseP = document.createElement('p'); + licenseP.textContent = 'License:'; + licenseP.style.gridRow = 2; + licenseP.style.gridColumn = 1; + infoGrid.appendChild(licenseP); + + const licenseContentA = document.createElement('a'); + licenseContentA.textContent = license; + licenseContentA.href = licenseUrl; + licenseContentA.target = '_blank'; + licenseContentA.style.gridRow = 2; + licenseContentA.style.gridColumn = 2; + infoGrid.appendChild(licenseContentA); + + const sourceP = document.createElement('p'); + sourceP.textContent = 'Source:'; + sourceP.style.gridRow = 3; + sourceP.style.gridColumn = 1; + infoGrid.appendChild(sourceP); + + const sourceContentA = document.createElement('a'); + sourceContentA.href = protoURl; + sourceContentA.textContent = protoURl; + sourceContentA.target = '_blank'; + sourceContentA.style.gridRow = 3; + sourceContentA.style.gridColumn = 2; + infoGrid.appendChild(sourceContentA); + + if (generateAll) { } + + return infoGrid; } function mainContainer(project) { From 963fcce202ad5fa40abb579f1d22a05a930e9981 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 11:29:12 +0100 Subject: [PATCH 169/459] margin --- httpdocs/css/webots-cloud.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 34683e397..9e6df7561 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -528,3 +528,8 @@ nav.pagination > a[disabled] { width: max-content; margin-bottom: 50px; } + +.proto-info-array a { + margin-left: 10px; + margin-right: 10px; +} From 8599c136a98f20b6a255f75a8adeb099b0d0ce2a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 11:44:52 +0100 Subject: [PATCH 170/459] style --- httpdocs/css/webots-cloud.css | 2 +- httpdocs/js/webots-cloud.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 9e6df7561..ac62c56b3 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -524,7 +524,7 @@ nav.pagination > a[disabled] { .proto-info-array { display: grid; - border: 1px solid black; + border: 1px solid #dbdbdb; width: max-content; margin-bottom: 50px; } diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 01ee73d16..bb3ccd72f 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1601,12 +1601,14 @@ document.addEventListener('DOMContentLoaded', function() { licenseP.textContent = 'License:'; licenseP.style.gridRow = 2; licenseP.style.gridColumn = 1; + licenseP.style.backgroundColor = '#fafafa'; infoGrid.appendChild(licenseP); const licenseContentA = document.createElement('a'); licenseContentA.textContent = license; licenseContentA.href = licenseUrl; licenseContentA.target = '_blank'; + licenseContentA.style.backgroundColor = '#fafafa'; licenseContentA.style.gridRow = 2; licenseContentA.style.gridColumn = 2; infoGrid.appendChild(licenseContentA); From 340ea106ba316058407f3de093d806a4f49e98a7 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 11:47:57 +0100 Subject: [PATCH 171/459] padding --- httpdocs/css/webots-cloud.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index ac62c56b3..dbf9c031e 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -417,8 +417,8 @@ nav.pagination > a[disabled] { .proto-doc p { color: black; - margin-left: 10px; - margin-right: 10px; + padding-left: 10px; + padding-right: 10px; font-size: 16px; text-align: justify; line-height: 140%; @@ -530,6 +530,6 @@ nav.pagination > a[disabled] { } .proto-info-array a { - margin-left: 10px; - margin-right: 10px; + padding-left: 10px; + padding-right: 10px; } From c8c2df713816d1e22db6dc4a0793e430a046811f Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 11:50:15 +0100 Subject: [PATCH 172/459] border --- httpdocs/css/webots-cloud.css | 4 ++++ httpdocs/js/webots-cloud.js | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index dbf9c031e..8c0f598ab 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -533,3 +533,7 @@ nav.pagination > a[disabled] { padding-left: 10px; padding-right: 10px; } + +.info-array-cell { + border-bottom: 1px solid #dbdbdb; +} diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index bb3ccd72f..acb70b23b 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1587,18 +1587,21 @@ document.addEventListener('DOMContentLoaded', function() { const versionP = document.createElement('p'); versionP.textContent = 'Version:'; + versionP.className = 'info-array-cell'; versionP.style.gridRow = 1; versionP.style.gridColumn = 1; infoGrid.appendChild(versionP); const versionContentP = document.createElement('p'); versionContentP.textContent = version; + versionContentP.className = 'info-array-cell'; versionContentP.style.gridRow = 1; versionContentP.style.gridColumn = 2; infoGrid.appendChild(versionContentP); const licenseP = document.createElement('p'); licenseP.textContent = 'License:'; + licenseP.className = 'info-array-cell'; licenseP.style.gridRow = 2; licenseP.style.gridColumn = 1; licenseP.style.backgroundColor = '#fafafa'; @@ -1606,6 +1609,7 @@ document.addEventListener('DOMContentLoaded', function() { const licenseContentA = document.createElement('a'); licenseContentA.textContent = license; + licenseContentA.className = 'info-array-cell'; licenseContentA.href = licenseUrl; licenseContentA.target = '_blank'; licenseContentA.style.backgroundColor = '#fafafa'; @@ -1615,12 +1619,14 @@ document.addEventListener('DOMContentLoaded', function() { const sourceP = document.createElement('p'); sourceP.textContent = 'Source:'; + sourceP.className = 'info-array-cell'; sourceP.style.gridRow = 3; sourceP.style.gridColumn = 1; infoGrid.appendChild(sourceP); const sourceContentA = document.createElement('a'); sourceContentA.href = protoURl; + sourceContentA.className = 'info-array-cell'; sourceContentA.textContent = protoURl; sourceContentA.target = '_blank'; sourceContentA.style.gridRow = 3; From 1153c30baa82f89c0fdf3910ab12792107097bf5 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 11:53:56 +0100 Subject: [PATCH 173/459] border --- httpdocs/css/webots-cloud.css | 14 ++++++++++++++ httpdocs/js/webots-cloud.js | 12 ++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 8c0f598ab..40549f2b0 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -537,3 +537,17 @@ nav.pagination > a[disabled] { .info-array-cell { border-bottom: 1px solid #dbdbdb; } + +.first-row-cell { + border-top: 1px solid #dbdbdb; +} + +.first-column-cell { + border-left: 1px solid #dbdbdb; +} + +.last-column-cell { + border-right: 1px solid #dbdbdb; +} + +. diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index acb70b23b..57b5b5159 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1587,21 +1587,21 @@ document.addEventListener('DOMContentLoaded', function() { const versionP = document.createElement('p'); versionP.textContent = 'Version:'; - versionP.className = 'info-array-cell'; + versionP.className = 'info-array-cell first-column-cell first-row-cell'; versionP.style.gridRow = 1; versionP.style.gridColumn = 1; infoGrid.appendChild(versionP); const versionContentP = document.createElement('p'); versionContentP.textContent = version; - versionContentP.className = 'info-array-cell'; + versionContentP.className = 'info-array-cell last-column-cell first-row-cell'; versionContentP.style.gridRow = 1; versionContentP.style.gridColumn = 2; infoGrid.appendChild(versionContentP); const licenseP = document.createElement('p'); licenseP.textContent = 'License:'; - licenseP.className = 'info-array-cell'; + licenseP.className = 'info-array-cell first-column-cell'; licenseP.style.gridRow = 2; licenseP.style.gridColumn = 1; licenseP.style.backgroundColor = '#fafafa'; @@ -1609,7 +1609,7 @@ document.addEventListener('DOMContentLoaded', function() { const licenseContentA = document.createElement('a'); licenseContentA.textContent = license; - licenseContentA.className = 'info-array-cell'; + licenseContentA.className = 'info-array-cell last-column-cell'; licenseContentA.href = licenseUrl; licenseContentA.target = '_blank'; licenseContentA.style.backgroundColor = '#fafafa'; @@ -1619,14 +1619,14 @@ document.addEventListener('DOMContentLoaded', function() { const sourceP = document.createElement('p'); sourceP.textContent = 'Source:'; - sourceP.className = 'info-array-cell'; + sourceP.className = 'info-array-cell first-column-cell'; sourceP.style.gridRow = 3; sourceP.style.gridColumn = 1; infoGrid.appendChild(sourceP); const sourceContentA = document.createElement('a'); sourceContentA.href = protoURl; - sourceContentA.className = 'info-array-cell'; + sourceContentA.className = 'info-array-cell last-column-cell'; sourceContentA.textContent = protoURl; sourceContentA.target = '_blank'; sourceContentA.style.gridRow = 3; From e4b9c7f76356a7e8c143403188a5aab67405b080 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 11:54:47 +0100 Subject: [PATCH 174/459] width --- httpdocs/css/webots-cloud.css | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 40549f2b0..e18f3dad8 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -525,7 +525,6 @@ nav.pagination > a[disabled] { .proto-info-array { display: grid; border: 1px solid #dbdbdb; - width: max-content; margin-bottom: 50px; } From 40a5dbe28bfc0971050fad759bf98e6f69cdea5b Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 11:56:39 +0100 Subject: [PATCH 175/459] url --- httpdocs/js/webots-cloud.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 57b5b5159..7391f884a 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1538,6 +1538,7 @@ document.addEventListener('DOMContentLoaded', function() { } function loadMd(url) { + let protoURl = url; if (url.includes('github.com')) { url = url.replace('github.com', 'raw.githubusercontent.com'); url = url.replace('blob/', ''); @@ -1550,14 +1551,14 @@ document.addEventListener('DOMContentLoaded', function() { fetch(mdUrl) .then(response => response.text()) .then(content => { - let infoArray = createMdFromProto(url, proto); + let infoArray = createMdFromProto(protoURl, proto); populateProtoViewDiv(content, prefix, infoArray); }).catch(() => { // No md file, so we read the description from the proto file fetch(url) .then(response => response.text()) .then(content => { - createMdFromProto(url, proto, true); + createMdFromProto(protoURl, proto, true); }); }); }); From a5c94d3b1995d77b3532d5aa48d64b12f205fce8 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 12:04:19 +0100 Subject: [PATCH 176/459] css --- httpdocs/css/webots-cloud.css | 1 + httpdocs/js/webots-cloud.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index e18f3dad8..c54e8f926 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -535,6 +535,7 @@ nav.pagination > a[disabled] { .info-array-cell { border-bottom: 1px solid #dbdbdb; + line-height: 50px; } .first-row-cell { diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 7391f884a..c0933782e 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1587,7 +1587,7 @@ document.addEventListener('DOMContentLoaded', function() { infoGrid.className = 'proto-info-array'; const versionP = document.createElement('p'); - versionP.textContent = 'Version:'; + versionP.textContent = 'Version'; versionP.className = 'info-array-cell first-column-cell first-row-cell'; versionP.style.gridRow = 1; versionP.style.gridColumn = 1; @@ -1601,7 +1601,7 @@ document.addEventListener('DOMContentLoaded', function() { infoGrid.appendChild(versionContentP); const licenseP = document.createElement('p'); - licenseP.textContent = 'License:'; + licenseP.textContent = 'License'; licenseP.className = 'info-array-cell first-column-cell'; licenseP.style.gridRow = 2; licenseP.style.gridColumn = 1; @@ -1619,7 +1619,7 @@ document.addEventListener('DOMContentLoaded', function() { infoGrid.appendChild(licenseContentA); const sourceP = document.createElement('p'); - sourceP.textContent = 'Source:'; + sourceP.textContent = 'Source'; sourceP.className = 'info-array-cell first-column-cell'; sourceP.style.gridRow = 3; sourceP.style.gridColumn = 1; From 7a40446357d72db23982ca5910c0de823907c10d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 12:06:07 +0100 Subject: [PATCH 177/459] css scope --- httpdocs/css/webots-cloud.css | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index c54e8f926..bbbdc986e 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -522,31 +522,31 @@ nav.pagination > a[disabled] { color: darkblue; } -.proto-info-array { +.proto-doc .proto-info-array { display: grid; border: 1px solid #dbdbdb; margin-bottom: 50px; } -.proto-info-array a { +.proto-doc .proto-info-array a { padding-left: 10px; padding-right: 10px; } -.info-array-cell { +.proto-doc .proto-info-array .info-array-cell { border-bottom: 1px solid #dbdbdb; line-height: 50px; } -.first-row-cell { +.proto-doc .proto-info-array .first-row-cell { border-top: 1px solid #dbdbdb; } -.first-column-cell { +.proto-doc .proto-info-array .first-column-cell { border-left: 1px solid #dbdbdb; } -.last-column-cell { +.proto-doc .proto-info-array .last-column-cell { border-right: 1px solid #dbdbdb; } From e47d35fb27d4467f1bffd8b5f2af3711a6722084 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 12:10:35 +0100 Subject: [PATCH 178/459] link --- httpdocs/js/webots-cloud.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index c0933782e..99d5a2a32 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1593,12 +1593,14 @@ document.addEventListener('DOMContentLoaded', function() { versionP.style.gridColumn = 1; infoGrid.appendChild(versionP); - const versionContentP = document.createElement('p'); - versionContentP.textContent = version; - versionContentP.className = 'info-array-cell last-column-cell first-row-cell'; - versionContentP.style.gridRow = 1; - versionContentP.style.gridColumn = 2; - infoGrid.appendChild(versionContentP); + const versionContentA = document.createElement('a'); + versionContentA.textContent = version; + versionContentA.href = 'https://github.com/cyberbotics/webots/releases/tag/' + version; + versionContentA.target = '_blank'; + versionContentA.className = 'info-array-cell last-column-cell first-row-cell'; + versionContentA.style.gridRow = 1; + versionContentA.style.gridColumn = 2; + infoGrid.appendChild(versionContentA); const licenseP = document.createElement('p'); licenseP.textContent = 'License'; From a417fdd6f9bdaefb4cf971f2854ec90717436335 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 14:54:09 +0100 Subject: [PATCH 179/459] fields --- httpdocs/js/webots-cloud.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 99d5a2a32..4292249e2 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1564,9 +1564,12 @@ document.addEventListener('DOMContentLoaded', function() { }); } + const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; + const fieldRegex = /\[\n((.*\n)*)\]/ig; function createMdFromProto(protoURl, proto, generateAll) { // parse header let version, license, licenseUrl; + let description = ''; for (const line of proto.split('\n')) { if (!line.startsWith('#')) break; @@ -1581,6 +1584,11 @@ document.addEventListener('DOMContentLoaded', function() { line.startsWith('#template language:') || line.startsWith('# documentation url:') || line.startsWith('#documentation url:')) continue; + else { + let newLine = line.replace('#', '').replace('_', '\\_').trim() + newLine = newLine.replace(urlRegex, url => `[${url}](${url})`); + description += newLine + '\n' + } } const infoGrid = document.createElement('div'); @@ -1637,6 +1645,7 @@ document.addEventListener('DOMContentLoaded', function() { infoGrid.appendChild(sourceContentA); if (generateAll) { + console.log(proto.match(fieldRegex)); } return infoGrid; From c86fb5bcc4c17ceca3b78634ef69ce7e649b7d5d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 14:55:26 +0100 Subject: [PATCH 180/459] log --- httpdocs/js/webots-cloud.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 4292249e2..417590fe2 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1554,6 +1554,7 @@ document.addEventListener('DOMContentLoaded', function() { let infoArray = createMdFromProto(protoURl, proto); populateProtoViewDiv(content, prefix, infoArray); }).catch(() => { + console.log("MD NOT FOUND") // No md file, so we read the description from the proto file fetch(url) .then(response => response.text()) @@ -1566,6 +1567,7 @@ document.addEventListener('DOMContentLoaded', function() { const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; const fieldRegex = /\[\n((.*\n)*)\]/ig; + function createMdFromProto(protoURl, proto, generateAll) { // parse header let version, license, licenseUrl; From f9f27a5dbf7ca45aa04d338d3694b14f519b2c47 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 14:59:16 +0100 Subject: [PATCH 181/459] error --- httpdocs/js/webots-cloud.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 417590fe2..aaa331d91 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1553,9 +1553,9 @@ document.addEventListener('DOMContentLoaded', function() { .then(content => { let infoArray = createMdFromProto(protoURl, proto); populateProtoViewDiv(content, prefix, infoArray); - }).catch(() => { - console.log("MD NOT FOUND") - // No md file, so we read the description from the proto file + }).catch(error => { + console.log("MD NOT FOUND" + error) + // No md file, so we read the description from the proto file fetch(url) .then(response => response.text()) .then(content => { From b425ac5cc76be4e93d2301d5160ddd80b602c4fa Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 15:02:39 +0100 Subject: [PATCH 182/459] log --- httpdocs/js/webots-cloud.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index aaa331d91..3effee705 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1556,11 +1556,11 @@ document.addEventListener('DOMContentLoaded', function() { }).catch(error => { console.log("MD NOT FOUND" + error) // No md file, so we read the description from the proto file - fetch(url) - .then(response => response.text()) - .then(content => { - createMdFromProto(protoURl, proto, true); - }); + // fetch(url) + // .then(response => response.text()) + // .then(content => { + // createMdFromProto(protoURl, proto, true); + // }); }); }); } From 0bb8f147565a3518e63c98d0909f01fa82f28741 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 15:05:39 +0100 Subject: [PATCH 183/459] test --- httpdocs/js/webots-cloud.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 3effee705..ee63a1ad0 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1553,14 +1553,15 @@ document.addEventListener('DOMContentLoaded', function() { .then(content => { let infoArray = createMdFromProto(protoURl, proto); populateProtoViewDiv(content, prefix, infoArray); - }).catch(error => { - console.log("MD NOT FOUND" + error) - // No md file, so we read the description from the proto file - // fetch(url) - // .then(response => response.text()) - // .then(content => { - // createMdFromProto(protoURl, proto, true); - // }); + }); + }) + .catch(error => { + console.log("MD NOT FOUND" + error) + // No md file, so we read the description from the proto file + fetch(url) + .then(response => response.text()) + .then(content => { + // createMdFromProto(protoURl, proto, true); }); }); } From e0dc0f6845d47b8ea41ac460a2fac428d50eca1f Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 15:06:21 +0100 Subject: [PATCH 184/459] catch --- httpdocs/js/webots-cloud.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index ee63a1ad0..418201d29 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1553,15 +1553,14 @@ document.addEventListener('DOMContentLoaded', function() { .then(content => { let infoArray = createMdFromProto(protoURl, proto); populateProtoViewDiv(content, prefix, infoArray); - }); - }) - .catch(error => { - console.log("MD NOT FOUND" + error) - // No md file, so we read the description from the proto file - fetch(url) - .then(response => response.text()) - .then(content => { - // createMdFromProto(protoURl, proto, true); + }).catch((error) => { + console.log("MD NOT FOUND" + error) + // No md file, so we read the description from the proto file + fetch(url) + .then(response => response.text()) + .then(content => { + createMdFromProto(protoURl, proto, true); + }); }); }); } From 2e2fc3bbbb80f1916faccf7d208ad5417347c7be Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 15:06:51 +0100 Subject: [PATCH 185/459] fetch --- httpdocs/js/webots-cloud.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 418201d29..f37fa2d1f 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1548,12 +1548,7 @@ document.addEventListener('DOMContentLoaded', function() { const mdUrl = prefix + protoName.toLowerCase() + '.md'; fetch(url).then(response => response.text()) .then(proto => { - fetch(mdUrl) - .then(response => response.text()) - .then(content => { - let infoArray = createMdFromProto(protoURl, proto); - populateProtoViewDiv(content, prefix, infoArray); - }).catch((error) => { + fetch(mdUrl).catch((error) => { console.log("MD NOT FOUND" + error) // No md file, so we read the description from the proto file fetch(url) From a735ee687d67f5e1187da55402b952072f5299ab Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 15:08:27 +0100 Subject: [PATCH 186/459] debug --- httpdocs/js/webots-cloud.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index f37fa2d1f..fe32c39f0 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1548,15 +1548,20 @@ document.addEventListener('DOMContentLoaded', function() { const mdUrl = prefix + protoName.toLowerCase() + '.md'; fetch(url).then(response => response.text()) .then(proto => { - fetch(mdUrl).catch((error) => { - console.log("MD NOT FOUND" + error) - // No md file, so we read the description from the proto file - fetch(url) - .then(response => response.text()) - .then(content => { - createMdFromProto(protoURl, proto, true); - }); - }); + fetch(mdUrl) + .then(response => response.text()) + .then(content => { + let infoArray = createMdFromProto(protoURl, proto); + populateProtoViewDiv(content, prefix, infoArray); + }).catch((error) => console.log(error))//{ + // console.log("MD NOT FOUND" + error) + // // No md file, so we read the description from the proto file + // fetch(url) + // .then(response => response.text()) + // .then(content => { + // createMdFromProto(protoURl, proto, true); + // }); + // }); }); } From 234aea9d66c23911d148d65a659f41e09715c0d0 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 15:12:03 +0100 Subject: [PATCH 187/459] debug --- httpdocs/js/webots-cloud.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index fe32c39f0..68faaefe5 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1548,20 +1548,21 @@ document.addEventListener('DOMContentLoaded', function() { const mdUrl = prefix + protoName.toLowerCase() + '.md'; fetch(url).then(response => response.text()) .then(proto => { + console.log("dslu") fetch(mdUrl) .then(response => response.text()) .then(content => { let infoArray = createMdFromProto(protoURl, proto); populateProtoViewDiv(content, prefix, infoArray); - }).catch((error) => console.log(error))//{ - // console.log("MD NOT FOUND" + error) - // // No md file, so we read the description from the proto file - // fetch(url) - // .then(response => response.text()) - // .then(content => { - // createMdFromProto(protoURl, proto, true); - // }); - // }); + }).catch((error) => { + console.log("MD NOT FOUND" + error) + // No md file, so we read the description from the proto file + fetch(url) + .then(response => response.text()) + .then(content => { + createMdFromProto(protoURl, proto, true); + }); + }); }); } From ecf7041168fa4db56f55f85d2c5db8fce01adcdf Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 15:12:35 +0100 Subject: [PATCH 188/459] test --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 68faaefe5..da3a60777 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1555,7 +1555,7 @@ document.addEventListener('DOMContentLoaded', function() { let infoArray = createMdFromProto(protoURl, proto); populateProtoViewDiv(content, prefix, infoArray); }).catch((error) => { - console.log("MD NOT FOUND" + error) + console.error("MD NOT FOUND" + error) // No md file, so we read the description from the proto file fetch(url) .then(response => response.text()) From 232b14d1c25094981194bc4650f9b1cd299c3e6d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 15:14:44 +0100 Subject: [PATCH 189/459] catchy --- httpdocs/js/webots-cloud.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index da3a60777..196fa9a31 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1554,7 +1554,7 @@ document.addEventListener('DOMContentLoaded', function() { .then(content => { let infoArray = createMdFromProto(protoURl, proto); populateProtoViewDiv(content, prefix, infoArray); - }).catch((error) => { + }).catch(error => { console.error("MD NOT FOUND" + error) // No md file, so we read the description from the proto file fetch(url) @@ -1563,7 +1563,7 @@ document.addEventListener('DOMContentLoaded', function() { createMdFromProto(protoURl, proto, true); }); }); - }); + }).catch(e => console.log("other catch")); } const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; From c070304d139ec7bea101f897ed1af25da6e92217 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 15:15:39 +0100 Subject: [PATCH 190/459] test --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 196fa9a31..5f9782acd 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1549,7 +1549,7 @@ document.addEventListener('DOMContentLoaded', function() { fetch(url).then(response => response.text()) .then(proto => { console.log("dslu") - fetch(mdUrl) + fetch(mdUrl).catch(e => console.log("BONJOUR")) .then(response => response.text()) .then(content => { let infoArray = createMdFromProto(protoURl, proto); From ae6fa495f9f00531e1dcc538ca3510ae12abb876 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 15:17:08 +0100 Subject: [PATCH 191/459] remove --- httpdocs/js/webots-cloud.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 5f9782acd..18fc263fc 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1548,22 +1548,22 @@ document.addEventListener('DOMContentLoaded', function() { const mdUrl = prefix + protoName.toLowerCase() + '.md'; fetch(url).then(response => response.text()) .then(proto => { - console.log("dslu") - fetch(mdUrl).catch(e => console.log("BONJOUR")) - .then(response => response.text()) - .then(content => { - let infoArray = createMdFromProto(protoURl, proto); - populateProtoViewDiv(content, prefix, infoArray); - }).catch(error => { - console.error("MD NOT FOUND" + error) - // No md file, so we read the description from the proto file - fetch(url) - .then(response => response.text()) - .then(content => { - createMdFromProto(protoURl, proto, true); - }); - }); - }).catch(e => console.log("other catch")); + console.log("bonjour") + // fetch(mdUrl) + // .then(response => response.text()) + // .then(content => { + // let infoArray = createMdFromProto(protoURl, proto); + // populateProtoViewDiv(content, prefix, infoArray); + // }).catch(error => { + // console.error("MD NOT FOUND" + error) + // // No md file, so we read the description from the proto file + // fetch(url) + // .then(response => response.text()) + // .then(content => { + // createMdFromProto(protoURl, proto, true); + // }); + // }); + }); } const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; From f052100fab34673f33250c6bb18c845125e52274 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 15:18:04 +0100 Subject: [PATCH 192/459] fetch --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 18fc263fc..96521d4f7 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1549,6 +1549,7 @@ document.addEventListener('DOMContentLoaded', function() { fetch(url).then(response => response.text()) .then(proto => { console.log("bonjour") + fetch(mdUrl); // fetch(mdUrl) // .then(response => response.text()) // .then(content => { From 83d509ed22f80c2a09f3c2d461b86831a1011588 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 15:18:51 +0100 Subject: [PATCH 193/459] md --- httpdocs/js/webots-cloud.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 96521d4f7..14463c308 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1548,8 +1548,7 @@ document.addEventListener('DOMContentLoaded', function() { const mdUrl = prefix + protoName.toLowerCase() + '.md'; fetch(url).then(response => response.text()) .then(proto => { - console.log("bonjour") - fetch(mdUrl); + console.log("bonjour"); // fetch(mdUrl) // .then(response => response.text()) // .then(content => { From 0bc4c8c60ea18026401455183bdfe64c514c3a08 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 15:19:22 +0100 Subject: [PATCH 194/459] log --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 14463c308..1c1dbd27c 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1549,7 +1549,7 @@ document.addEventListener('DOMContentLoaded', function() { fetch(url).then(response => response.text()) .then(proto => { console.log("bonjour"); - // fetch(mdUrl) + fetch(mdUrl).catch(e => console.log("eee")) // .then(response => response.text()) // .then(content => { // let infoArray = createMdFromProto(protoURl, proto); From b21fd6181b9bd4f2789a6bdcbf0415a7c9d40b62 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 15:20:36 +0100 Subject: [PATCH 195/459] test --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 1c1dbd27c..f03bbbd25 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1549,7 +1549,7 @@ document.addEventListener('DOMContentLoaded', function() { fetch(url).then(response => response.text()) .then(proto => { console.log("bonjour"); - fetch(mdUrl).catch(e => console.log("eee")) + fetch('https://github.com/BenjaminDeleze/sandbox/master/blob/protoExample/protos/docs/officechair.md').catch(e => console.log("eee")) // .then(response => response.text()) // .then(content => { // let infoArray = createMdFromProto(protoURl, proto); From f00e66dffac981536eb6faecc677a5e323e0d690 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 15:21:08 +0100 Subject: [PATCH 196/459] raw --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index f03bbbd25..714853e26 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1549,7 +1549,7 @@ document.addEventListener('DOMContentLoaded', function() { fetch(url).then(response => response.text()) .then(proto => { console.log("bonjour"); - fetch('https://github.com/BenjaminDeleze/sandbox/master/blob/protoExample/protos/docs/officechair.md').catch(e => console.log("eee")) + fetch('https://raw.githubusercontent.com/BenjaminDeleze/sandbox/master/protoExample/protos/docs/officechair.md').catch(e => console.log("eee")) // .then(response => response.text()) // .then(content => { // let infoArray = createMdFromProto(protoURl, proto); From 359cadbd0f03da33ef107e627dd61a927947cfc5 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 15:25:35 +0100 Subject: [PATCH 197/459] 404 --- httpdocs/js/webots-cloud.js | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 714853e26..efb1b8dfd 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1548,21 +1548,24 @@ document.addEventListener('DOMContentLoaded', function() { const mdUrl = prefix + protoName.toLowerCase() + '.md'; fetch(url).then(response => response.text()) .then(proto => { - console.log("bonjour"); - fetch('https://raw.githubusercontent.com/BenjaminDeleze/sandbox/master/protoExample/protos/docs/officechair.md').catch(e => console.log("eee")) - // .then(response => response.text()) - // .then(content => { - // let infoArray = createMdFromProto(protoURl, proto); - // populateProtoViewDiv(content, prefix, infoArray); - // }).catch(error => { - // console.error("MD NOT FOUND" + error) - // // No md file, so we read the description from the proto file - // fetch(url) - // .then(response => response.text()) - // .then(content => { - // createMdFromProto(protoURl, proto, true); - // }); - // }); + fetch(mdUrl) + .then(response => { + if (!response.ok) + throw new Error(''); + response.text(); + }) + .then(content => { + let infoArray = createMdFromProto(protoURl, proto); + populateProtoViewDiv(content, prefix, infoArray); + }).catch(error => { + console.error("MD NOT FOUND" + error) + // No md file, so we read the description from the proto file + fetch(url) + .then(response => response.text()) + .then(content => { + createMdFromProto(protoURl, proto, true); + }); + }); }); } From 15fa3371f36b8833e1f98425709e1f77ec1eab05 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 16:34:15 +0100 Subject: [PATCH 198/459] enum --- httpdocs/js/webots-cloud.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index efb1b8dfd..c05cde760 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1557,8 +1557,7 @@ document.addEventListener('DOMContentLoaded', function() { .then(content => { let infoArray = createMdFromProto(protoURl, proto); populateProtoViewDiv(content, prefix, infoArray); - }).catch(error => { - console.error("MD NOT FOUND" + error) + }).catch(() => { // No md file, so we read the description from the proto file fetch(url) .then(response => response.text()) @@ -1571,6 +1570,7 @@ document.addEventListener('DOMContentLoaded', function() { const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; const fieldRegex = /\[\n((.*\n)*)\]/ig; + const removeEnumRegex = /.*ield\s+([^ ]*?)(\{(?:[^\[\n]*\,?\s?)(? Date: Wed, 11 Jan 2023 16:45:54 +0100 Subject: [PATCH 199/459] match --- httpdocs/js/webots-cloud.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index c05cde760..4fb3d7097 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1651,9 +1651,14 @@ document.addEventListener('DOMContentLoaded', function() { infoGrid.appendChild(sourceContentA); if (generateAll) { - let fields = proto.match(fieldRegex); - fields = fields[0].match(removeEnumRegex); - console.log(fields) + let matches = proto.matchAll(fieldRegex); + for (const match of matches) { + console.log(match[0]) + console.log(match[1]) + break; + } + // fields = fields[0].match(removeEnumRegex); + // console.log(fields) } return infoGrid; From fe8d10391f42c502ee622234fa5cbac1964a5ab3 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 16:51:12 +0100 Subject: [PATCH 200/459] group --- httpdocs/js/webots-cloud.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 4fb3d7097..e1c292cba 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1652,15 +1652,20 @@ document.addEventListener('DOMContentLoaded', function() { if (generateAll) { let matches = proto.matchAll(fieldRegex); + let fieldsDefinition; + let fieldEnumeration = new Map(); for (const match of matches) { - console.log(match[0]) - console.log(match[1]) + fieldsDefinition = match[1]; break; } - // fields = fields[0].match(removeEnumRegex); - // console.log(fields) - } + // remove enumerations + matches = fieldsDefinition.matchAll(removeEnumRegex); + for (const match of matches) { + fieldEnumeration.set(match[4]) = match[2]; + } + } + console.log(fieldEnumeration) return infoGrid; } From 0fd90228b95a33f08f98ffc3525e8fd1b1cee9de Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 16:52:34 +0100 Subject: [PATCH 201/459] rvalue --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index e1c292cba..49391c18f 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1662,7 +1662,7 @@ document.addEventListener('DOMContentLoaded', function() { // remove enumerations matches = fieldsDefinition.matchAll(removeEnumRegex); for (const match of matches) { - fieldEnumeration.set(match[4]) = match[2]; + fieldEnumeration.set(match[4], match[2]); } } console.log(fieldEnumeration) From bed0ae1ff8f322f801aaf49adabdb97e674e8871 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 16:53:12 +0100 Subject: [PATCH 202/459] scop --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 49391c18f..9f018f91c 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1664,8 +1664,8 @@ document.addEventListener('DOMContentLoaded', function() { for (const match of matches) { fieldEnumeration.set(match[4], match[2]); } + console.log(fieldEnumeration) } - console.log(fieldEnumeration) return infoGrid; } From 277c13c45095fcf360ad03870e605fe75d445734 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 16:54:38 +0100 Subject: [PATCH 203/459] try --- httpdocs/js/webots-cloud.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 9f018f91c..d3ff5cbf4 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1662,9 +1662,8 @@ document.addEventListener('DOMContentLoaded', function() { // remove enumerations matches = fieldsDefinition.matchAll(removeEnumRegex); for (const match of matches) { - fieldEnumeration.set(match[4], match[2]); + fieldEnumeration.set(match[4], match[2].substr(1,-1)); } - console.log(fieldEnumeration) } return infoGrid; } From e2807d642dff20345ff206bfb4e8716801a165ba Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 16:55:29 +0100 Subject: [PATCH 204/459] print --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index d3ff5cbf4..9b6956ec2 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1664,6 +1664,7 @@ document.addEventListener('DOMContentLoaded', function() { for (const match of matches) { fieldEnumeration.set(match[4], match[2].substr(1,-1)); } + console.log(fieldEnumeration) } return infoGrid; } From 6fa6b397c2132412daed87afb89d59e57f05242a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 16:57:19 +0100 Subject: [PATCH 205/459] split --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 9b6956ec2..eb0ebdea9 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1662,7 +1662,7 @@ document.addEventListener('DOMContentLoaded', function() { // remove enumerations matches = fieldsDefinition.matchAll(removeEnumRegex); for (const match of matches) { - fieldEnumeration.set(match[4], match[2].substr(1,-1)); + fieldEnumeration.set(match[4], match[2].slice(1,-1).split(',')); } console.log(fieldEnumeration) } From 234443da3fcb017f8291188e86c97ae87462e83a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 17:03:13 +0100 Subject: [PATCH 206/459] remove enum --- httpdocs/js/webots-cloud.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index eb0ebdea9..ccf1a4a1d 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1662,9 +1662,14 @@ document.addEventListener('DOMContentLoaded', function() { // remove enumerations matches = fieldsDefinition.matchAll(removeEnumRegex); for (const match of matches) { - fieldEnumeration.set(match[4], match[2].slice(1,-1).split(',')); + fieldEnumeration.set(match[4], match[2].slice(1, -1).split(',')); + if ('\n' in match[0]) { + const string = ' '.repeat(match[0].index(match[2])); + fieldsDefinition = fieldsDefinition.replace(string + match[4], match[4]); + fieldsDefinition = fieldsDefinition.replace(match[2] + '\n', '') + } } - console.log(fieldEnumeration) + console.log(fieldsDefinition) } return infoGrid; } From ab3d1ab84ff3f7308fa29696f2eb73c86372158f Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 17:03:49 +0100 Subject: [PATCH 207/459] typo --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index ccf1a4a1d..88ed00a69 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1663,7 +1663,7 @@ document.addEventListener('DOMContentLoaded', function() { matches = fieldsDefinition.matchAll(removeEnumRegex); for (const match of matches) { fieldEnumeration.set(match[4], match[2].slice(1, -1).split(',')); - if ('\n' in match[0]) { + if (match[0].contains('\n')) { const string = ' '.repeat(match[0].index(match[2])); fieldsDefinition = fieldsDefinition.replace(string + match[4], match[4]); fieldsDefinition = fieldsDefinition.replace(match[2] + '\n', '') From 8febe5eb8a7b9e35adeb8984cb324a3d2d1ced8d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 17:04:18 +0100 Subject: [PATCH 208/459] include --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 88ed00a69..37faf2b29 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1663,7 +1663,7 @@ document.addEventListener('DOMContentLoaded', function() { matches = fieldsDefinition.matchAll(removeEnumRegex); for (const match of matches) { fieldEnumeration.set(match[4], match[2].slice(1, -1).split(',')); - if (match[0].contains('\n')) { + if (match[0].includes('\n')) { const string = ' '.repeat(match[0].index(match[2])); fieldsDefinition = fieldsDefinition.replace(string + match[4], match[4]); fieldsDefinition = fieldsDefinition.replace(match[2] + '\n', '') From ca359d71b6b383173d23a00e9ade6cb33611a602 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 17:04:52 +0100 Subject: [PATCH 209/459] typo --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 37faf2b29..fcaf8f4f5 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1664,7 +1664,7 @@ document.addEventListener('DOMContentLoaded', function() { for (const match of matches) { fieldEnumeration.set(match[4], match[2].slice(1, -1).split(',')); if (match[0].includes('\n')) { - const string = ' '.repeat(match[0].index(match[2])); + const string = ' '.repeat(match[0].indexOf(match[2])); fieldsDefinition = fieldsDefinition.replace(string + match[4], match[4]); fieldsDefinition = fieldsDefinition.replace(match[2] + '\n', '') } From a858921bd8443e121d0346054398198174ea8648 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 17:08:00 +0100 Subject: [PATCH 210/459] spacing --- httpdocs/js/webots-cloud.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index fcaf8f4f5..4a0832dfd 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1666,7 +1666,11 @@ document.addEventListener('DOMContentLoaded', function() { if (match[0].includes('\n')) { const string = ' '.repeat(match[0].indexOf(match[2])); fieldsDefinition = fieldsDefinition.replace(string + match[4], match[4]); - fieldsDefinition = fieldsDefinition.replace(match[2] + '\n', '') + fieldsDefinition = fieldsDefinition.replace(match[2] + '\n', ''); + if (match[2].length < 40) + fieldsDefinition = fieldsDefinition.replace(match[2], ' '.repeat(match[2].length)); + else + fieldsDefinition = fieldsDefinition.replace(match[2], ''); } } console.log(fieldsDefinition) From 05306d9041b680deb1829e12041ba62210580fe6 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 11 Jan 2023 17:13:27 +0100 Subject: [PATCH 211/459] spacing regex --- httpdocs/js/webots-cloud.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 4a0832dfd..a9bfccb15 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1571,7 +1571,7 @@ document.addEventListener('DOMContentLoaded', function() { const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; const fieldRegex = /\[\n((.*\n)*)\]/ig; const removeEnumRegex = /.*ield\s+([^ ]*?)(\{(?:[^\[\n]*\,?\s?)(? Date: Thu, 12 Jan 2023 10:04:24 +0100 Subject: [PATCH 212/459] fields --- httpdocs/js/webots-cloud.js | 75 +++++++++++++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 7 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index a9bfccb15..d741dc498 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1568,14 +1568,11 @@ document.addEventListener('DOMContentLoaded', function() { }); } - const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; - const fieldRegex = /\[\n((.*\n)*)\]/ig; - const removeEnumRegex = /.*ield\s+([^ ]*?)(\{(?:[^\[\n]*\,?\s?)(? `[${url}](${url})`); - description += newLine + '\n' + description += newLine + '\n'; } } @@ -1651,15 +1648,19 @@ document.addEventListener('DOMContentLoaded', function() { infoGrid.appendChild(sourceContentA); if (generateAll) { + const fieldRegex = /\[\n((.*\n)*)\]/ig; let matches = proto.matchAll(fieldRegex); let fieldsDefinition; - let fieldEnumeration = new Map(); + const fieldEnumeration = new Map(); + const describedField = []; + let fields = ''; for (const match of matches) { fieldsDefinition = match[1]; break; } // remove enumerations + const removeEnumRegex = /.*ield\s+([^ ]*?)(\{(?:[^\[\n]*\,?\s?)(? 0; + if (fieldComment && !isComment) { + // add link to base nodes: + for (const baseNode of baseNodeList) { + if (fieldComment.indexOf(baseNode) !== -1) { + const link = ' [' + baseNode + '](https://cyberbotics.com/doc/reference/' + baseNode.toLowerCase()+')'; + fieldComment.replace(' ' + baseNode, link); + } + } + describedField.push([fieldType, fieldName, fieldComment]); + } + // remove the comment + let fieldString = match[0]; + fieldString = fieldString.replace(removeCommentRegex, ''); + // remove intial '*field' string + fieldString = fieldString.replace(removeInitialFieldRegex, ''); + fieldString = fieldString.replace('webots://', 'https://raw.githubusercontent.com/cyberbotics/webots/released'); + + // remove unwanted spaces between field type and field name (if needed) + if (spacesToRemove > 0) + fieldString = fieldString.replace(fieldType + ' '.repeat(spacesToRemove), fieldType); + + fields += fieldString; + } + } - console.log(fieldsDefinition) + console.log(fields) } return infoGrid; } From 6a46452425e976ed6b8d9ea57ac79f165c865177 Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 10:06:12 +0100 Subject: [PATCH 213/459] length --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index d741dc498..f51fb6953 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1709,7 +1709,7 @@ document.addEventListener('DOMContentLoaded', function() { const fieldName = match[4]; const fieldComment = match[7].trim(); // skip 'Is `NodeType.fieldName`.' descriptions - const isComment = fieldComment.match(isDescriptionRegex).length > 0; + const isComment = fieldComment.match(isDescriptionRegex); if (fieldComment && !isComment) { // add link to base nodes: for (const baseNode of baseNodeList) { From e0c04d1d2042040629ddee63594bfda7260c7acd Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 10:07:10 +0100 Subject: [PATCH 214/459] log --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index f51fb6953..9217f6417 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1703,6 +1703,7 @@ document.addEventListener('DOMContentLoaded', function() { const removeCommentRegex = /\s*(#.*)/ig; const removeInitialFieldRegex = /^\s*.*field\s/ig; for (const match of matches) { + console.log(match[0]) if (!(match[1].includes('hiddenField') || match[1].includes('deprecatedField'))) { const fieldType = match[2]; const spaces = match[3]; From f61d9384aa687851994a08c85dc0093019808a48 Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 10:25:49 +0100 Subject: [PATCH 215/459] log --- httpdocs/js/webots-cloud.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 9217f6417..39da1c9e8 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1703,7 +1703,6 @@ document.addEventListener('DOMContentLoaded', function() { const removeCommentRegex = /\s*(#.*)/ig; const removeInitialFieldRegex = /^\s*.*field\s/ig; for (const match of matches) { - console.log(match[0]) if (!(match[1].includes('hiddenField') || match[1].includes('deprecatedField'))) { const fieldType = match[2]; const spaces = match[3]; @@ -1736,7 +1735,7 @@ document.addEventListener('DOMContentLoaded', function() { } } - console.log(fields) + console.log(fieldsDefinition) } return infoGrid; } From 3db0d7ecb8a9d2b841785a85feef26401a5aa41e Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 10:26:34 +0100 Subject: [PATCH 216/459] log --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 39da1c9e8..abcffae30 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1700,6 +1700,7 @@ document.addEventListener('DOMContentLoaded', function() { 'Material']; matches = fieldsDefinition.matchAll(cleaningRegex); + console.log(matches[0]) const removeCommentRegex = /\s*(#.*)/ig; const removeInitialFieldRegex = /^\s*.*field\s/ig; for (const match of matches) { From 00692ab383e40adcaf14f1713534a0edb12f9919 Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 10:30:29 +0100 Subject: [PATCH 217/459] log --- httpdocs/js/webots-cloud.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index abcffae30..096e32a60 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1699,8 +1699,9 @@ document.addEventListener('DOMContentLoaded', function() { 'LightSensor', 'Gyro', 'Receiver', 'Microphone', 'Solid', 'Billboard', 'Fluid', 'Muscle', 'Group', 'Skin', 'Material']; + //remove enumeration matches = fieldsDefinition.matchAll(cleaningRegex); - console.log(matches[0]) + console.log(matches) const removeCommentRegex = /\s*(#.*)/ig; const removeInitialFieldRegex = /^\s*.*field\s/ig; for (const match of matches) { From cf533283a85edc0aae078a1afaa150fa11ec0214 Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 10:32:29 +0100 Subject: [PATCH 218/459] log --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 096e32a60..8abb67e49 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1701,7 +1701,7 @@ document.addEventListener('DOMContentLoaded', function() { //remove enumeration matches = fieldsDefinition.matchAll(cleaningRegex); - console.log(matches) + console.log(matches.next()) const removeCommentRegex = /\s*(#.*)/ig; const removeInitialFieldRegex = /^\s*.*field\s/ig; for (const match of matches) { From b75b1324d7e7ec03c1c8ca9fc1018c4039ebb1dc Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 10:33:07 +0100 Subject: [PATCH 219/459] log --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 8abb67e49..46201bb21 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1701,7 +1701,7 @@ document.addEventListener('DOMContentLoaded', function() { //remove enumeration matches = fieldsDefinition.matchAll(cleaningRegex); - console.log(matches.next()) + console.log(matches.next().next()) const removeCommentRegex = /\s*(#.*)/ig; const removeInitialFieldRegex = /^\s*.*field\s/ig; for (const match of matches) { From b8765a509510d594c8774992de8f8e12c03583a3 Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 10:33:32 +0100 Subject: [PATCH 220/459] next --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 46201bb21..8a4abb040 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1701,7 +1701,7 @@ document.addEventListener('DOMContentLoaded', function() { //remove enumeration matches = fieldsDefinition.matchAll(cleaningRegex); - console.log(matches.next().next()) + console.log(matches.next().hasNext()) const removeCommentRegex = /\s*(#.*)/ig; const removeInitialFieldRegex = /^\s*.*field\s/ig; for (const match of matches) { From 998038053a7cad035270afffbab9154e2cc38369 Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 10:34:34 +0100 Subject: [PATCH 221/459] array --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 8a4abb040..a914fa409 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1701,7 +1701,7 @@ document.addEventListener('DOMContentLoaded', function() { //remove enumeration matches = fieldsDefinition.matchAll(cleaningRegex); - console.log(matches.next().hasNext()) + console.log([...matches]) const removeCommentRegex = /\s*(#.*)/ig; const removeInitialFieldRegex = /^\s*.*field\s/ig; for (const match of matches) { From a6a575c5f69e8fa7e0d09851025f298dfa7b6efd Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 12:35:23 +0100 Subject: [PATCH 222/459] corrected and complete --- httpdocs/js/localTest.js | 266 ++++++++++++++++++++++++++++++++++++ httpdocs/js/test.html | 18 +++ httpdocs/js/webots-cloud.js | 114 ++++++++++++---- 3 files changed, 370 insertions(+), 28 deletions(-) create mode 100644 httpdocs/js/localTest.js create mode 100644 httpdocs/js/test.html diff --git a/httpdocs/js/localTest.js b/httpdocs/js/localTest.js new file mode 100644 index 000000000..03c5059c6 --- /dev/null +++ b/httpdocs/js/localTest.js @@ -0,0 +1,266 @@ +function loadMd(url) { + let protoURl = url; + if (url.includes('github.com')) { + url = url.replace('github.com', 'raw.githubusercontent.com'); + url = url.replace('blob/', ''); + } + const prefix = url.substr(0, url.lastIndexOf('/') + 1) + 'docs/'; + const protoName = url.substr(url.lastIndexOf('/') + 1).replace('.proto', ''); + const mdUrl = prefix + protoName.toLowerCase() + '.md'; + fetch(url).then(response => response.text()) + .then(proto => { + fetch(mdUrl) + .then(response => { + if (!response.ok) + throw new Error(''); + response.text(); + }) + .then(content => { + let infoArray = createMdFromProto(protoURl, proto); + populateProtoViewDiv(content, prefix, infoArray); + }).catch(() => { + // No md file, so we read the description from the proto file + fetch(url) + .then(response => response.text()) + .then(content => { + createMdFromProto(protoURl, proto, protoName, true); + }); + }); + }); +} + +function createMdFromProto(protoURl, proto, protoName, generateAll) { + // parse header + let version, license, licenseUrl; + let description = ''; + const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; + for (const line of proto.split('\n')) { + if (!line.startsWith('#')) + break; + + if (line.startsWith('#VRML_SIM') || line.startsWith('# VRML_SIM')) + version = line.substring(line.indexOf('VRML_SIM') + 9).split(' ')[0]; + else if (line.startsWith('# license:') || line.startsWith('#license:')) + license = line.substring(line.indexOf('license:') + 9); + else if (line.startsWith('# license url:') || line.startsWith('#license url:')) + licenseUrl = line.substring(line.indexOf('license url:') + 13); + else if (line.startsWith('#tags:') || line.startsWith('# tags:') || line.startsWith('# template language:') || + line.startsWith('#template language:') || line.startsWith('# documentation url:') || + line.startsWith('#documentation url:')) + continue; + else { + let newLine = line.replace('#', '').replace('_', '\\_').trim() + newLine = newLine.replace(urlRegex, url => `[${url}](${url})`); + description += newLine + '\n'; + } + } + + const infoGrid = document.createElement('div'); + infoGrid.className = 'proto-info-array'; + + const versionP = document.createElement('p'); + versionP.textContent = 'Version'; + versionP.className = 'info-array-cell first-column-cell first-row-cell'; + versionP.style.gridRow = 1; + versionP.style.gridColumn = 1; + infoGrid.appendChild(versionP); + + const versionContentA = document.createElement('a'); + versionContentA.textContent = version; + versionContentA.href = 'https://github.com/cyberbotics/webots/releases/tag/' + version; + versionContentA.target = '_blank'; + versionContentA.className = 'info-array-cell last-column-cell first-row-cell'; + versionContentA.style.gridRow = 1; + versionContentA.style.gridColumn = 2; + infoGrid.appendChild(versionContentA); + + const licenseP = document.createElement('p'); + licenseP.textContent = 'License'; + licenseP.className = 'info-array-cell first-column-cell'; + licenseP.style.gridRow = 2; + licenseP.style.gridColumn = 1; + licenseP.style.backgroundColor = '#fafafa'; + infoGrid.appendChild(licenseP); + + const licenseContentA = document.createElement('a'); + licenseContentA.textContent = license; + licenseContentA.className = 'info-array-cell last-column-cell'; + licenseContentA.href = licenseUrl; + licenseContentA.target = '_blank'; + licenseContentA.style.backgroundColor = '#fafafa'; + licenseContentA.style.gridRow = 2; + licenseContentA.style.gridColumn = 2; + infoGrid.appendChild(licenseContentA); + + const sourceP = document.createElement('p'); + sourceP.textContent = 'Source'; + sourceP.className = 'info-array-cell first-column-cell'; + sourceP.style.gridRow = 3; + sourceP.style.gridColumn = 1; + infoGrid.appendChild(sourceP); + + const sourceContentA = document.createElement('a'); + sourceContentA.href = protoURl; + sourceContentA.className = 'info-array-cell last-column-cell'; + sourceContentA.textContent = protoURl; + sourceContentA.target = '_blank'; + sourceContentA.style.gridRow = 3; + sourceContentA.style.gridColumn = 2; + infoGrid.appendChild(sourceContentA); + + if (generateAll) { + const fieldRegex = /\[\n((.*\n)*)\]/mg; + let matches = proto.matchAll(fieldRegex); + let fieldsDefinition; + const fieldEnumeration = new Map(); + const describedField = []; + let fields = ''; + let file = ''; + for (const match of matches) { + fieldsDefinition = match[1]; + break; + } + + // remove enumerations + const removeEnumRegex = /.*ield\s+([^ ]*?)(\{(?:[^\[\n]*\,?\s?)(? 0) + fieldString = fieldString.replace(fieldType + ' '.repeat(spacesToRemove), fieldType); + + fields += fieldString + '\n'; + } + } + fetch('https://cyberbotics.com/wwi/proto/protoVisualizer/temporary-proto-list.xml') + .then(result => result.text()) + .then(content => { + const xml = new window.DOMParser().parseFromString(content, 'text/xml'); + const protos = xml.getElementsByTagName('proto'); + let protoNode; + for (const proto of protos) { + if (proto.getElementsByTagName('name')[0].textContent === protoName) { + protoNode = proto; + break; + } + } + const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; + + file += description + '\n'; + file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + '.\n\n'; + file += '```\n'; + file += protoName + ' {\n'; + file += fields; + file += '}\n'; + file += '```\n\n'; + + if (describedField) { + file += ' ### ' + protoName + ' Field Summary\n\n'; + for (const [fieldType, fieldName, fielDescription] of describedField) { + file += '- ' + fieldName + ' : ' + fielDescription; + const isMFField = fieldType.startsWith('MF'); + if (fieldEnumeration.has(fieldName)) { + const values = fieldEnumeration.get(fieldName); + if (isMFField) + file += ' This field accept a list of '; + else { + if (values.length > 1) + file += ' This field accepts the following values: '; + else + file += ' This field accepts the following value: '; + } + + for (let i = 0; i < values.length; i++) { + const value = values[i].split('{')[0]; // In case of node keep only the type + if (i === values.length - 1) { + if (isMFField) + file += '`' + value.trim() + '` ' + fieldType.replace('MF', '').toLowerCase() + 's.'; + else + file += '`' + value.trim() + '`.'; + } else if (i === values.length - 2) { + if (values.length === 2) + file += '`' + value.trim() + '` and '; + else + file += '`' + value.trim() + '`, and '; + } else + file += '`' + value.trim() + ', '; + } + } + file += '\n\n'; + } + } + console.log(file) + }); + } + return infoGrid; +} + +// loadMd('https://github.com/cyberbotics/webots/blob/released/projects/objects/chairs/protos/OfficeChair.proto') +loadMd('https://github.com/cyberbotics/webots/blob/released/projects/appearances/protos/Grass.proto') \ No newline at end of file diff --git a/httpdocs/js/test.html b/httpdocs/js/test.html new file mode 100644 index 000000000..57ff3ee00 --- /dev/null +++ b/httpdocs/js/test.html @@ -0,0 +1,18 @@ + + + + + + + + + + + diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index a914fa409..5d300d4d2 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1562,13 +1562,13 @@ document.addEventListener('DOMContentLoaded', function() { fetch(url) .then(response => response.text()) .then(content => { - createMdFromProto(protoURl, proto, true); + createMdFromProto(protoURl, proto, protoName, true); }); }); }); } - - function createMdFromProto(protoURl, proto, generateAll) { + + function createMdFromProto(protoURl, proto, protoName, generateAll) { // parse header let version, license, licenseUrl; let description = ''; @@ -1576,7 +1576,7 @@ document.addEventListener('DOMContentLoaded', function() { for (const line of proto.split('\n')) { if (!line.startsWith('#')) break; - + if (line.startsWith('#VRML_SIM') || line.startsWith('# VRML_SIM')) version = line.substring(line.indexOf('VRML_SIM') + 9).split(' ')[0]; else if (line.startsWith('# license:') || line.startsWith('#license:')) @@ -1593,17 +1593,17 @@ document.addEventListener('DOMContentLoaded', function() { description += newLine + '\n'; } } - + const infoGrid = document.createElement('div'); infoGrid.className = 'proto-info-array'; - + const versionP = document.createElement('p'); versionP.textContent = 'Version'; versionP.className = 'info-array-cell first-column-cell first-row-cell'; versionP.style.gridRow = 1; versionP.style.gridColumn = 1; infoGrid.appendChild(versionP); - + const versionContentA = document.createElement('a'); versionContentA.textContent = version; versionContentA.href = 'https://github.com/cyberbotics/webots/releases/tag/' + version; @@ -1612,7 +1612,7 @@ document.addEventListener('DOMContentLoaded', function() { versionContentA.style.gridRow = 1; versionContentA.style.gridColumn = 2; infoGrid.appendChild(versionContentA); - + const licenseP = document.createElement('p'); licenseP.textContent = 'License'; licenseP.className = 'info-array-cell first-column-cell'; @@ -1620,7 +1620,7 @@ document.addEventListener('DOMContentLoaded', function() { licenseP.style.gridColumn = 1; licenseP.style.backgroundColor = '#fafafa'; infoGrid.appendChild(licenseP); - + const licenseContentA = document.createElement('a'); licenseContentA.textContent = license; licenseContentA.className = 'info-array-cell last-column-cell'; @@ -1630,14 +1630,14 @@ document.addEventListener('DOMContentLoaded', function() { licenseContentA.style.gridRow = 2; licenseContentA.style.gridColumn = 2; infoGrid.appendChild(licenseContentA); - + const sourceP = document.createElement('p'); sourceP.textContent = 'Source'; sourceP.className = 'info-array-cell first-column-cell'; sourceP.style.gridRow = 3; sourceP.style.gridColumn = 1; infoGrid.appendChild(sourceP); - + const sourceContentA = document.createElement('a'); sourceContentA.href = protoURl; sourceContentA.className = 'info-array-cell last-column-cell'; @@ -1646,21 +1646,22 @@ document.addEventListener('DOMContentLoaded', function() { sourceContentA.style.gridRow = 3; sourceContentA.style.gridColumn = 2; infoGrid.appendChild(sourceContentA); - + if (generateAll) { - const fieldRegex = /\[\n((.*\n)*)\]/ig; + const fieldRegex = /\[\n((.*\n)*)\]/mg; let matches = proto.matchAll(fieldRegex); let fieldsDefinition; const fieldEnumeration = new Map(); const describedField = []; let fields = ''; + let file = ''; for (const match of matches) { fieldsDefinition = match[1]; break; } - + // remove enumerations - const removeEnumRegex = /.*ield\s+([^ ]*?)(\{(?:[^\[\n]*\,?\s?)(? 0) fieldString = fieldString.replace(fieldType + ' '.repeat(spacesToRemove), fieldType); - fields += fieldString; + fields += fieldString + '\n'; } } + fetch('https://cyberbotics.com/wwi/proto/protoVisualizer/temporary-proto-list.xml') + .then(result => result.text()) + .then(content => { + const xml = new window.DOMParser().parseFromString(content, 'text/xml'); + const protos = xml.getElementsByTagName('proto'); + let protoNode; + for (const proto of protos) { + if (proto.getElementsByTagName('name')[0].textContent === protoName) { + protoNode = proto; + break; + } + } + const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; + + file += description + '\n'; + file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + '.\n\n'; + file += '```\n'; + file += protoName + ' {\n'; + file += fields; + file += '}\n'; + file += '```\n\n'; + + if (describedField) { + file += ' ### ' + protoName + ' Field Summary\n\n'; + for (const [fieldType, fieldName, fielDescription] of describedField) { + file += '- ' + fieldName + ' : ' + fielDescription; + const isMFField = fieldType.startsWith('MF'); + if (fieldEnumeration.has(fieldName)) { + const values = fieldEnumeration.get(fieldName); + if (isMFField) + file += ' This field accept a list of '; + else { + if (values.length > 1) + file += ' This field accepts the following values: '; + else + file += ' This field accepts the following value: '; + } - console.log(fieldsDefinition) + for (let i = 0; i < values.length; i++) { + const value = values[i].split('{')[0]; // In case of node keep only the type + if (i === values.length - 1) { + if (isMFField) + file += '`' + value.trim() + '` ' + fieldType.replace('MF', '').toLowerCase() + 's.'; + else + file += '`' + value.trim() + '`.'; + } else if (i === values.length - 2) { + if (values.length === 2) + file += '`' + value.trim() + '` and '; + else + file += '`' + value.trim() + '`, and '; + } else + file += '`' + value.trim() + ', '; + } + } + file += '\n\n'; + } + } + console.log(file) + }); } return infoGrid; } From d65bd2c4c81f48b59da69463d90e48fce6451017 Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 12:39:47 +0100 Subject: [PATCH 223/459] insert --- httpdocs/js/webots-cloud.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 5d300d4d2..70a6e132e 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1562,13 +1562,13 @@ document.addEventListener('DOMContentLoaded', function() { fetch(url) .then(response => response.text()) .then(content => { - createMdFromProto(protoURl, proto, protoName, true); + createMdFromProto(protoURl, proto, protoName, prefix, true); }); }); }); } - - function createMdFromProto(protoURl, proto, protoName, generateAll) { + + function createMdFromProto(protoURl, proto, protoName, prefix, generateAll) { // parse header let version, license, licenseUrl; let description = ''; @@ -1576,7 +1576,7 @@ document.addEventListener('DOMContentLoaded', function() { for (const line of proto.split('\n')) { if (!line.startsWith('#')) break; - + if (line.startsWith('#VRML_SIM') || line.startsWith('# VRML_SIM')) version = line.substring(line.indexOf('VRML_SIM') + 9).split(' ')[0]; else if (line.startsWith('# license:') || line.startsWith('#license:')) @@ -1593,17 +1593,17 @@ document.addEventListener('DOMContentLoaded', function() { description += newLine + '\n'; } } - + const infoGrid = document.createElement('div'); infoGrid.className = 'proto-info-array'; - + const versionP = document.createElement('p'); versionP.textContent = 'Version'; versionP.className = 'info-array-cell first-column-cell first-row-cell'; versionP.style.gridRow = 1; versionP.style.gridColumn = 1; infoGrid.appendChild(versionP); - + const versionContentA = document.createElement('a'); versionContentA.textContent = version; versionContentA.href = 'https://github.com/cyberbotics/webots/releases/tag/' + version; @@ -1612,7 +1612,7 @@ document.addEventListener('DOMContentLoaded', function() { versionContentA.style.gridRow = 1; versionContentA.style.gridColumn = 2; infoGrid.appendChild(versionContentA); - + const licenseP = document.createElement('p'); licenseP.textContent = 'License'; licenseP.className = 'info-array-cell first-column-cell'; @@ -1620,7 +1620,7 @@ document.addEventListener('DOMContentLoaded', function() { licenseP.style.gridColumn = 1; licenseP.style.backgroundColor = '#fafafa'; infoGrid.appendChild(licenseP); - + const licenseContentA = document.createElement('a'); licenseContentA.textContent = license; licenseContentA.className = 'info-array-cell last-column-cell'; @@ -1630,14 +1630,14 @@ document.addEventListener('DOMContentLoaded', function() { licenseContentA.style.gridRow = 2; licenseContentA.style.gridColumn = 2; infoGrid.appendChild(licenseContentA); - + const sourceP = document.createElement('p'); sourceP.textContent = 'Source'; sourceP.className = 'info-array-cell first-column-cell'; sourceP.style.gridRow = 3; sourceP.style.gridColumn = 1; infoGrid.appendChild(sourceP); - + const sourceContentA = document.createElement('a'); sourceContentA.href = protoURl; sourceContentA.className = 'info-array-cell last-column-cell'; @@ -1646,7 +1646,7 @@ document.addEventListener('DOMContentLoaded', function() { sourceContentA.style.gridRow = 3; sourceContentA.style.gridColumn = 2; infoGrid.appendChild(sourceContentA); - + if (generateAll) { const fieldRegex = /\[\n((.*\n)*)\]/mg; let matches = proto.matchAll(fieldRegex); @@ -1659,7 +1659,7 @@ document.addEventListener('DOMContentLoaded', function() { fieldsDefinition = match[1]; break; } - + // remove enumerations const removeEnumRegex = /.*ield\s+([^ ]*?)(\{(?:[^\[\n]*\,?\s?)(? Date: Thu, 12 Jan 2023 14:00:40 +0100 Subject: [PATCH 224/459] typo --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 70a6e132e..2490f98ce 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1752,7 +1752,7 @@ document.addEventListener('DOMContentLoaded', function() { const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; file += description + '\n'; - file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + '.\n\n'; + file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; file += '```\n'; file += protoName + ' {\n'; file += fields; From b708415e0f408a59a8eff9eaedd654d938994683 Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 14:03:39 +0100 Subject: [PATCH 225/459] style --- httpdocs/js/webots-cloud.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 2490f98ce..ef9a68902 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1751,7 +1751,7 @@ document.addEventListener('DOMContentLoaded', function() { } const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; - file += description + '\n'; + file += description + '\n\n'; file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; file += '```\n'; file += protoName + ' {\n'; @@ -1760,7 +1760,7 @@ document.addEventListener('DOMContentLoaded', function() { file += '```\n\n'; if (describedField) { - file += ' ### ' + protoName + ' Field Summary\n\n'; + file += '### ' + protoName + ' Field Summary\n\n'; for (const [fieldType, fieldName, fielDescription] of describedField) { file += '- ' + fieldName + ' : ' + fielDescription; const isMFField = fieldType.startsWith('MF'); From 86ed107648c7da67407561ed471c23cbd2be945c Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 14:08:40 +0100 Subject: [PATCH 226/459] css --- httpdocs/css/webots-cloud.css | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index bbbdc986e..d18f3988a 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -550,4 +550,12 @@ nav.pagination > a[disabled] { border-right: 1px solid #dbdbdb; } -. +.proto-doc pre { + padding: 20px 10px 20px 40px; + margin: 20px 10px; + background-color: #f1f1f1; + color: #333; + border-radius: 2px; + overflow-x: auto; + font-size: 16px; +} From 3412c4fc62d5530db2e9d0c961ea08af09817f1b Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 15:48:46 +0100 Subject: [PATCH 227/459] update grid creation --- httpdocs/js/webots-cloud.js | 349 +++++++++++++++++++++--------------- 1 file changed, 208 insertions(+), 141 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index ef9a68902..9dc3aff40 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1555,7 +1555,7 @@ document.addEventListener('DOMContentLoaded', function() { response.text(); }) .then(content => { - let infoArray = createMdFromProto(protoURl, proto); + let infoArray = createArrayFromProto(protoURl, proto); populateProtoViewDiv(content, prefix, infoArray); }).catch(() => { // No md file, so we read the description from the proto file @@ -1568,6 +1568,77 @@ document.addEventListener('DOMContentLoaded', function() { }); } + function createArrayFromProto(protoURl, proto, protoName) { + // parse header + let version, license, licenseUrl; + for (const line of proto.split('\n')) { + if (!line.startsWith('#')) + break; + + if (line.startsWith('#VRML_SIM') || line.startsWith('# VRML_SIM')) + version = line.substring(line.indexOf('VRML_SIM') + 9).split(' ')[0]; + else if (line.startsWith('# license:') || line.startsWith('#license:')) + license = line.substring(line.indexOf('license:') + 9); + else if (line.startsWith('# license url:') || line.startsWith('#license url:')) + licenseUrl = line.substring(line.indexOf('license url:') + 13); + } + + const infoGrid = document.createElement('div'); + infoGrid.className = 'proto-info-array'; + + const versionP = document.createElement('p'); + versionP.textContent = 'Version'; + versionP.className = 'info-array-cell first-column-cell first-row-cell'; + versionP.style.gridRow = 1; + versionP.style.gridColumn = 1; + infoGrid.appendChild(versionP); + + const versionContentA = document.createElement('a'); + versionContentA.textContent = version; + versionContentA.href = 'https://github.com/cyberbotics/webots/releases/tag/' + version; + versionContentA.target = '_blank'; + versionContentA.className = 'info-array-cell last-column-cell first-row-cell'; + versionContentA.style.gridRow = 1; + versionContentA.style.gridColumn = 2; + infoGrid.appendChild(versionContentA); + + const licenseP = document.createElement('p'); + licenseP.textContent = 'License'; + licenseP.className = 'info-array-cell first-column-cell'; + licenseP.style.gridRow = 2; + licenseP.style.gridColumn = 1; + licenseP.style.backgroundColor = '#fafafa'; + infoGrid.appendChild(licenseP); + + const licenseContentA = document.createElement('a'); + licenseContentA.textContent = license; + licenseContentA.className = 'info-array-cell last-column-cell'; + licenseContentA.href = licenseUrl; + licenseContentA.target = '_blank'; + licenseContentA.style.backgroundColor = '#fafafa'; + licenseContentA.style.gridRow = 2; + licenseContentA.style.gridColumn = 2; + infoGrid.appendChild(licenseContentA); + + const sourceP = document.createElement('p'); + sourceP.textContent = 'Source'; + sourceP.className = 'info-array-cell first-column-cell'; + sourceP.style.gridRow = 3; + sourceP.style.gridColumn = 1; + infoGrid.appendChild(sourceP); + + const sourceContentA = document.createElement('a'); + sourceContentA.href = protoURl; + sourceContentA.className = 'info-array-cell last-column-cell'; + sourceContentA.textContent = protoURl; + sourceContentA.target = '_blank'; + sourceContentA.style.gridRow = 3; + sourceContentA.style.gridColumn = 2; + infoGrid.appendChild(sourceContentA); + + return infoGrid; + } + function createMdFromProto(protoURl, proto, protoName, prefix, generateAll) { // parse header let version, license, licenseUrl; @@ -1647,158 +1718,154 @@ document.addEventListener('DOMContentLoaded', function() { sourceContentA.style.gridColumn = 2; infoGrid.appendChild(sourceContentA); - if (generateAll) { - const fieldRegex = /\[\n((.*\n)*)\]/mg; - let matches = proto.matchAll(fieldRegex); - let fieldsDefinition; - const fieldEnumeration = new Map(); - const describedField = []; - let fields = ''; - let file = ''; - for (const match of matches) { - fieldsDefinition = match[1]; - break; - } + const fieldRegex = /\[\n((.*\n)*)\]/mg; + let matches = proto.matchAll(fieldRegex); + let fieldsDefinition; + const fieldEnumeration = new Map(); + const describedField = []; + let fields = ''; + let file = ''; + for (const match of matches) { + fieldsDefinition = match[1]; + break; + } - // remove enumerations - const removeEnumRegex = /.*ield\s+([^ ]*?)(\{(?:[^\[\n]*\,?\s?)(? 0) - fieldString = fieldString.replace(fieldType + ' '.repeat(spacesToRemove), fieldType); - - fields += fieldString + '\n'; + describedField.push([fieldType, fieldName, fieldComment]); } + // remove the comment + let fieldString = match[0]; + fieldString = fieldString.replace(removeCommentRegex, ''); + // remove intial '*field' string + fieldString = fieldString.replace(removeInitialFieldRegex, ''); + fieldString = fieldString.replace('webots://', 'https://raw.githubusercontent.com/cyberbotics/webots/released'); + + // remove unwanted spaces between field type and field name (if needed) + if (spacesToRemove > 0) + fieldString = fieldString.replace(fieldType + ' '.repeat(spacesToRemove), fieldType); + + fields += fieldString + '\n'; } - fetch('https://cyberbotics.com/wwi/proto/protoVisualizer/temporary-proto-list.xml') - .then(result => result.text()) - .then(content => { - const xml = new window.DOMParser().parseFromString(content, 'text/xml'); - const protos = xml.getElementsByTagName('proto'); - let protoNode; - for (const proto of protos) { - if (proto.getElementsByTagName('name')[0].textContent === protoName) { - protoNode = proto; - break; - } + } + fetch('https://cyberbotics.com/wwi/proto/protoVisualizer/temporary-proto-list.xml') + .then(result => result.text()) + .then(content => { + const xml = new window.DOMParser().parseFromString(content, 'text/xml'); + const protos = xml.getElementsByTagName('proto'); + let protoNode; + for (const proto of protos) { + if (proto.getElementsByTagName('name')[0].textContent === protoName) { + protoNode = proto; + break; } - const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; - - file += description + '\n\n'; - file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; - file += '```\n'; - file += protoName + ' {\n'; - file += fields; - file += '}\n'; - file += '```\n\n'; - - if (describedField) { - file += '### ' + protoName + ' Field Summary\n\n'; - for (const [fieldType, fieldName, fielDescription] of describedField) { - file += '- ' + fieldName + ' : ' + fielDescription; - const isMFField = fieldType.startsWith('MF'); - if (fieldEnumeration.has(fieldName)) { - const values = fieldEnumeration.get(fieldName); - if (isMFField) - file += ' This field accept a list of '; - else { - if (values.length > 1) - file += ' This field accepts the following values: '; - else - file += ' This field accepts the following value: '; - } + } + const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; + + file += description + '\n\n'; + file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; + file += '```\n'; + file += protoName + ' {\n'; + file += fields; + file += '}\n'; + file += '```\n\n'; + + if (describedField) { + file += '### ' + protoName + ' Field Summary\n\n'; + for (const [fieldType, fieldName, fielDescription] of describedField) { + file += '- ' + fieldName + ' : ' + fielDescription; + const isMFField = fieldType.startsWith('MF'); + if (fieldEnumeration.has(fieldName)) { + const values = fieldEnumeration.get(fieldName); + if (isMFField) + file += ' This field accept a list of '; + else { + if (values.length > 1) + file += ' This field accepts the following values: '; + else + file += ' This field accepts the following value: '; + } - for (let i = 0; i < values.length; i++) { - const value = values[i].split('{')[0]; // In case of node keep only the type - if (i === values.length - 1) { - if (isMFField) - file += '`' + value.trim() + '` ' + fieldType.replace('MF', '').toLowerCase() + 's.'; - else - file += '`' + value.trim() + '`.'; - } else if (i === values.length - 2) { - if (values.length === 2) - file += '`' + value.trim() + '` and '; - else - file += '`' + value.trim() + '`, and '; - } else - file += '`' + value.trim() + ', '; - } + for (let i = 0; i < values.length; i++) { + const value = values[i].split('{')[0]; // In case of node keep only the type + if (i === values.length - 1) { + if (isMFField) + file += '`' + value.trim() + '` ' + fieldType.replace('MF', '').toLowerCase() + 's.'; + else + file += '`' + value.trim() + '`.'; + } else if (i === values.length - 2) { + if (values.length === 2) + file += '`' + value.trim() + '` and '; + else + file += '`' + value.trim() + '`, and '; + } else + file += '`' + value.trim() + ', '; } - file += '\n\n'; } + file += '\n\n'; } - populateProtoViewDiv(file, prefix, infoGrid); - console.log(file) - }); - } - return infoGrid; + } + populateProtoViewDiv(file, prefix, infoGrid); + }); } function mainContainer(project) { From ab03623f2a15b614e37bf35c5248aaae15bee91a Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 15:51:41 +0100 Subject: [PATCH 228/459] debug --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 9dc3aff40..739d9c079 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1556,6 +1556,7 @@ document.addEventListener('DOMContentLoaded', function() { }) .then(content => { let infoArray = createArrayFromProto(protoURl, proto); + console.log(content) populateProtoViewDiv(content, prefix, infoArray); }).catch(() => { // No md file, so we read the description from the proto file From adbab5bca764d765b07609006038d94095f4be34 Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 15:54:02 +0100 Subject: [PATCH 229/459] correct --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 739d9c079..915f6ba67 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1552,7 +1552,7 @@ document.addEventListener('DOMContentLoaded', function() { .then(response => { if (!response.ok) throw new Error(''); - response.text(); + return response.text(); }) .then(content => { let infoArray = createArrayFromProto(protoURl, proto); From 4b107c3df3124e1d6b1436965449e94feec7488b Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 16:24:42 +0100 Subject: [PATCH 230/459] refactor --- httpdocs/js/webots-cloud.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 915f6ba67..3721cbdf5 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1555,8 +1555,8 @@ document.addEventListener('DOMContentLoaded', function() { return response.text(); }) .then(content => { - let infoArray = createArrayFromProto(protoURl, proto); - console.log(content) + let results = parseProtoHeader(proto); + let infoArray = createArrayFromProto(results[0], results[1], results[2], protoURl); populateProtoViewDiv(content, prefix, infoArray); }).catch(() => { // No md file, so we read the description from the proto file @@ -1569,8 +1569,7 @@ document.addEventListener('DOMContentLoaded', function() { }); } - function createArrayFromProto(protoURl, proto, protoName) { - // parse header + function parseProtoHeader(proto) { let version, license, licenseUrl; for (const line of proto.split('\n')) { if (!line.startsWith('#')) @@ -1584,6 +1583,10 @@ document.addEventListener('DOMContentLoaded', function() { licenseUrl = line.substring(line.indexOf('license url:') + 13); } + return [version, license, licenseUrl]; + } + + function createArrayFromProto(version, license, licenseUrl, protoURl) { const infoGrid = document.createElement('div'); infoGrid.className = 'proto-info-array'; From a724c76761f129fa1ef4b1de9f40c6af0141e5ce Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 16:40:02 +0100 Subject: [PATCH 231/459] simplify --- httpdocs/js/webots-cloud.js | 100 +++++++----------------------------- 1 file changed, 18 insertions(+), 82 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 3721cbdf5..6250f9fd9 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1556,7 +1556,7 @@ document.addEventListener('DOMContentLoaded', function() { }) .then(content => { let results = parseProtoHeader(proto); - let infoArray = createArrayFromProto(results[0], results[1], results[2], protoURl); + let infoArray = createProtoArray(results[0], results[1], results[2], protoURl); populateProtoViewDiv(content, prefix, infoArray); }).catch(() => { // No md file, so we read the description from the proto file @@ -1586,7 +1586,7 @@ document.addEventListener('DOMContentLoaded', function() { return [version, license, licenseUrl]; } - function createArrayFromProto(version, license, licenseUrl, protoURl) { + function createProtoArray(version, license, licenseUrl, protoURl) { const infoGrid = document.createElement('div'); infoGrid.className = 'proto-info-array'; @@ -1644,84 +1644,6 @@ document.addEventListener('DOMContentLoaded', function() { } function createMdFromProto(protoURl, proto, protoName, prefix, generateAll) { - // parse header - let version, license, licenseUrl; - let description = ''; - const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; - for (const line of proto.split('\n')) { - if (!line.startsWith('#')) - break; - - if (line.startsWith('#VRML_SIM') || line.startsWith('# VRML_SIM')) - version = line.substring(line.indexOf('VRML_SIM') + 9).split(' ')[0]; - else if (line.startsWith('# license:') || line.startsWith('#license:')) - license = line.substring(line.indexOf('license:') + 9); - else if (line.startsWith('# license url:') || line.startsWith('#license url:')) - licenseUrl = line.substring(line.indexOf('license url:') + 13); - else if (line.startsWith('#tags:') || line.startsWith('# tags:') || line.startsWith('# template language:') || - line.startsWith('#template language:') || line.startsWith('# documentation url:') || - line.startsWith('#documentation url:')) - continue; - else { - let newLine = line.replace('#', '').replace('_', '\\_').trim() - newLine = newLine.replace(urlRegex, url => `[${url}](${url})`); - description += newLine + '\n'; - } - } - - const infoGrid = document.createElement('div'); - infoGrid.className = 'proto-info-array'; - - const versionP = document.createElement('p'); - versionP.textContent = 'Version'; - versionP.className = 'info-array-cell first-column-cell first-row-cell'; - versionP.style.gridRow = 1; - versionP.style.gridColumn = 1; - infoGrid.appendChild(versionP); - - const versionContentA = document.createElement('a'); - versionContentA.textContent = version; - versionContentA.href = 'https://github.com/cyberbotics/webots/releases/tag/' + version; - versionContentA.target = '_blank'; - versionContentA.className = 'info-array-cell last-column-cell first-row-cell'; - versionContentA.style.gridRow = 1; - versionContentA.style.gridColumn = 2; - infoGrid.appendChild(versionContentA); - - const licenseP = document.createElement('p'); - licenseP.textContent = 'License'; - licenseP.className = 'info-array-cell first-column-cell'; - licenseP.style.gridRow = 2; - licenseP.style.gridColumn = 1; - licenseP.style.backgroundColor = '#fafafa'; - infoGrid.appendChild(licenseP); - - const licenseContentA = document.createElement('a'); - licenseContentA.textContent = license; - licenseContentA.className = 'info-array-cell last-column-cell'; - licenseContentA.href = licenseUrl; - licenseContentA.target = '_blank'; - licenseContentA.style.backgroundColor = '#fafafa'; - licenseContentA.style.gridRow = 2; - licenseContentA.style.gridColumn = 2; - infoGrid.appendChild(licenseContentA); - - const sourceP = document.createElement('p'); - sourceP.textContent = 'Source'; - sourceP.className = 'info-array-cell first-column-cell'; - sourceP.style.gridRow = 3; - sourceP.style.gridColumn = 1; - infoGrid.appendChild(sourceP); - - const sourceContentA = document.createElement('a'); - sourceContentA.href = protoURl; - sourceContentA.className = 'info-array-cell last-column-cell'; - sourceContentA.textContent = protoURl; - sourceContentA.target = '_blank'; - sourceContentA.style.gridRow = 3; - sourceContentA.style.gridColumn = 2; - infoGrid.appendChild(sourceContentA); - const fieldRegex = /\[\n((.*\n)*)\]/mg; let matches = proto.matchAll(fieldRegex); let fieldsDefinition; @@ -1823,8 +1745,12 @@ document.addEventListener('DOMContentLoaded', function() { break; } } - const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; + if (!protoNode) + return; + + const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; + const description = protoNode.getElementsByTagName('description')[0].textContent; file += description + '\n\n'; file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; file += '```\n'; @@ -1868,7 +1794,17 @@ document.addEventListener('DOMContentLoaded', function() { file += '\n\n'; } } - populateProtoViewDiv(file, prefix, infoGrid); + + const license = protoNode.getElementsByTagName('license')[0].textContent; + const licenseUrl = protoNode.getElementsByTagName('license-url')[0].textContent; + let version; + for (const line of proto.split('\n')) { + if (line.startsWith('#VRML_SIM') || line.startsWith('# VRML_SIM')) { + version = line.substring(line.indexOf('VRML_SIM') + 9).split(' ')[0]; + break; + } + } + populateProtoViewDiv(file, prefix, createProtoArray(version, license, licenseUrl, protoURl)); }); } From 97bb88ab1ca763c62734a99db1a6c95ffabc922e Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 16:57:27 +0100 Subject: [PATCH 232/459] style --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 6250f9fd9..d0d1527fd 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1760,7 +1760,7 @@ document.addEventListener('DOMContentLoaded', function() { file += '```\n\n'; if (describedField) { - file += '### ' + protoName + ' Field Summary\n\n'; + file += '### `' + protoName + '` Field Summary\n\n'; for (const [fieldType, fieldName, fielDescription] of describedField) { file += '- ' + fieldName + ' : ' + fielDescription; const isMFField = fieldType.startsWith('MF'); From 639fd5aa6ca26bc4f155ed132553d0e8bc42717c Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 12 Jan 2023 17:02:10 +0100 Subject: [PATCH 233/459] typo --- httpdocs/js/webots-cloud.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index d0d1527fd..b176b081e 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1760,9 +1760,9 @@ document.addEventListener('DOMContentLoaded', function() { file += '```\n\n'; if (describedField) { - file += '### `' + protoName + '` Field Summary\n\n'; + file += '### ' + protoName + ' Field Summary\n\n'; for (const [fieldType, fieldName, fielDescription] of describedField) { - file += '- ' + fieldName + ' : ' + fielDescription; + file += '- `' + fieldName + '` : ' + fielDescription; const isMFField = fieldType.startsWith('MF'); if (fieldEnumeration.has(fieldName)) { const values = fieldEnumeration.get(fieldName); From ba33fb4b58a38e1a301a22a58fd1f0bf9e90d2e8 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 07:59:43 +0100 Subject: [PATCH 234/459] \n --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index b176b081e..1e0180c63 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1751,7 +1751,7 @@ document.addEventListener('DOMContentLoaded', function() { const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; const description = protoNode.getElementsByTagName('description')[0].textContent; - file += description + '\n\n'; + file += description + '\n'; file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; file += '```\n'; file += protoName + ' {\n'; From 0f31aa83e1a23961e8186ecb61b9f098e67f2bbd Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 08:00:24 +0100 Subject: [PATCH 235/459] innertext --- httpdocs/js/webots-cloud.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 1e0180c63..4dee0f73a 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1750,8 +1750,8 @@ document.addEventListener('DOMContentLoaded', function() { return; const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; - const description = protoNode.getElementsByTagName('description')[0].textContent; - file += description + '\n'; + const description = protoNode.getElementsByTagName('description')[0].innerHTML; + file += description + '\n\n'; file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; file += '```\n'; file += protoName + ' {\n'; From 5f7c5beab69efb64a2741adb68a23047ad460212 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 08:01:16 +0100 Subject: [PATCH 236/459] innertext --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 4dee0f73a..daa8e183a 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1750,7 +1750,7 @@ document.addEventListener('DOMContentLoaded', function() { return; const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; - const description = protoNode.getElementsByTagName('description')[0].innerHTML; + const description = protoNode.getElementsByTagName('description')[0].innerText; file += description + '\n\n'; file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; file += '```\n'; From 4efd09222d087a203b948c5e3440130b111e44b0 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 08:05:31 +0100 Subject: [PATCH 237/459] test --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index daa8e183a..448051867 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1750,7 +1750,7 @@ document.addEventListener('DOMContentLoaded', function() { return; const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; - const description = protoNode.getElementsByTagName('description')[0].innerText; + const description = protoNode.getElementsByTagName('description')[0].textContent.replace('\n', '
    '); file += description + '\n\n'; file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; file += '```\n'; From e6a0781757200f75873cf25876d6f1ec32fc812a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 08:06:22 +0100 Subject: [PATCH 238/459] description --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 448051867..9edfab78b 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1751,6 +1751,7 @@ document.addEventListener('DOMContentLoaded', function() { const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; const description = protoNode.getElementsByTagName('description')[0].textContent.replace('\n', '
    '); + console.log(description) file += description + '\n\n'; file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; file += '```\n'; From 32555ee71dc8b2405d0b2902019095767fbf9221 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 08:06:56 +0100 Subject: [PATCH 239/459] test --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 9edfab78b..d75b897c0 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1750,7 +1750,7 @@ document.addEventListener('DOMContentLoaded', function() { return; const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; - const description = protoNode.getElementsByTagName('description')[0].textContent.replace('\n', '
    '); + const description = protoNode.getElementsByTagName('description')[0].textContent.replace('\\n', '
    '); console.log(description) file += description + '\n\n'; file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; From 17f486dae576241eadc3ec520adfe6b18eb513ce Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 08:13:53 +0100 Subject: [PATCH 240/459] test --- httpdocs/js/webots-cloud.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index d75b897c0..90915c3a5 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1750,8 +1750,7 @@ document.addEventListener('DOMContentLoaded', function() { return; const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; - const description = protoNode.getElementsByTagName('description')[0].textContent.replace('\\n', '
    '); - console.log(description) + const description = protoNode.getElementsByTagName('description')[0].innerHTML.replace('\\n', '
    '); file += description + '\n\n'; file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; file += '```\n'; From 7c60cd590c5dbbed89d591b6ac6484096678b05a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 08:15:11 +0100 Subject: [PATCH 241/459] test --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 90915c3a5..0a9911e6d 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1750,7 +1750,7 @@ document.addEventListener('DOMContentLoaded', function() { return; const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; - const description = protoNode.getElementsByTagName('description')[0].innerHTML.replace('\\n', '
    '); + const description = protoNode.getElementsByTagName('description')[0].textContent.replace('\\n', ''); file += description + '\n\n'; file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; file += '```\n'; From ba78e81ee9a588446de48876070b31154504494c Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 08:56:12 +0100 Subject: [PATCH 242/459] indent --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 0a9911e6d..951b2d612 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1755,7 +1755,7 @@ document.addEventListener('DOMContentLoaded', function() { file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; file += '```\n'; file += protoName + ' {\n'; - file += fields; + file += ' ' + fields; file += '}\n'; file += '```\n\n'; From 0cd13d54be62bf352d14b11e56f66f8a64aba38c Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 08:57:45 +0100 Subject: [PATCH 243/459] indent --- httpdocs/js/webots-cloud.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 951b2d612..21147334a 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1723,7 +1723,7 @@ document.addEventListener('DOMContentLoaded', function() { let fieldString = match[0]; fieldString = fieldString.replace(removeCommentRegex, ''); // remove intial '*field' string - fieldString = fieldString.replace(removeInitialFieldRegex, ''); + fieldString = fieldString.replace(removeInitialFieldRegex, ' '); fieldString = fieldString.replace('webots://', 'https://raw.githubusercontent.com/cyberbotics/webots/released'); // remove unwanted spaces between field type and field name (if needed) @@ -1755,7 +1755,7 @@ document.addEventListener('DOMContentLoaded', function() { file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; file += '```\n'; file += protoName + ' {\n'; - file += ' ' + fields; + file += fields; file += '}\n'; file += '```\n\n'; From f6c916b589847f2f66f29635314cf4c98815ffb4 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 09:04:20 +0100 Subject: [PATCH 244/459] cleanup --- httpdocs/js/localTest.js | 266 --------------------------------------- httpdocs/js/test.html | 18 --- 2 files changed, 284 deletions(-) delete mode 100644 httpdocs/js/localTest.js delete mode 100644 httpdocs/js/test.html diff --git a/httpdocs/js/localTest.js b/httpdocs/js/localTest.js deleted file mode 100644 index 03c5059c6..000000000 --- a/httpdocs/js/localTest.js +++ /dev/null @@ -1,266 +0,0 @@ -function loadMd(url) { - let protoURl = url; - if (url.includes('github.com')) { - url = url.replace('github.com', 'raw.githubusercontent.com'); - url = url.replace('blob/', ''); - } - const prefix = url.substr(0, url.lastIndexOf('/') + 1) + 'docs/'; - const protoName = url.substr(url.lastIndexOf('/') + 1).replace('.proto', ''); - const mdUrl = prefix + protoName.toLowerCase() + '.md'; - fetch(url).then(response => response.text()) - .then(proto => { - fetch(mdUrl) - .then(response => { - if (!response.ok) - throw new Error(''); - response.text(); - }) - .then(content => { - let infoArray = createMdFromProto(protoURl, proto); - populateProtoViewDiv(content, prefix, infoArray); - }).catch(() => { - // No md file, so we read the description from the proto file - fetch(url) - .then(response => response.text()) - .then(content => { - createMdFromProto(protoURl, proto, protoName, true); - }); - }); - }); -} - -function createMdFromProto(protoURl, proto, protoName, generateAll) { - // parse header - let version, license, licenseUrl; - let description = ''; - const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; - for (const line of proto.split('\n')) { - if (!line.startsWith('#')) - break; - - if (line.startsWith('#VRML_SIM') || line.startsWith('# VRML_SIM')) - version = line.substring(line.indexOf('VRML_SIM') + 9).split(' ')[0]; - else if (line.startsWith('# license:') || line.startsWith('#license:')) - license = line.substring(line.indexOf('license:') + 9); - else if (line.startsWith('# license url:') || line.startsWith('#license url:')) - licenseUrl = line.substring(line.indexOf('license url:') + 13); - else if (line.startsWith('#tags:') || line.startsWith('# tags:') || line.startsWith('# template language:') || - line.startsWith('#template language:') || line.startsWith('# documentation url:') || - line.startsWith('#documentation url:')) - continue; - else { - let newLine = line.replace('#', '').replace('_', '\\_').trim() - newLine = newLine.replace(urlRegex, url => `[${url}](${url})`); - description += newLine + '\n'; - } - } - - const infoGrid = document.createElement('div'); - infoGrid.className = 'proto-info-array'; - - const versionP = document.createElement('p'); - versionP.textContent = 'Version'; - versionP.className = 'info-array-cell first-column-cell first-row-cell'; - versionP.style.gridRow = 1; - versionP.style.gridColumn = 1; - infoGrid.appendChild(versionP); - - const versionContentA = document.createElement('a'); - versionContentA.textContent = version; - versionContentA.href = 'https://github.com/cyberbotics/webots/releases/tag/' + version; - versionContentA.target = '_blank'; - versionContentA.className = 'info-array-cell last-column-cell first-row-cell'; - versionContentA.style.gridRow = 1; - versionContentA.style.gridColumn = 2; - infoGrid.appendChild(versionContentA); - - const licenseP = document.createElement('p'); - licenseP.textContent = 'License'; - licenseP.className = 'info-array-cell first-column-cell'; - licenseP.style.gridRow = 2; - licenseP.style.gridColumn = 1; - licenseP.style.backgroundColor = '#fafafa'; - infoGrid.appendChild(licenseP); - - const licenseContentA = document.createElement('a'); - licenseContentA.textContent = license; - licenseContentA.className = 'info-array-cell last-column-cell'; - licenseContentA.href = licenseUrl; - licenseContentA.target = '_blank'; - licenseContentA.style.backgroundColor = '#fafafa'; - licenseContentA.style.gridRow = 2; - licenseContentA.style.gridColumn = 2; - infoGrid.appendChild(licenseContentA); - - const sourceP = document.createElement('p'); - sourceP.textContent = 'Source'; - sourceP.className = 'info-array-cell first-column-cell'; - sourceP.style.gridRow = 3; - sourceP.style.gridColumn = 1; - infoGrid.appendChild(sourceP); - - const sourceContentA = document.createElement('a'); - sourceContentA.href = protoURl; - sourceContentA.className = 'info-array-cell last-column-cell'; - sourceContentA.textContent = protoURl; - sourceContentA.target = '_blank'; - sourceContentA.style.gridRow = 3; - sourceContentA.style.gridColumn = 2; - infoGrid.appendChild(sourceContentA); - - if (generateAll) { - const fieldRegex = /\[\n((.*\n)*)\]/mg; - let matches = proto.matchAll(fieldRegex); - let fieldsDefinition; - const fieldEnumeration = new Map(); - const describedField = []; - let fields = ''; - let file = ''; - for (const match of matches) { - fieldsDefinition = match[1]; - break; - } - - // remove enumerations - const removeEnumRegex = /.*ield\s+([^ ]*?)(\{(?:[^\[\n]*\,?\s?)(? 0) - fieldString = fieldString.replace(fieldType + ' '.repeat(spacesToRemove), fieldType); - - fields += fieldString + '\n'; - } - } - fetch('https://cyberbotics.com/wwi/proto/protoVisualizer/temporary-proto-list.xml') - .then(result => result.text()) - .then(content => { - const xml = new window.DOMParser().parseFromString(content, 'text/xml'); - const protos = xml.getElementsByTagName('proto'); - let protoNode; - for (const proto of protos) { - if (proto.getElementsByTagName('name')[0].textContent === protoName) { - protoNode = proto; - break; - } - } - const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; - - file += description + '\n'; - file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + '.\n\n'; - file += '```\n'; - file += protoName + ' {\n'; - file += fields; - file += '}\n'; - file += '```\n\n'; - - if (describedField) { - file += ' ### ' + protoName + ' Field Summary\n\n'; - for (const [fieldType, fieldName, fielDescription] of describedField) { - file += '- ' + fieldName + ' : ' + fielDescription; - const isMFField = fieldType.startsWith('MF'); - if (fieldEnumeration.has(fieldName)) { - const values = fieldEnumeration.get(fieldName); - if (isMFField) - file += ' This field accept a list of '; - else { - if (values.length > 1) - file += ' This field accepts the following values: '; - else - file += ' This field accepts the following value: '; - } - - for (let i = 0; i < values.length; i++) { - const value = values[i].split('{')[0]; // In case of node keep only the type - if (i === values.length - 1) { - if (isMFField) - file += '`' + value.trim() + '` ' + fieldType.replace('MF', '').toLowerCase() + 's.'; - else - file += '`' + value.trim() + '`.'; - } else if (i === values.length - 2) { - if (values.length === 2) - file += '`' + value.trim() + '` and '; - else - file += '`' + value.trim() + '`, and '; - } else - file += '`' + value.trim() + ', '; - } - } - file += '\n\n'; - } - } - console.log(file) - }); - } - return infoGrid; -} - -// loadMd('https://github.com/cyberbotics/webots/blob/released/projects/objects/chairs/protos/OfficeChair.proto') -loadMd('https://github.com/cyberbotics/webots/blob/released/projects/appearances/protos/Grass.proto') \ No newline at end of file diff --git a/httpdocs/js/test.html b/httpdocs/js/test.html deleted file mode 100644 index 57ff3ee00..000000000 --- a/httpdocs/js/test.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - From 5981b98dcbe7167a14b2fbf7bbad5de9854714ab Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 14:36:45 +0100 Subject: [PATCH 245/459] typo --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 21147334a..de5720db5 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1788,7 +1788,7 @@ document.addEventListener('DOMContentLoaded', function() { else file += '`' + value.trim() + '`, and '; } else - file += '`' + value.trim() + ', '; + file += '`' + value.trim() + '`, '; } } file += '\n\n'; From 912f54b7c9bc90a52e47c0acf487a2989fb33cf2 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 15:24:19 +0100 Subject: [PATCH 246/459] clean css --- httpdocs/css/webots-cloud.css | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index d18f3988a..846ffa2b5 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -425,34 +425,6 @@ nav.pagination > a[disabled] { word-wrap: break-word; } -.proto-doc figcaption:hover .anchor-link, -.proto-doc h1:hover .anchor-link, -.proto-doc h2:hover .anchor-link, -.proto-doc h3:hover .anchor-link, -.proto-doc h4:hover .anchor-link, -.proto-doc h5:hover .anchor-link, -.proto-doc h6:hover .anchor-link { - opacity: 1; -} - -.proto-doc .anchor-link-image { - padding-left: 20px; - background: url("https://raw.githubusercontent.com/cyberbotics/webots/released/docs/css/images/anchor.png") left center no-repeat; - background-size: 20px; -} -.proto-doc .anchor-link { - opacity: 0; - \-webkit-transition: opacity 0.2s ease-in-out 0.1s; - \-moz-transition: opacity 0.2s ease-in-out 0.1s; - \-ms-transition: opacity 0.2s ease-in-out 0.1s; -} - -.proto-doc .anchor-header { - position: relative; - left: -20px; - padding: 9px 0px; -} - .proto-doc h3 { font-size: 26px; } From fa826bc06f977aab870f9a3a225dc7b2e3d43055 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 15:25:44 +0100 Subject: [PATCH 247/459] unlock width --- httpdocs/css/webots-cloud.css | 2 -- 1 file changed, 2 deletions(-) diff --git a/httpdocs/css/webots-cloud.css b/httpdocs/css/webots-cloud.css index 846ffa2b5..bb233c8b5 100644 --- a/httpdocs/css/webots-cloud.css +++ b/httpdocs/css/webots-cloud.css @@ -269,7 +269,6 @@ nav.pagination > a[disabled] { .thumbnail-image { height: 180px; - width: 320px; object-fit: cover; box-shadow: 0 0 10px black; z-index: 2; @@ -308,7 +307,6 @@ nav.pagination > a[disabled] { .thumbnail-image { height: 144px; - width: 256px; } } From e31ea22b379bb6ebcc1715cb4e685ec87451b318 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 15:36:32 +0100 Subject: [PATCH 248/459] img src --- httpdocs/js/webots-cloud.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index de5720db5..82180891d 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -322,13 +322,15 @@ document.addEventListener('DOMContentLoaded', function() { const dotIndex = data.url.lastIndexOf('/') + 1; thumbnailUrl = (data.url.slice(0, dotIndex) + '.' + data.url.slice(dotIndex)).replace('github.com', 'raw.githubusercontent.com').replace('/blob', ''); - if (proto) - thumbnailUrl = thumbnailUrl.replace('.proto', '.jpg'); - else - thumbnailUrl = thumbnailUrl.replace('.wbt', '.jpg'); + thumbnailUrl = thumbnailUrl.replace('.wbt', '.jpg'); } else if (data.type === 'competition') { const [, , , username, repo, , branch] = data.url.split('/'); thumbnailUrl = `https://raw.githubusercontent.com/${username}/${repo}/${branch}/preview/thumbnail.jpg`; + } else if (proto) { + const prefix = data.url.substr(0, data.url.lastIndexOf('/') + 1).replace('github.com', + 'raw.githubusercontent.com').replace('/blob', '') + 'icons/'; + const imageName = data.url.substr(data.url.lastIndexOf('/') + 1).replace('.proto', 'png'); + thumbnailUrl = prefix + imageName; } const defaultThumbnailUrl = document.location.origin + '/images/thumbnail_not_available.jpg'; const repository = `https://github.com/${words[0]}/${words[1]}`; From 03656001d8d4e223e474b7af24c0ddd3b9785ffe Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 15:37:34 +0100 Subject: [PATCH 249/459] typo --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 82180891d..1397353c3 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -318,7 +318,7 @@ document.addEventListener('DOMContentLoaded', function() { const admin = project.email ? project.email.endsWith('@cyberbotics.com') : false; const words = data.url.substring(19).split('/'); let thumbnailUrl; - if (data.type === 'demo' || proto) { + if (data.type === 'demo') { const dotIndex = data.url.lastIndexOf('/') + 1; thumbnailUrl = (data.url.slice(0, dotIndex) + '.' + data.url.slice(dotIndex)).replace('github.com', 'raw.githubusercontent.com').replace('/blob', ''); From 40fadf8e2c8c82a8b3055715ac46b7e6ca023bd8 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 15:37:53 +0100 Subject: [PATCH 250/459] typo --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 1397353c3..8c5ed63fa 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -329,7 +329,7 @@ document.addEventListener('DOMContentLoaded', function() { } else if (proto) { const prefix = data.url.substr(0, data.url.lastIndexOf('/') + 1).replace('github.com', 'raw.githubusercontent.com').replace('/blob', '') + 'icons/'; - const imageName = data.url.substr(data.url.lastIndexOf('/') + 1).replace('.proto', 'png'); + const imageName = data.url.substr(data.url.lastIndexOf('/') + 1).replace('.proto', '.png'); thumbnailUrl = prefix + imageName; } const defaultThumbnailUrl = document.location.origin + '/images/thumbnail_not_available.jpg'; From af43e4bb8508cc2ed91868dfd94e2c0d8060b782 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 16:00:16 +0100 Subject: [PATCH 251/459] do not allow hidden or deprecated --- httpdocs/ajax/proto/create.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 659560899..6363bdaca 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -53,7 +53,10 @@ function error($message) { if ($line[0] === '#') { if (strtolower(substr($line, 0, 9)) !== '# license' && strtolower(substr($line, 0, 8)) !== '#license' && strtolower(substr($line, 0, 10)) !== '# template' && strtolower(substr($line, 0, 9)) !== '#template' && substr($line, 0, 5) !== '#VRML') { - if ($description !== '') + if(strtolower(substr($line, 0, 6)) !== '# tags' && strtolower(substr($line, 0, 5)) !== '#tags') { + if (strpos($line, 'deprecated' || strpos($line, 'hidden') + error("This proto is either deprecated or hidden and should not be added.") + } else if ($description !== '') $description .= "\n"; $description .= $mysqli->escape_string(substr($line, 2)); } From 8b0b2ca0948b4927b2aeaac1bca03ad319bcce56 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 16:01:00 +0100 Subject: [PATCH 252/459] typo --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 6363bdaca..4a338a14f 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -55,7 +55,7 @@ function error($message) { strtolower(substr($line, 0, 10)) !== '# template' && strtolower(substr($line, 0, 9)) !== '#template' && substr($line, 0, 5) !== '#VRML') { if(strtolower(substr($line, 0, 6)) !== '# tags' && strtolower(substr($line, 0, 5)) !== '#tags') { if (strpos($line, 'deprecated' || strpos($line, 'hidden') - error("This proto is either deprecated or hidden and should not be added.") + error("This proto is either deprecated or hidden and should not be added."); } else if ($description !== '') $description .= "\n"; $description .= $mysqli->escape_string(substr($line, 2)); From d629bbaa1ee53f84cdf04f41cc3d19763d332990 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 16:02:02 +0100 Subject: [PATCH 253/459] log --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 8c5ed63fa..2ab8ed0dd 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1190,6 +1190,7 @@ document.addEventListener('DOMContentLoaded', function() { }; fetch('/ajax/proto/create.php', content) .then(function(response) { + console.log(response.text()) return response.json(); }) .then(function(data) { From 6aac0f4f612c1436a313fe623ee7873807f31ce1 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 16:02:51 +0100 Subject: [PATCH 254/459] missing parenthesis --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 4a338a14f..e1b67ca38 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -54,7 +54,7 @@ function error($message) { if (strtolower(substr($line, 0, 9)) !== '# license' && strtolower(substr($line, 0, 8)) !== '#license' && strtolower(substr($line, 0, 10)) !== '# template' && strtolower(substr($line, 0, 9)) !== '#template' && substr($line, 0, 5) !== '#VRML') { if(strtolower(substr($line, 0, 6)) !== '# tags' && strtolower(substr($line, 0, 5)) !== '#tags') { - if (strpos($line, 'deprecated' || strpos($line, 'hidden') + if (strpos($line, 'deprecated') || strpos($line, 'hidden')) error("This proto is either deprecated or hidden and should not be added."); } else if ($description !== '') $description .= "\n"; From 2b823191225a6b40f3ddb993bbf4593587e4568d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 16:03:29 +0100 Subject: [PATCH 255/459] log --- httpdocs/js/webots-cloud.js | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 2ab8ed0dd..8c5ed63fa 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1190,7 +1190,6 @@ document.addEventListener('DOMContentLoaded', function() { }; fetch('/ajax/proto/create.php', content) .then(function(response) { - console.log(response.text()) return response.json(); }) .then(function(data) { From dff63e59fa600ba3a3019f0722b2cbe703d11277 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 16:54:07 +0100 Subject: [PATCH 256/459] debug --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 8c5ed63fa..742f7e006 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1785,6 +1785,7 @@ document.addEventListener('DOMContentLoaded', function() { else file += '`' + value.trim() + '`.'; } else if (i === values.length - 2) { + console.log(value) if (values.length === 2) file += '`' + value.trim() + '` and '; else From 60f747587bcfc0b30c2cabf2ab72f523070b59e1 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 16:55:57 +0100 Subject: [PATCH 257/459] log --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 742f7e006..081aaa56c 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1766,6 +1766,7 @@ document.addEventListener('DOMContentLoaded', function() { for (const [fieldType, fieldName, fielDescription] of describedField) { file += '- `' + fieldName + '` : ' + fielDescription; const isMFField = fieldType.startsWith('MF'); + console.log(fieldEnumeration) if (fieldEnumeration.has(fieldName)) { const values = fieldEnumeration.get(fieldName); if (isMFField) @@ -1785,7 +1786,6 @@ document.addEventListener('DOMContentLoaded', function() { else file += '`' + value.trim() + '`.'; } else if (i === values.length - 2) { - console.log(value) if (values.length === 2) file += '`' + value.trim() + '` and '; else From a0fc2bea87c0b14307a6c6646bdace1e09693ca1 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 16:56:47 +0100 Subject: [PATCH 258/459] debug --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 081aaa56c..f529ed1c5 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1766,9 +1766,9 @@ document.addEventListener('DOMContentLoaded', function() { for (const [fieldType, fieldName, fielDescription] of describedField) { file += '- `' + fieldName + '` : ' + fielDescription; const isMFField = fieldType.startsWith('MF'); - console.log(fieldEnumeration) if (fieldEnumeration.has(fieldName)) { const values = fieldEnumeration.get(fieldName); + console.log(values) if (isMFField) file += ' This field accept a list of '; else { From 0ad62cf64dfc69343c0e3013f77912e3e22ba0e4 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 17:00:45 +0100 Subject: [PATCH 259/459] log --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index f529ed1c5..c31503629 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1766,9 +1766,9 @@ document.addEventListener('DOMContentLoaded', function() { for (const [fieldType, fieldName, fielDescription] of describedField) { file += '- `' + fieldName + '` : ' + fielDescription; const isMFField = fieldType.startsWith('MF'); + console.log(fieldName); if (fieldEnumeration.has(fieldName)) { const values = fieldEnumeration.get(fieldName); - console.log(values) if (isMFField) file += ' This field accept a list of '; else { From 5b66f46d532b5e37552588bba7046978f7ab0dba Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 17:03:01 +0100 Subject: [PATCH 260/459] log --- httpdocs/js/webots-cloud.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index c31503629..f111457b1 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1701,7 +1701,7 @@ document.addEventListener('DOMContentLoaded', function() { // remove enumeration matches = fieldsDefinition.matchAll(cleaningRegex); - + console.log(fieldsDefinition) const removeCommentRegex = /\s*(#.*)/mg; const removeInitialFieldRegex = /^\s*.*field\s/mg; for (const match of matches) { @@ -1766,7 +1766,6 @@ document.addEventListener('DOMContentLoaded', function() { for (const [fieldType, fieldName, fielDescription] of describedField) { file += '- `' + fieldName + '` : ' + fielDescription; const isMFField = fieldType.startsWith('MF'); - console.log(fieldName); if (fieldEnumeration.has(fieldName)) { const values = fieldEnumeration.get(fieldName); if (isMFField) From 99b946f11993d51103c473ac390cce7c65db133f Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 13 Jan 2023 17:08:10 +0100 Subject: [PATCH 261/459] log --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index f111457b1..9ecdadf50 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1701,10 +1701,10 @@ document.addEventListener('DOMContentLoaded', function() { // remove enumeration matches = fieldsDefinition.matchAll(cleaningRegex); - console.log(fieldsDefinition) const removeCommentRegex = /\s*(#.*)/mg; const removeInitialFieldRegex = /^\s*.*field\s/mg; for (const match of matches) { + console.log(match[0]) if (!(match[1].includes('hiddenField') || match[1].includes('deprecatedField'))) { const fieldType = match[2]; const fieldName = match[4]; From 04cc38baa81af34344b186433a2643736f1185d4 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 08:27:57 +0100 Subject: [PATCH 262/459] log --- httpdocs/js/webots-cloud.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 9ecdadf50..e2532fa33 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1699,12 +1699,12 @@ document.addEventListener('DOMContentLoaded', function() { 'LightSensor', 'Gyro', 'Receiver', 'Microphone', 'Solid', 'Billboard', 'Fluid', 'Muscle', 'Group', 'Skin', 'Material']; - // remove enumeration + // create the final cleaned PROTO header + console.log(fieldsDefinition) matches = fieldsDefinition.matchAll(cleaningRegex); const removeCommentRegex = /\s*(#.*)/mg; const removeInitialFieldRegex = /^\s*.*field\s/mg; for (const match of matches) { - console.log(match[0]) if (!(match[1].includes('hiddenField') || match[1].includes('deprecatedField'))) { const fieldType = match[2]; const fieldName = match[4]; From e90fb732df5e335f03a5df168de848e27ee8a47a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 08:29:02 +0100 Subject: [PATCH 263/459] log --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index e2532fa33..7849fbc4e 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1662,6 +1662,7 @@ document.addEventListener('DOMContentLoaded', function() { const removeEnumRegex = /.*ield\s+([^ ]*?)(\{(?:[^\[\n]*\,?\s?)(? Date: Mon, 16 Jan 2023 08:29:46 +0100 Subject: [PATCH 264/459] log --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 7849fbc4e..7e2175288 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1662,7 +1662,6 @@ document.addEventListener('DOMContentLoaded', function() { const removeEnumRegex = /.*ield\s+([^ ]*?)(\{(?:[^\[\n]*\,?\s?)(? Date: Mon, 16 Jan 2023 08:30:18 +0100 Subject: [PATCH 265/459] enum --- httpdocs/js/webots-cloud.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 7e2175288..cd4ee20e5 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1664,15 +1664,16 @@ document.addEventListener('DOMContentLoaded', function() { for (const match of matches) { fieldEnumeration.set(match[4], match[2].slice(1, -1).split(',')); if (match[0].includes('\n')) { + console.log(fieldsDefinition) const string = ' '.repeat(match[0].indexOf(match[2])); fieldsDefinition = fieldsDefinition.replace(string + match[4], match[4]); fieldsDefinition = fieldsDefinition.replace(match[2] + '\n', ''); + console.log(fieldsDefinition) if (match[2].length < 40) fieldsDefinition = fieldsDefinition.replace(match[2], ' '.repeat(match[2].length)); else fieldsDefinition = fieldsDefinition.replace(match[2], ''); } - console.log(fieldEnumeration) } const spacingRegex = /.*ield\s+([^ ]*?)(\s+)([^ ]*)\s+([^#\n]*)(#?)(.*)/mg; From af1e2d39b5c0c231a9135872b22737919c9c8c1a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 08:31:48 +0100 Subject: [PATCH 266/459] log --- httpdocs/js/webots-cloud.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index cd4ee20e5..9582622c8 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1664,16 +1664,15 @@ document.addEventListener('DOMContentLoaded', function() { for (const match of matches) { fieldEnumeration.set(match[4], match[2].slice(1, -1).split(',')); if (match[0].includes('\n')) { - console.log(fieldsDefinition) const string = ' '.repeat(match[0].indexOf(match[2])); fieldsDefinition = fieldsDefinition.replace(string + match[4], match[4]); fieldsDefinition = fieldsDefinition.replace(match[2] + '\n', ''); - console.log(fieldsDefinition) - if (match[2].length < 40) - fieldsDefinition = fieldsDefinition.replace(match[2], ' '.repeat(match[2].length)); - else - fieldsDefinition = fieldsDefinition.replace(match[2], ''); } + + if (match[2].length < 40) + fieldsDefinition = fieldsDefinition.replace(match[2], ' '.repeat(match[2].length)); + else + fieldsDefinition = fieldsDefinition.replace(match[2], ''); } const spacingRegex = /.*ield\s+([^ ]*?)(\s+)([^ ]*)\s+([^#\n]*)(#?)(.*)/mg; From f2aaa889c55dcaa83d81f7b668362854804147e4 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 12:05:30 +0100 Subject: [PATCH 267/459] license --- database/webots-cloud.sql | 11 ++++++++--- httpdocs/ajax/proto/create.php | 24 ++++++++++++++++-------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/database/webots-cloud.sql b/database/webots-cloud.sql index 90c58f994..ef0afece2 100644 --- a/database/webots-cloud.sql +++ b/database/webots-cloud.sql @@ -86,13 +86,18 @@ ALTER TABLE `server_branch` CREATE TABLE `proto` ( `id` int(11) NOT NULL, `url` varchar(2048) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, + `viewed` int(11) NOT NULL, `stars` int(11) NOT NULL, `title` varchar(256) CHARACTER SET utf8mb4 NOT NULL, `description` varchar(2048) CHARACTER SET utf8mb4 NOT NULL, - `version` varchar(16) NOT NULL, - `branch` varchar(256) CHARACTER SET utf8mb4 NOT NULL, + `version` varchar(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, + `branch` varchar(256) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `viewed` int(11) NOT NULL + `license_url` varchar(256) CHARACTER SET utf8mb4 NOT NULL, + `license` varchar(256) CHARACTER SET utf8mb4 NOT NULL, + `needs_robot_ancestor` varchar(256) CHARACTER SET utf8mb4 NOT NULL, + `base_type` varchar(256) CHARACTER SET utf8mb4 NOT NULL, + `slot_type` varchar(256) CHARACTER SET utf8mb4 NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ALTER TABLE `proto` diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index e1b67ca38..bc042b38c 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -41,27 +41,35 @@ function error($message) { error($check_yaml); } -# retrieve the title and info (description) from the header. +# retrieve the title and infos from the header. $info = false; $title = ''; $description = ''; +$license = ''; +$license_url = ''; $line = strtok($proto_content, "\r\n"); $version = $mysqli->escape_string(substr($line, 10, 6)); // "#VRML_SIM R2022b utf8" -> "R2022b" $line = strtok("\r\n"); while ($line !== false) { $line == trim($line); if ($line[0] === '#') { - if (strtolower(substr($line, 0, 9)) !== '# license' && strtolower(substr($line, 0, 8)) !== '#license' && - strtolower(substr($line, 0, 10)) !== '# template' && strtolower(substr($line, 0, 9)) !== '#template' && substr($line, 0, 5) !== '#VRML') { - if(strtolower(substr($line, 0, 6)) !== '# tags' && strtolower(substr($line, 0, 5)) !== '#tags') { + $line = trim(str_replace('#', '', $line)); + if (strtolower(substr($line, 0, 8)) !== 'template' && substr($line, 0, 4) !== 'VRML') { + if(strtolower(substr($line, 0, 4)) !== 'tags') { if (strpos($line, 'deprecated') || strpos($line, 'hidden')) error("This proto is either deprecated or hidden and should not be added."); - } else if ($description !== '') - $description .= "\n"; - $description .= $mysqli->escape_string(substr($line, 2)); + elseif (strtolower(substr($line, 0, 11)) !== 'license url') + $license_url = trim(preg_replace("/license url\s*:/", '', $line)); + elseif (strtolower(substr($line, 0, 7)) !== 'license') { + $license = trim(preg_replace("/license\s*:/", '', $line)); + } else { + if ($description !== '') + $description .= "\n"; + $description .= $mysqli->escape_string(substr($line, 2)); + } } } - elseif (substr($line, 0, 6) === 'PROTO ') + } elseif (substr($line, 0, 6) === 'PROTO ') $title = trim(substr($line, 6)); if (!empty($title) && $title[-1] === '[') $title = trim(substr($title, 0, -1)); From 4c5c84ffa4b0bacdee0ffcae3801929af8bb09ff Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 12:09:17 +0100 Subject: [PATCH 268/459] insert license --- httpdocs/ajax/proto/create.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index bc042b38c..f3ffae411 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -60,9 +60,9 @@ function error($message) { error("This proto is either deprecated or hidden and should not be added."); elseif (strtolower(substr($line, 0, 11)) !== 'license url') $license_url = trim(preg_replace("/license url\s*:/", '', $line)); - elseif (strtolower(substr($line, 0, 7)) !== 'license') { + elseif (strtolower(substr($line, 0, 7)) !== 'license') $license = trim(preg_replace("/license\s*:/", '', $line)); - } else { + else { if ($description !== '') $description .= "\n"; $description .= $mysqli->escape_string(substr($line, 2)); @@ -89,7 +89,7 @@ function error($message) { $branch = basename(dirname(__FILE__, 4)); if ($id === 0) $query = "INSERT IGNORE INTO proto(url, viewed, stars, title, description, version, branch) " - ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\")"; + ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license_url\", \"$license\")"; else $query = "UPDATE proto SET viewed=$viewed, stars=$stars, title=\"$title\", description=\"$description\", " ."version=\"$version\", updated=NOW() " From d99c9e652f884d56aa2aabbc162eac8c40d151fa Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 12:10:09 +0100 Subject: [PATCH 269/459] debug --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 9582622c8..bc13d8d8f 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1190,6 +1190,7 @@ document.addEventListener('DOMContentLoaded', function() { }; fetch('/ajax/proto/create.php', content) .then(function(response) { + console.log(response.text()) return response.json(); }) .then(function(data) { From 088ba443a78fcb90c778c797e34df5e6bda6ab39 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 12:12:36 +0100 Subject: [PATCH 270/459] license --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index f3ffae411..1437bb1c6 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -89,7 +89,7 @@ function error($message) { $branch = basename(dirname(__FILE__, 4)); if ($id === 0) $query = "INSERT IGNORE INTO proto(url, viewed, stars, title, description, version, branch) " - ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license_url\", \"$license\")"; + ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license_url\")"; else $query = "UPDATE proto SET viewed=$viewed, stars=$stars, title=\"$title\", description=\"$description\", " ."version=\"$version\", updated=NOW() " From cf7641b2e61f808d9116b122b8d7839d02482798 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 12:13:14 +0100 Subject: [PATCH 271/459] test --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 1437bb1c6..d5a86f2f3 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -89,7 +89,7 @@ function error($message) { $branch = basename(dirname(__FILE__, 4)); if ($id === 0) $query = "INSERT IGNORE INTO proto(url, viewed, stars, title, description, version, branch) " - ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license_url\")"; + ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\")"; else $query = "UPDATE proto SET viewed=$viewed, stars=$stars, title=\"$title\", description=\"$description\", " ."version=\"$version\", updated=NOW() " From 679b1a95ca6439a52ec62753181385dbe544a045 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 12:13:53 +0100 Subject: [PATCH 272/459] license --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index d5a86f2f3..6c4e75078 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -89,7 +89,7 @@ function error($message) { $branch = basename(dirname(__FILE__, 4)); if ($id === 0) $query = "INSERT IGNORE INTO proto(url, viewed, stars, title, description, version, branch) " - ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\")"; + ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license\")"; else $query = "UPDATE proto SET viewed=$viewed, stars=$stars, title=\"$title\", description=\"$description\", " ."version=\"$version\", updated=NOW() " From a34b0a7121e5f1cdf6ed49425962aad6e7f5eab6 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 12:15:21 +0100 Subject: [PATCH 273/459] correct --- httpdocs/ajax/proto/create.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 6c4e75078..abf5054f2 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -88,8 +88,8 @@ function error($message) { $viewed = ($result && $row) ? $row['viewed'] : 0; $branch = basename(dirname(__FILE__, 4)); if ($id === 0) - $query = "INSERT IGNORE INTO proto(url, viewed, stars, title, description, version, branch) " - ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license\")"; + $query = "INSERT IGNORE INTO proto(url, viewed, stars, title, description, version, branch, license_url, license) " + ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license_url\". \"$license\")"; else $query = "UPDATE proto SET viewed=$viewed, stars=$stars, title=\"$title\", description=\"$description\", " ."version=\"$version\", updated=NOW() " From 8a6c746a9481743f16bccfe65b62b9d31e23ac34 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 12:17:35 +0100 Subject: [PATCH 274/459] typo --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index abf5054f2..3841c19d0 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -89,7 +89,7 @@ function error($message) { $branch = basename(dirname(__FILE__, 4)); if ($id === 0) $query = "INSERT IGNORE INTO proto(url, viewed, stars, title, description, version, branch, license_url, license) " - ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license_url\". \"$license\")"; + ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license_url\", \"$license\")"; else $query = "UPDATE proto SET viewed=$viewed, stars=$stars, title=\"$title\", description=\"$description\", " ."version=\"$version\", updated=NOW() " From d2ced787726a6dd4d83cef69d664a042d7bb9a24 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 12:28:29 +0100 Subject: [PATCH 275/459] typo --- httpdocs/ajax/proto/create.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 3841c19d0..ee367bce4 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -58,9 +58,9 @@ function error($message) { if(strtolower(substr($line, 0, 4)) !== 'tags') { if (strpos($line, 'deprecated') || strpos($line, 'hidden')) error("This proto is either deprecated or hidden and should not be added."); - elseif (strtolower(substr($line, 0, 11)) !== 'license url') + elseif (strtolower(substr($line, 0, 11)) === 'license url') $license_url = trim(preg_replace("/license url\s*:/", '', $line)); - elseif (strtolower(substr($line, 0, 7)) !== 'license') + elseif (strtolower(substr($line, 0, 7)) === 'license') $license = trim(preg_replace("/license\s*:/", '', $line)); else { if ($description !== '') From da5d4565818013ea029668a92b0d626be8228c99 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 12:33:40 +0100 Subject: [PATCH 276/459] skip documentation url --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index ee367bce4..e6f5a3a93 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -54,7 +54,7 @@ function error($message) { $line == trim($line); if ($line[0] === '#') { $line = trim(str_replace('#', '', $line)); - if (strtolower(substr($line, 0, 8)) !== 'template' && substr($line, 0, 4) !== 'VRML') { + if (strtolower(substr($line, 0, 8)) !== 'template' && strtolower(substr($line, 0, 17)) !== 'documentation url' && substr($line, 0, 4) !== 'VRML') { if(strtolower(substr($line, 0, 4)) !== 'tags') { if (strpos($line, 'deprecated') || strpos($line, 'hidden')) error("This proto is either deprecated or hidden and should not be added."); From 981c3586018ce34dac4435898d18c539521f9504 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 12:35:08 +0100 Subject: [PATCH 277/459] typo --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index e6f5a3a93..7e0f4890b 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -65,7 +65,7 @@ function error($message) { else { if ($description !== '') $description .= "\n"; - $description .= $mysqli->escape_string(substr($line, 2)); + $description .= $mysqli->escape_string($line); } } } From 47fead772d8796348188e8b8a74e066ee2a7048b Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 14:42:03 +0100 Subject: [PATCH 278/459] test --- httpdocs/ajax/proto/create.php | 45 +++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 7e0f4890b..a3bae7a48 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -50,6 +50,7 @@ function error($message) { $line = strtok($proto_content, "\r\n"); $version = $mysqli->escape_string(substr($line, 10, 6)); // "#VRML_SIM R2022b utf8" -> "R2022b" $line = strtok("\r\n"); +$externprotos = []; while ($line !== false) { $line == trim($line); if ($line[0] === '#') { @@ -69,13 +70,49 @@ function error($message) { } } } + } elseif (substr($line, 0, 11) === 'EXTERNPROTO') { + $proto_url = trim(str_replace('"', '',str_replace('EXTERNPROTO', '', $line))); + $proto_name = str_replace('.proto"', '', $line); + $proto_name = substr($proto_name, strrpos($proto_name, '/') + 1); + array_push($externprotos, [$proto_name, $proto_url]); } elseif (substr($line, 0, 6) === 'PROTO ') $title = trim(substr($line, 6)); - if (!empty($title) && $title[-1] === '[') - $title = trim(substr($title, 0, -1)); + if (!empty($title) && $title[-1] === '[') + $title = trim(substr($title, 0, -1)); $line = strtok("\r\n"); } +$title = $mysqli->escape_string($title); +$license = $mysqli->escape_string($license); +$license_url = $mysqli->escape_string($license_url); + +$base_type = ''; +preg_match("/(?:\]\s*)\{\s*(?:\%\<[\s\S]*?(?:\>\%\s*))?(?:DEF\s+[^\s]+)?\s+([a-zA-Z0-9\_\-\+]+)\s*\{/", $proto_content, $match); +if ($match) + $base_type = $match[1]; + +$base_nodes = ['Gyro', 'DistanceSensor', 'Recognition', 'TouchSensor', 'ContactProperties', 'TextureCoordinate', 'Color', + 'Camera', 'Accelerometer', 'Slot', 'Radar', 'Transform', 'Zoom', 'RangeFinder', 'PointSet', 'Capsule', 'Speaker', 'Lens', + 'Viewpoint', 'IndexedFaceSet', 'Solid', 'Group', 'Muscle', 'Lidar', 'InertialUnit', 'DirectionalLight', + 'HingeJointParameters', 'Compass', 'Normal', 'Propeller', 'Physics', 'RotationalMotor', 'Microphone', 'ImageTexture', 'Fog', + 'Mesh', 'Track', 'Background', 'LED', 'Material', 'Box', 'PointLight', 'Cylinder', 'Damping', 'GPS', 'Radio', 'Pen', 'Cone', + 'WorldInfo', 'SpotLight', 'TextureTransform', 'LinearMotor', 'Receiver', 'Coordinate', 'Hinge2JointParameters', 'CadShape', + 'LensFlare', 'TrackWheel', 'PBRAppearance', 'Shape', 'Altimeter', 'PositionSensor', 'Connector', 'HingeJoint', 'Plane', + 'Brake', 'Appearance', 'ElevationGrid', 'BallJointParameters', 'Fluid', 'Robot', 'SolidReference', 'Sphere', 'Skin', + 'IndexedLineSet', 'ImmersionProperties', 'JointParameters', 'Focus', 'SliderJoint', 'Emitter', 'Hinge2Joint', 'BallJoint', + 'LightSensor', 'Display', 'Billboard', 'Charger']; + +while(!in_array($base_type, $base_nodes)) { + for($i = 0; $i < count($externprotos); $i++) { + if ($externprotos[i][0] === $base_type) { + $base_type = $externprotos[i][1]; + // $query = "SELECT base_type FROM proto WHERE url=\"$url\"; + break; + } + } + break; +} + $auth = "Authorization: Basic " . base64_encode("$github_oauth_client_id:$github_oauth_client_secret"); $context = stream_context_create(['http' => ['method' => 'GET', 'header' => ['User-Agent: PHP', $auth]]]); $info_json = @file_get_contents("https://api.github.com/repos/$username/$repository", false, $context); @@ -88,8 +125,8 @@ function error($message) { $viewed = ($result && $row) ? $row['viewed'] : 0; $branch = basename(dirname(__FILE__, 4)); if ($id === 0) - $query = "INSERT IGNORE INTO proto(url, viewed, stars, title, description, version, branch, license_url, license) " - ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license_url\", \"$license\")"; + $query = "INSERT IGNORE INTO proto(url, viewed, stars, title, description, version, branch, license_url, license, base_type) " + ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license_url\", \"$license\", \"$base_type\")"; else $query = "UPDATE proto SET viewed=$viewed, stars=$stars, title=\"$title\", description=\"$description\", " ."version=\"$version\", updated=NOW() " From 3a6dbb842bd8e11cd13b0a5aad15d526532d997b Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 14:43:43 +0100 Subject: [PATCH 279/459] $ --- httpdocs/ajax/proto/create.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index a3bae7a48..7968b9c8b 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -104,8 +104,8 @@ function error($message) { while(!in_array($base_type, $base_nodes)) { for($i = 0; $i < count($externprotos); $i++) { - if ($externprotos[i][0] === $base_type) { - $base_type = $externprotos[i][1]; + if ($externprotos[$i][0] === $base_type) { + $base_type = $externprotos[$i][1]; // $query = "SELECT base_type FROM proto WHERE url=\"$url\"; break; } From e2225b78c133a22b2954cd7464eedfc3bb42f31c Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 15:03:06 +0100 Subject: [PATCH 280/459] base_type --- httpdocs/ajax/proto/create.php | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 7968b9c8b..5adf93d15 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -103,14 +103,40 @@ function error($message) { 'LightSensor', 'Display', 'Billboard', 'Charger']; while(!in_array($base_type, $base_nodes)) { + $found_parent = false; for($i = 0; $i < count($externprotos); $i++) { if ($externprotos[$i][0] === $base_type) { - $base_type = $externprotos[$i][1]; - // $query = "SELECT base_type FROM proto WHERE url=\"$url\"; + $found_parent = true; + $extern_url = $externprotos[$i][1]; + $check_url = proto_check_url($extern_url); + if (!is_array($check_url)) + error($check_url); + list($extern_username, $extern_repository, $extern_tag_or_branch, $extern_folder, $extern_proto) = $check_url; + $extern_proto_url = "https://raw.githubusercontent.com/$extern_username/$extern_repository/$extern_tag_or_branch$extern_folder/protos/$pextern_protoroto"; + $extern_proto_content = @file_get_contents($extern_proto_url); + if ($extern_proto_content === false) + error("Could not retrieve parent proto with url'$extern_url'"); + + $line = strtok("\r\n"); + $externprotos = []; + while ($line !== false) { + $line == trim($line); + if (substr($line, 0, 11) === 'EXTERNPROTO') { + $proto_url = trim(str_replace('"', '',str_replace('EXTERNPROTO', '', $line))); + $proto_name = str_replace('.proto"', '', $line); + $proto_name = substr($proto_name, strrpos($proto_name, '/') + 1); + array_push($externprotos, [$proto_name, $proto_url]); + } + } + + preg_match("/(?:\]\s*)\{\s*(?:\%\<[\s\S]*?(?:\>\%\s*))?(?:DEF\s+[^\s]+)?\s+([a-zA-Z0-9\_\-\+]+)\s*\{/", $proto_content, $match); + if ($match) + $base_type = $match[1]; break; } } - break; + if(!$found_parent) + error("Seems like the parent node is missing from the EXTERNPROTO."); } $auth = "Authorization: Basic " . base64_encode("$github_oauth_client_id:$github_oauth_client_secret"); From 03ba9c59adf34c9aa368c346aba58a4b4a7194db Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 15:30:11 +0100 Subject: [PATCH 281/459] forge url --- httpdocs/ajax/proto/create.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 5adf93d15..4b81f82b5 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -102,12 +102,18 @@ function error($message) { 'IndexedLineSet', 'ImmersionProperties', 'JointParameters', 'Focus', 'SliderJoint', 'Emitter', 'Hinge2Joint', 'BallJoint', 'LightSensor', 'Display', 'Billboard', 'Charger']; +$parent_url = $url; while(!in_array($base_type, $base_nodes)) { $found_parent = false; for($i = 0; $i < count($externprotos); $i++) { if ($externprotos[$i][0] === $base_type) { $found_parent = true; $extern_url = $externprotos[$i][1]; + if (str_starts_with($extern_url, "webots://")) + $extern_url = str_replace("webots://", "https://github.com/cyberbotics/webots/blob/released/"); + else if (!srt_starts_with($extern_url, "https")) + $extern_url = substr($parent_url, 0, strrpos($parent_url, '/') + 1).$extern_url; + $parent_url = $extern_url; $check_url = proto_check_url($extern_url); if (!is_array($check_url)) error($check_url); From d7673b496ccbb719470015d04a534fac5785c8dc Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 15:31:12 +0100 Subject: [PATCH 282/459] typo --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 4b81f82b5..95c7f2609 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -110,7 +110,7 @@ function error($message) { $found_parent = true; $extern_url = $externprotos[$i][1]; if (str_starts_with($extern_url, "webots://")) - $extern_url = str_replace("webots://", "https://github.com/cyberbotics/webots/blob/released/"); + $extern_url = str_replace("webots://", "https://github.com/cyberbotics/webots/blob/released/", $extern_url); else if (!srt_starts_with($extern_url, "https")) $extern_url = substr($parent_url, 0, strrpos($parent_url, '/') + 1).$extern_url; $parent_url = $extern_url; From b8ed37eaf9012d253d70100d8c4236582296b74d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 15:32:28 +0100 Subject: [PATCH 283/459] name --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 95c7f2609..0042bc6eb 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -118,7 +118,7 @@ function error($message) { if (!is_array($check_url)) error($check_url); list($extern_username, $extern_repository, $extern_tag_or_branch, $extern_folder, $extern_proto) = $check_url; - $extern_proto_url = "https://raw.githubusercontent.com/$extern_username/$extern_repository/$extern_tag_or_branch$extern_folder/protos/$pextern_protoroto"; + $extern_proto_url = "https://raw.githubusercontent.com/$extern_username/$extern_repository/$extern_tag_or_branch$extern_folder/protos/$extern_proto"; $extern_proto_content = @file_get_contents($extern_proto_url); if ($extern_proto_content === false) error("Could not retrieve parent proto with url'$extern_url'"); From 3d01c23f6dc88eec9890f0d6620635db1ace7f47 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 15:34:57 +0100 Subject: [PATCH 284/459] debug --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 0042bc6eb..3d305b9e6 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -142,7 +142,7 @@ function error($message) { } } if(!$found_parent) - error("Seems like the parent node is missing from the EXTERNPROTO."); + error("Seems like the parent node is missing from the EXTERNPROTO.$base_type ".$externprotos[$i][0]); } $auth = "Authorization: Basic " . base64_encode("$github_oauth_client_id:$github_oauth_client_secret"); From 09e3c7a7bb3507692fa2a510b996e491037283c8 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 15:35:55 +0100 Subject: [PATCH 285/459] 0 --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 3d305b9e6..a688f57da 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -142,7 +142,7 @@ function error($message) { } } if(!$found_parent) - error("Seems like the parent node is missing from the EXTERNPROTO.$base_type ".$externprotos[$i][0]); + error("Seems like the parent node is missing from the EXTERNPROTO.$base_type ".$externprotos[1][0]); } $auth = "Authorization: Basic " . base64_encode("$github_oauth_client_id:$github_oauth_client_secret"); From 3f3598bd8c5435300868234f896d745199655540 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 15:37:35 +0100 Subject: [PATCH 286/459] debug --- httpdocs/ajax/proto/create.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index a688f57da..7202e0245 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -123,6 +123,7 @@ function error($message) { if ($extern_proto_content === false) error("Could not retrieve parent proto with url'$extern_url'"); + strtok($extern_proto_content, "\r\n"); $line = strtok("\r\n"); $externprotos = []; while ($line !== false) { @@ -142,7 +143,7 @@ function error($message) { } } if(!$found_parent) - error("Seems like the parent node is missing from the EXTERNPROTO.$base_type ".$externprotos[1][0]); + error("Seems like the parent node is missing from the EXTERNPROTO.$base_type ".$externprotos[0][0]); } $auth = "Authorization: Basic " . base64_encode("$github_oauth_client_id:$github_oauth_client_secret"); From abb2f062414c405227449c7b2e29657ebac6959b Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 15:41:17 +0100 Subject: [PATCH 287/459] typo --- httpdocs/ajax/proto/create.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 7202e0245..b7460ed37 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -136,14 +136,14 @@ function error($message) { } } - preg_match("/(?:\]\s*)\{\s*(?:\%\<[\s\S]*?(?:\>\%\s*))?(?:DEF\s+[^\s]+)?\s+([a-zA-Z0-9\_\-\+]+)\s*\{/", $proto_content, $match); + preg_match("/(?:\]\s*)\{\s*(?:\%\<[\s\S]*?(?:\>\%\s*))?(?:DEF\s+[^\s]+)?\s+([a-zA-Z0-9\_\-\+]+)\s*\{/", $extern_proto_content, $match); if ($match) $base_type = $match[1]; break; } } if(!$found_parent) - error("Seems like the parent node is missing from the EXTERNPROTO.$base_type ".$externprotos[0][0]); + error("Seems like the parent node is missing from the EXTERNPROTO."); } $auth = "Authorization: Basic " . base64_encode("$github_oauth_client_id:$github_oauth_client_secret"); From 6bba377e69f697e01a17850df44ee27f8534cc67 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 15:42:15 +0100 Subject: [PATCH 288/459] log --- httpdocs/ajax/proto/create.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index b7460ed37..dab3f0ce5 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -139,6 +139,8 @@ function error($message) { preg_match("/(?:\]\s*)\{\s*(?:\%\<[\s\S]*?(?:\>\%\s*))?(?:DEF\s+[^\s]+)?\s+([a-zA-Z0-9\_\-\+]+)\s*\{/", $extern_proto_content, $match); if ($match) $base_type = $match[1]; + + error($match[1]); break; } } From 9286e6d2505de954ebe478e80d67bb1619a9b950 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 15:43:39 +0100 Subject: [PATCH 289/459] debug --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index dab3f0ce5..9bc8bba6a 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -106,6 +106,7 @@ function error($message) { while(!in_array($base_type, $base_nodes)) { $found_parent = false; for($i = 0; $i < count($externprotos); $i++) { + error("aie".$externprotos[$i][0]); if ($externprotos[$i][0] === $base_type) { $found_parent = true; $extern_url = $externprotos[$i][1]; @@ -140,7 +141,6 @@ function error($message) { if ($match) $base_type = $match[1]; - error($match[1]); break; } } From 3dfd7d580b19c2f683624c834b12b8b95d28e2e8 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 15:44:18 +0100 Subject: [PATCH 290/459] debug --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 9bc8bba6a..c6daa567d 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -106,8 +106,8 @@ function error($message) { while(!in_array($base_type, $base_nodes)) { $found_parent = false; for($i = 0; $i < count($externprotos); $i++) { - error("aie".$externprotos[$i][0]); if ($externprotos[$i][0] === $base_type) { + error("aie".$externprotos[$i][0]); $found_parent = true; $extern_url = $externprotos[$i][1]; if (str_starts_with($extern_url, "webots://")) From 22a5ca89910dd338b8e3aab0e3ab48ef59851f23 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 15:45:06 +0100 Subject: [PATCH 291/459] debug --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index c6daa567d..ad3f3eb03 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -107,7 +107,6 @@ function error($message) { $found_parent = false; for($i = 0; $i < count($externprotos); $i++) { if ($externprotos[$i][0] === $base_type) { - error("aie".$externprotos[$i][0]); $found_parent = true; $extern_url = $externprotos[$i][1]; if (str_starts_with($extern_url, "webots://")) @@ -135,6 +134,7 @@ function error($message) { $proto_name = substr($proto_name, strrpos($proto_name, '/') + 1); array_push($externprotos, [$proto_name, $proto_url]); } + $line = strtok("\r\n"); } preg_match("/(?:\]\s*)\{\s*(?:\%\<[\s\S]*?(?:\>\%\s*))?(?:DEF\s+[^\s]+)?\s+([a-zA-Z0-9\_\-\+]+)\s*\{/", $extern_proto_content, $match); From f6afdec961615fd2f2f43bda99b17bc83c9e5594 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 16:09:50 +0100 Subject: [PATCH 292/459] needs_robot_content --- httpdocs/ajax/proto/create.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index ad3f3eb03..30561ef34 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -102,6 +102,7 @@ function error($message) { 'IndexedLineSet', 'ImmersionProperties', 'JointParameters', 'Focus', 'SliderJoint', 'Emitter', 'Hinge2Joint', 'BallJoint', 'LightSensor', 'Display', 'Billboard', 'Charger']; +# search for the base type $parent_url = $url; while(!in_array($base_type, $base_nodes)) { $found_parent = false; @@ -148,6 +149,11 @@ function error($message) { error("Seems like the parent node is missing from the EXTERNPROTO."); } +$device_regex = "/(\s+Brake\s*|\s+LinearMotor\s*|\s+PositionSensor\s*|\s+RotationalMotor\s*|\s+Skin\s*|\s+Accelerometer\s*|\s+Altimeter\s*|\s+Camera\s*|\s+Compass\s*|\s+Compass\s*|\s+Display\s*|\s+DistanceSensor\s*|\s+Emitter\s*|\s+GPS\s*|\s+Gyro\s*|\s+InertialUnit\s*|\s+LED\s*|\s+Lidar\s*|\s+LightSensor\s*|\s+Pen\s*|\s+Radar\s*|\s+RangeFinder\s*|\s+Receiver\s*|\s+Speaker\s*|\s+TouchSensor\s*|\s+Track\s*)/" +$needs_robot_ancestor = 0; +if in_array($base_type, ['Solid', 'Transform', 'Group']) + $needs_robot_ancestor = $preg_match($device_regex, $proto_content); + $auth = "Authorization: Basic " . base64_encode("$github_oauth_client_id:$github_oauth_client_secret"); $context = stream_context_create(['http' => ['method' => 'GET', 'header' => ['User-Agent: PHP', $auth]]]); $info_json = @file_get_contents("https://api.github.com/repos/$username/$repository", false, $context); @@ -160,8 +166,8 @@ function error($message) { $viewed = ($result && $row) ? $row['viewed'] : 0; $branch = basename(dirname(__FILE__, 4)); if ($id === 0) - $query = "INSERT IGNORE INTO proto(url, viewed, stars, title, description, version, branch, license_url, license, base_type) " - ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license_url\", \"$license\", \"$base_type\")"; + $query = "INSERT IGNORE INTO proto(url, viewed, stars, title, description, version, branch, license_url, license, base_type, needs_robot_ancestor) " + ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license_url\", \"$license\", \"$base_type\", \"$needs_robot_ancestor\")"; else $query = "UPDATE proto SET viewed=$viewed, stars=$stars, title=\"$title\", description=\"$description\", " ."version=\"$version\", updated=NOW() " From d735840e69c1c5f050f9078d0804b0f3c66ec958 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 16:10:34 +0100 Subject: [PATCH 293/459] typo --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 30561ef34..79c0c64b0 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -149,7 +149,7 @@ function error($message) { error("Seems like the parent node is missing from the EXTERNPROTO."); } -$device_regex = "/(\s+Brake\s*|\s+LinearMotor\s*|\s+PositionSensor\s*|\s+RotationalMotor\s*|\s+Skin\s*|\s+Accelerometer\s*|\s+Altimeter\s*|\s+Camera\s*|\s+Compass\s*|\s+Compass\s*|\s+Display\s*|\s+DistanceSensor\s*|\s+Emitter\s*|\s+GPS\s*|\s+Gyro\s*|\s+InertialUnit\s*|\s+LED\s*|\s+Lidar\s*|\s+LightSensor\s*|\s+Pen\s*|\s+Radar\s*|\s+RangeFinder\s*|\s+Receiver\s*|\s+Speaker\s*|\s+TouchSensor\s*|\s+Track\s*)/" +$device_regex = "/(\s+Brake\s*|\s+LinearMotor\s*|\s+PositionSensor\s*|\s+RotationalMotor\s*|\s+Skin\s*|\s+Accelerometer\s*|\s+Altimeter\s*|\s+Camera\s*|\s+Compass\s*|\s+Compass\s*|\s+Display\s*|\s+DistanceSensor\s*|\s+Emitter\s*|\s+GPS\s*|\s+Gyro\s*|\s+InertialUnit\s*|\s+LED\s*|\s+Lidar\s*|\s+LightSensor\s*|\s+Pen\s*|\s+Radar\s*|\s+RangeFinder\s*|\s+Receiver\s*|\s+Speaker\s*|\s+TouchSensor\s*|\s+Track\s*)/"; $needs_robot_ancestor = 0; if in_array($base_type, ['Solid', 'Transform', 'Group']) $needs_robot_ancestor = $preg_match($device_regex, $proto_content); From c733114578d7d3013169a89cfe066b47260e30b2 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 16:11:04 +0100 Subject: [PATCH 294/459] typo --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 79c0c64b0..9330490c2 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -151,7 +151,7 @@ function error($message) { $device_regex = "/(\s+Brake\s*|\s+LinearMotor\s*|\s+PositionSensor\s*|\s+RotationalMotor\s*|\s+Skin\s*|\s+Accelerometer\s*|\s+Altimeter\s*|\s+Camera\s*|\s+Compass\s*|\s+Compass\s*|\s+Display\s*|\s+DistanceSensor\s*|\s+Emitter\s*|\s+GPS\s*|\s+Gyro\s*|\s+InertialUnit\s*|\s+LED\s*|\s+Lidar\s*|\s+LightSensor\s*|\s+Pen\s*|\s+Radar\s*|\s+RangeFinder\s*|\s+Receiver\s*|\s+Speaker\s*|\s+TouchSensor\s*|\s+Track\s*)/"; $needs_robot_ancestor = 0; -if in_array($base_type, ['Solid', 'Transform', 'Group']) +if (in_array($base_type, ['Solid', 'Transform', 'Group']) $needs_robot_ancestor = $preg_match($device_regex, $proto_content); $auth = "Authorization: Basic " . base64_encode("$github_oauth_client_id:$github_oauth_client_secret"); From 9a47c66ecabd30fe2966f81204f2cb2fee60d998 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 16:11:35 +0100 Subject: [PATCH 295/459] typo --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 9330490c2..c8f8e3cef 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -152,7 +152,7 @@ function error($message) { $device_regex = "/(\s+Brake\s*|\s+LinearMotor\s*|\s+PositionSensor\s*|\s+RotationalMotor\s*|\s+Skin\s*|\s+Accelerometer\s*|\s+Altimeter\s*|\s+Camera\s*|\s+Compass\s*|\s+Compass\s*|\s+Display\s*|\s+DistanceSensor\s*|\s+Emitter\s*|\s+GPS\s*|\s+Gyro\s*|\s+InertialUnit\s*|\s+LED\s*|\s+Lidar\s*|\s+LightSensor\s*|\s+Pen\s*|\s+Radar\s*|\s+RangeFinder\s*|\s+Receiver\s*|\s+Speaker\s*|\s+TouchSensor\s*|\s+Track\s*)/"; $needs_robot_ancestor = 0; if (in_array($base_type, ['Solid', 'Transform', 'Group']) - $needs_robot_ancestor = $preg_match($device_regex, $proto_content); + $needs_robot_ancestor = preg_match($device_regex, $proto_content); $auth = "Authorization: Basic " . base64_encode("$github_oauth_client_id:$github_oauth_client_secret"); $context = stream_context_create(['http' => ['method' => 'GET', 'header' => ['User-Agent: PHP', $auth]]]); From 3286040e54ce330e44a72f688f6a4b6f117ff99e Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 16:12:03 +0100 Subject: [PATCH 296/459] typo --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index c8f8e3cef..ffc92fdd6 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -151,7 +151,7 @@ function error($message) { $device_regex = "/(\s+Brake\s*|\s+LinearMotor\s*|\s+PositionSensor\s*|\s+RotationalMotor\s*|\s+Skin\s*|\s+Accelerometer\s*|\s+Altimeter\s*|\s+Camera\s*|\s+Compass\s*|\s+Compass\s*|\s+Display\s*|\s+DistanceSensor\s*|\s+Emitter\s*|\s+GPS\s*|\s+Gyro\s*|\s+InertialUnit\s*|\s+LED\s*|\s+Lidar\s*|\s+LightSensor\s*|\s+Pen\s*|\s+Radar\s*|\s+RangeFinder\s*|\s+Receiver\s*|\s+Speaker\s*|\s+TouchSensor\s*|\s+Track\s*)/"; $needs_robot_ancestor = 0; -if (in_array($base_type, ['Solid', 'Transform', 'Group']) +if (in_array($base_type, ['Solid', 'Transform', 'Group'])) $needs_robot_ancestor = preg_match($device_regex, $proto_content); $auth = "Authorization: Basic " . base64_encode("$github_oauth_client_id:$github_oauth_client_secret"); From 95a1474ea2cc1816a6bdaa9af1cc07d46da435e4 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 16:43:34 +0100 Subject: [PATCH 297/459] slot type --- httpdocs/ajax/proto/create.php | 68 ++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index ffc92fdd6..f3f8a87d4 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -82,6 +82,7 @@ function error($message) { $line = strtok("\r\n"); } +$original_externprotos = $externprotos; $title = $mysqli->escape_string($title); $license = $mysqli->escape_string($license); $license_url = $mysqli->escape_string($license_url); @@ -90,7 +91,7 @@ function error($message) { preg_match("/(?:\]\s*)\{\s*(?:\%\<[\s\S]*?(?:\>\%\s*))?(?:DEF\s+[^\s]+)?\s+([a-zA-Z0-9\_\-\+]+)\s*\{/", $proto_content, $match); if ($match) $base_type = $match[1]; - +$base_proto = $base_type $base_nodes = ['Gyro', 'DistanceSensor', 'Recognition', 'TouchSensor', 'ContactProperties', 'TextureCoordinate', 'Color', 'Camera', 'Accelerometer', 'Slot', 'Radar', 'Transform', 'Zoom', 'RangeFinder', 'PointSet', 'Capsule', 'Speaker', 'Lens', 'Viewpoint', 'IndexedFaceSet', 'Solid', 'Group', 'Muscle', 'Lidar', 'InertialUnit', 'DirectionalLight', @@ -124,7 +125,7 @@ function error($message) { if ($extern_proto_content === false) error("Could not retrieve parent proto with url'$extern_url'"); - strtok($extern_proto_content, "\r\n"); + $line = strtok($extern_proto_content, "\r\n"); $line = strtok("\r\n"); $externprotos = []; while ($line !== false) { @@ -154,6 +155,65 @@ function error($message) { if (in_array($base_type, ['Solid', 'Transform', 'Group'])) $needs_robot_ancestor = preg_match($device_regex, $proto_content); +$slot_type = ''; +if ($base_type === "Slot") { + $found = false; + $current_proto = $proto_content; + $externprotos = $original_externprotos; + $parent_url = $url; + while(!$found) { + preg_match("/type\s+\"([a-zA-Z0-9\_\-\+\s]+)\"/", $current_proto, $match); + if ($match) { + $slot_type = $match[1]; + $found = true; + } else { + for($i = 0; $i < count($externprotos); $i++) { + if ($externprotos[$i][0] === $base_proto) { + $found_parent = true; + $extern_url = $externprotos[$i][1]; + if (str_starts_with($extern_url, "webots://")) + $extern_url = str_replace("webots://", "https://github.com/cyberbotics/webots/blob/released/", $extern_url); + else if (!srt_starts_with($extern_url, "https")) + $extern_url = substr($parent_url, 0, strrpos($parent_url, '/') + 1).$extern_url; + $parent_url = $extern_url; + $check_url = proto_check_url($extern_url); + if (!is_array($check_url)) + error($check_url); + list($extern_username, $extern_repository, $extern_tag_or_branch, $extern_folder, $extern_proto) = $check_url; + $extern_proto_url = "https://raw.githubusercontent.com/$extern_username/$extern_repository/$extern_tag_or_branch$extern_folder/protos/$extern_proto"; + $extern_proto_content = @file_get_contents($extern_proto_url); + $current_proto = $extern_proto_content; + if ($extern_proto_content === false) + error("Could not retrieve parent proto with url'$extern_url'"); + + $line = strtok($extern_proto_content, "\r\n"); + $line = strtok("\r\n"); + $externprotos = []; + while ($line !== false) { + $line == trim($line); + if (substr($line, 0, 11) === 'EXTERNPROTO') { + $proto_url = trim(str_replace('"', '',str_replace('EXTERNPROTO', '', $line))); + $proto_name = str_replace('.proto"', '', $line); + $proto_name = substr($proto_name, strrpos($proto_name, '/') + 1); + array_push($externprotos, [$proto_name, $proto_url]); + } + $line = strtok("\r\n"); + } + + preg_match("/(?:\]\s*)\{\s*(?:\%\<[\s\S]*?(?:\>\%\s*))?(?:DEF\s+[^\s]+)?\s+([a-zA-Z0-9\_\-\+]+)\s*\{/", $extern_proto_content, $match); + if ($match) + $base_proto = $match[1]; + + break; + } + } + if(!$found_parent) + error("Seems like the parent node is missing from the EXTERNPROTO."); + } + } +} + + $auth = "Authorization: Basic " . base64_encode("$github_oauth_client_id:$github_oauth_client_secret"); $context = stream_context_create(['http' => ['method' => 'GET', 'header' => ['User-Agent: PHP', $auth]]]); $info_json = @file_get_contents("https://api.github.com/repos/$username/$repository", false, $context); @@ -166,8 +226,8 @@ function error($message) { $viewed = ($result && $row) ? $row['viewed'] : 0; $branch = basename(dirname(__FILE__, 4)); if ($id === 0) - $query = "INSERT IGNORE INTO proto(url, viewed, stars, title, description, version, branch, license_url, license, base_type, needs_robot_ancestor) " - ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license_url\", \"$license\", \"$base_type\", \"$needs_robot_ancestor\")"; + $query = "INSERT IGNORE INTO proto(url, viewed, stars, title, description, version, branch, license_url, license, base_type, needs_robot_ancestor, slot_type) " + ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license_url\", \"$license\", \"$base_type\", \"$needs_robot_ancestor\", \"$slot_type\")"; else $query = "UPDATE proto SET viewed=$viewed, stars=$stars, title=\"$title\", description=\"$description\", " ."version=\"$version\", updated=NOW() " From 92bb6cb00f49f0f8465403b30b553b70cd7ce936 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 16:44:54 +0100 Subject: [PATCH 298/459] ; --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index f3f8a87d4..40de92246 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -91,7 +91,7 @@ function error($message) { preg_match("/(?:\]\s*)\{\s*(?:\%\<[\s\S]*?(?:\>\%\s*))?(?:DEF\s+[^\s]+)?\s+([a-zA-Z0-9\_\-\+]+)\s*\{/", $proto_content, $match); if ($match) $base_type = $match[1]; -$base_proto = $base_type +$base_proto = $base_type; $base_nodes = ['Gyro', 'DistanceSensor', 'Recognition', 'TouchSensor', 'ContactProperties', 'TextureCoordinate', 'Color', 'Camera', 'Accelerometer', 'Slot', 'Radar', 'Transform', 'Zoom', 'RangeFinder', 'PointSet', 'Capsule', 'Speaker', 'Lens', 'Viewpoint', 'IndexedFaceSet', 'Solid', 'Group', 'Muscle', 'Lidar', 'InertialUnit', 'DirectionalLight', From c17c9d0a5d0e8d88fb98e96a91d0ffab789a9326 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 16:53:37 +0100 Subject: [PATCH 299/459] remove log --- httpdocs/js/webots-cloud.js | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index bc13d8d8f..9582622c8 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1190,7 +1190,6 @@ document.addEventListener('DOMContentLoaded', function() { }; fetch('/ajax/proto/create.php', content) .then(function(response) { - console.log(response.text()) return response.json(); }) .then(function(data) { From 57b812700dcb9b67351fd5eb8a0bec06f2606c72 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 16 Jan 2023 16:55:39 +0100 Subject: [PATCH 300/459] check for license --- httpdocs/js/webots-cloud.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 9582622c8..29dcb69a3 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1797,8 +1797,8 @@ document.addEventListener('DOMContentLoaded', function() { } } - const license = protoNode.getElementsByTagName('license')[0].textContent; - const licenseUrl = protoNode.getElementsByTagName('license-url')[0].textContent; + const license = protoNode.getElementsByTagName('license')[0]?.textContent; + const licenseUrl = protoNode.getElementsByTagName('license-url')[0]?.textContent; let version; for (const line of proto.split('\n')) { if (line.startsWith('#VRML_SIM') || line.startsWith('# VRML_SIM')) { From 759a79a182701d8b88f63e901cef4396a6ad7399 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 08:25:05 +0100 Subject: [PATCH 301/459] fetch doc --- httpdocs/ajax/proto/documentation.php | 19 +++++++++++++++++++ httpdocs/js/webots-cloud.js | 7 +++++++ 2 files changed, 26 insertions(+) create mode 100644 httpdocs/ajax/proto/documentation.php diff --git a/httpdocs/ajax/proto/documentation.php b/httpdocs/ajax/proto/documentation.php new file mode 100644 index 000000000..49262e7f3 --- /dev/null +++ b/httpdocs/ajax/proto/documentation.php @@ -0,0 +1,19 @@ +connect_errno) + error("Can't connect to MySQL database: $mysqli->connect_error"); + $mysqli->set_charset('utf8'); + $branch = basename(dirname(__FILE__, 4)); + $url = $mysqli->escape_string($data->url); + $condition = "branch=\"$branch\" AND url=\"$url\""; + $query = "SELECT * FROM proto WHERE $condition"; + $result = $mysqli->query($query) or error($mysqli->error); + die(json_encode($result)); + ?> diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 29dcb69a3..6e0469bd4 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1735,6 +1735,13 @@ document.addEventListener('DOMContentLoaded', function() { fields += fieldString + '\n'; } } + fetch('ajax/proto/documentation.php', {method: 'post', body: JSON.stringify({url: protoURl})}) + .then(function(response) { + return response.json(); + }) + .then(content => { + console.log(content); + }); fetch('https://cyberbotics.com/wwi/proto/protoVisualizer/temporary-proto-list.xml') .then(result => result.text()) .then(content => { From 4914e108197d8154d5f65ad9d5431623ffe63985 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 08:26:09 +0100 Subject: [PATCH 302/459] log --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 6e0469bd4..293e9e381 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1740,7 +1740,7 @@ document.addEventListener('DOMContentLoaded', function() { return response.json(); }) .then(content => { - console.log(content); + console.log(protoURl); }); fetch('https://cyberbotics.com/wwi/proto/protoVisualizer/temporary-proto-list.xml') .then(result => result.text()) From 496fd7761a744194556ab6cd60b4928f9c3c6f17 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 08:29:11 +0100 Subject: [PATCH 303/459] content --- httpdocs/ajax/proto/documentation.php | 2 +- httpdocs/js/webots-cloud.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/documentation.php b/httpdocs/ajax/proto/documentation.php index 49262e7f3..5498595b6 100644 --- a/httpdocs/ajax/proto/documentation.php +++ b/httpdocs/ajax/proto/documentation.php @@ -12,7 +12,7 @@ function error($message) { $mysqli->set_charset('utf8'); $branch = basename(dirname(__FILE__, 4)); $url = $mysqli->escape_string($data->url); - $condition = "branch=\"$branch\" AND url=\"$url\""; + $condition = "branch=\"$branch\""; $query = "SELECT * FROM proto WHERE $condition"; $result = $mysqli->query($query) or error($mysqli->error); die(json_encode($result)); diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 293e9e381..6e0469bd4 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1740,7 +1740,7 @@ document.addEventListener('DOMContentLoaded', function() { return response.json(); }) .then(content => { - console.log(protoURl); + console.log(content); }); fetch('https://cyberbotics.com/wwi/proto/protoVisualizer/temporary-proto-list.xml') .then(result => result.text()) From ff884f73c8aa31ced8e82ab35594d173fc9da4dd Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 08:30:30 +0100 Subject: [PATCH 304/459] test --- httpdocs/ajax/proto/documentation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/documentation.php b/httpdocs/ajax/proto/documentation.php index 5498595b6..4131646f9 100644 --- a/httpdocs/ajax/proto/documentation.php +++ b/httpdocs/ajax/proto/documentation.php @@ -12,8 +12,8 @@ function error($message) { $mysqli->set_charset('utf8'); $branch = basename(dirname(__FILE__, 4)); $url = $mysqli->escape_string($data->url); - $condition = "branch=\"$branch\""; + $condition = "branch=\"$branch\" AND url=\"$url\""; $query = "SELECT * FROM proto WHERE $condition"; $result = $mysqli->query($query) or error($mysqli->error); - die(json_encode($result)); + die($result); ?> From b6d578067f8388457b9e91d6f13918e69dfce141 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 08:30:58 +0100 Subject: [PATCH 305/459] log --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 6e0469bd4..5320824be 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1737,7 +1737,7 @@ document.addEventListener('DOMContentLoaded', function() { } fetch('ajax/proto/documentation.php', {method: 'post', body: JSON.stringify({url: protoURl})}) .then(function(response) { - return response.json(); + return response.text(); }) .then(content => { console.log(content); From 61024614f53e0789c5929a379ec1233dd30b979d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 08:32:15 +0100 Subject: [PATCH 306/459] test --- httpdocs/ajax/proto/documentation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/documentation.php b/httpdocs/ajax/proto/documentation.php index 4131646f9..289cdf853 100644 --- a/httpdocs/ajax/proto/documentation.php +++ b/httpdocs/ajax/proto/documentation.php @@ -15,5 +15,5 @@ function error($message) { $condition = "branch=\"$branch\" AND url=\"$url\""; $query = "SELECT * FROM proto WHERE $condition"; $result = $mysqli->query($query) or error($mysqli->error); - die($result); + die($result->fetch_array(MYSQLI_ASSOC)); ?> From 1d4e4bd677033aa9948b93e87956f716a08febf6 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 08:32:47 +0100 Subject: [PATCH 307/459] json --- httpdocs/ajax/proto/documentation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/documentation.php b/httpdocs/ajax/proto/documentation.php index 289cdf853..6e8613635 100644 --- a/httpdocs/ajax/proto/documentation.php +++ b/httpdocs/ajax/proto/documentation.php @@ -15,5 +15,5 @@ function error($message) { $condition = "branch=\"$branch\" AND url=\"$url\""; $query = "SELECT * FROM proto WHERE $condition"; $result = $mysqli->query($query) or error($mysqli->error); - die($result->fetch_array(MYSQLI_ASSOC)); + die(json_encode($result->fetch_array(MYSQLI_ASSOC))); ?> From 4b026e6f9f17b0bf3c8a97ef92cb762da61c7df7 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 08:40:19 +0100 Subject: [PATCH 308/459] restrict queried field --- httpdocs/ajax/proto/documentation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/documentation.php b/httpdocs/ajax/proto/documentation.php index 6e8613635..aad8efe71 100644 --- a/httpdocs/ajax/proto/documentation.php +++ b/httpdocs/ajax/proto/documentation.php @@ -13,7 +13,7 @@ function error($message) { $branch = basename(dirname(__FILE__, 4)); $url = $mysqli->escape_string($data->url); $condition = "branch=\"$branch\" AND url=\"$url\""; - $query = "SELECT * FROM proto WHERE $condition"; + $query = "SELECT base_type, descritption, version, license, license_url FROM proto WHERE $condition"; $result = $mysqli->query($query) or error($mysqli->error); die(json_encode($result->fetch_array(MYSQLI_ASSOC))); ?> From 24dffd9baaaa782556fd843215cd4d064101eb89 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 08:40:37 +0100 Subject: [PATCH 309/459] typo --- httpdocs/ajax/proto/documentation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/documentation.php b/httpdocs/ajax/proto/documentation.php index aad8efe71..6741c83dc 100644 --- a/httpdocs/ajax/proto/documentation.php +++ b/httpdocs/ajax/proto/documentation.php @@ -13,7 +13,7 @@ function error($message) { $branch = basename(dirname(__FILE__, 4)); $url = $mysqli->escape_string($data->url); $condition = "branch=\"$branch\" AND url=\"$url\""; - $query = "SELECT base_type, descritption, version, license, license_url FROM proto WHERE $condition"; + $query = "SELECT base_type, description, version, license, license_url FROM proto WHERE $condition"; $result = $mysqli->query($query) or error($mysqli->error); die(json_encode($result->fetch_array(MYSQLI_ASSOC))); ?> From f274a0d6b9ee15476c5abd0ea7a6efa8f4508beb Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 08:51:18 +0100 Subject: [PATCH 310/459] replace --- httpdocs/js/webots-cloud.js | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 5320824be..395eb7a59 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1740,26 +1740,8 @@ document.addEventListener('DOMContentLoaded', function() { return response.text(); }) .then(content => { - console.log(content); - }); - fetch('https://cyberbotics.com/wwi/proto/protoVisualizer/temporary-proto-list.xml') - .then(result => result.text()) - .then(content => { - const xml = new window.DOMParser().parseFromString(content, 'text/xml'); - const protos = xml.getElementsByTagName('proto'); - let protoNode; - for (const proto of protos) { - if (proto.getElementsByTagName('name')[0].textContent === protoName) { - protoNode = proto; - break; - } - } - - if (!protoNode) - return; - - const baseType = protoNode.getElementsByTagName('base-type')[0].textContent; - const description = protoNode.getElementsByTagName('description')[0].textContent.replace('\\n', ''); + const baseType = content.baseType; + const description = content.description; file += description + '\n\n'; file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; file += '```\n'; @@ -1804,15 +1786,9 @@ document.addEventListener('DOMContentLoaded', function() { } } - const license = protoNode.getElementsByTagName('license')[0]?.textContent; - const licenseUrl = protoNode.getElementsByTagName('license-url')[0]?.textContent; - let version; - for (const line of proto.split('\n')) { - if (line.startsWith('#VRML_SIM') || line.startsWith('# VRML_SIM')) { - version = line.substring(line.indexOf('VRML_SIM') + 9).split(' ')[0]; - break; - } - } + const license = content.license; + const licenseUrl = content.license_url; + let version = content.version; populateProtoViewDiv(file, prefix, createProtoArray(version, license, licenseUrl, protoURl)); }); } From 294005ab752c051c5a369e675a29cab906091b4d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 08:51:47 +0100 Subject: [PATCH 311/459] typo --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 395eb7a59..b604b1ddd 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1740,7 +1740,7 @@ document.addEventListener('DOMContentLoaded', function() { return response.text(); }) .then(content => { - const baseType = content.baseType; + const baseType = content.base_type; const description = content.description; file += description + '\n\n'; file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; From 38e7dcd503373e5881a096e216f076253c0cd073 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 08:53:00 +0100 Subject: [PATCH 312/459] log --- httpdocs/js/webots-cloud.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index b604b1ddd..6efffed75 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1740,10 +1740,11 @@ document.addEventListener('DOMContentLoaded', function() { return response.text(); }) .then(content => { + console.log(content) const baseType = content.base_type; const description = content.description; file += description + '\n\n'; - file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType.toLowerCase() + ').\n\n'; + file += 'Derived from [' + baseType + '](https://cyberbotics.com/doc/reference/' + baseType?.toLowerCase() + ').\n\n'; file += '```\n'; file += protoName + ' {\n'; file += fields; From 09854d31d6c41671ed5ee39ebdd433b94ebee0eb Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 08:53:51 +0100 Subject: [PATCH 313/459] json --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 6efffed75..b41c6cef5 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1737,7 +1737,7 @@ document.addEventListener('DOMContentLoaded', function() { } fetch('ajax/proto/documentation.php', {method: 'post', body: JSON.stringify({url: protoURl})}) .then(function(response) { - return response.text(); + return response.json(); }) .then(content => { console.log(content) From deaad217edb63a0bc57fe0ed7ab3029c8e36c3e4 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 08:56:10 +0100 Subject: [PATCH 314/459] remove log --- httpdocs/js/webots-cloud.js | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index b41c6cef5..53fffe9d0 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1740,7 +1740,6 @@ document.addEventListener('DOMContentLoaded', function() { return response.json(); }) .then(content => { - console.log(content) const baseType = content.base_type; const description = content.description; file += description + '\n\n'; From 1e5d0829db0c867cc030cd66397b16c51fe587a3 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 10:25:26 +0100 Subject: [PATCH 315/459] try --- httpdocs/ajax/proto/insertable.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 httpdocs/ajax/proto/insertable.php diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php new file mode 100644 index 000000000..c332d9d03 --- /dev/null +++ b/httpdocs/ajax/proto/insertable.php @@ -0,0 +1,30 @@ +connect_errno) + error("Can't connect to MySQL database: $mysqli->connect_error"); + $mysqli->set_charset('utf8'); + $base_types = $mysqli->escape_string($data->base_types); + $branch = basename(dirname(__FILE__, 4)); + $placeholders = implode(',', array_fill(0, count($base_types), '?')); + $condition = "branch=\"$branch\" and base_type IN ( $placeholders)"; + $query = $mysqli->prepare("SELECT * FROM proto WHERE $condition"); + $query->execute($base_type); + $protos = array(); + while($row = $query->fetch_assoc()) { + settype($row['id'], 'integer'); + settype($row['viewed'], 'integer'); + settype($row['stars'], 'integer'); + $row['title'] = htmlentities($row['title']); + $row['description'] = htmlentities($row['description']); + $row['version'] = htmlentities($row['version']); + array_push($protos, $row); + } + die(json_encode($protos)); + ?> From 6052682143a5bc46bf52836711640cb438da6e0e Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 10:30:14 +0100 Subject: [PATCH 316/459] move --- httpdocs/ajax/proto/node_insert/.htaccess | 4 ++++ httpdocs/ajax/proto/{ => node_insert}/insertable.php | 0 2 files changed, 4 insertions(+) create mode 100644 httpdocs/ajax/proto/node_insert/.htaccess rename httpdocs/ajax/proto/{ => node_insert}/insertable.php (100%) diff --git a/httpdocs/ajax/proto/node_insert/.htaccess b/httpdocs/ajax/proto/node_insert/.htaccess new file mode 100644 index 000000000..004dd9596 --- /dev/null +++ b/httpdocs/ajax/proto/node_insert/.htaccess @@ -0,0 +1,4 @@ + + Header set Access-Control-Allow-Origin "*" + + diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/node_insert/insertable.php similarity index 100% rename from httpdocs/ajax/proto/insertable.php rename to httpdocs/ajax/proto/node_insert/insertable.php From f492a4196d61b8c14f41b8e4bb2b8062fce9d293 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 10:31:38 +0100 Subject: [PATCH 317/459] test --- httpdocs/ajax/proto/{node_insert => }/.htaccess | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename httpdocs/ajax/proto/{node_insert => }/.htaccess (100%) diff --git a/httpdocs/ajax/proto/node_insert/.htaccess b/httpdocs/ajax/proto/.htaccess similarity index 100% rename from httpdocs/ajax/proto/node_insert/.htaccess rename to httpdocs/ajax/proto/.htaccess From 30797bf92a4541903ddb038bc3169f00822ba22e Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 10:47:58 +0100 Subject: [PATCH 318/459] move --- httpdocs/ajax/proto/{ => node_insert}/.htaccess | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename httpdocs/ajax/proto/{ => node_insert}/.htaccess (100%) diff --git a/httpdocs/ajax/proto/.htaccess b/httpdocs/ajax/proto/node_insert/.htaccess similarity index 100% rename from httpdocs/ajax/proto/.htaccess rename to httpdocs/ajax/proto/node_insert/.htaccess From 37cf2e7702e83333b76cf1ec248e33963e77b071 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 10:49:09 +0100 Subject: [PATCH 319/459] path --- httpdocs/ajax/proto/node_insert/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/node_insert/insertable.php b/httpdocs/ajax/proto/node_insert/insertable.php index c332d9d03..487a4d538 100644 --- a/httpdocs/ajax/proto/node_insert/insertable.php +++ b/httpdocs/ajax/proto/node_insert/insertable.php @@ -5,7 +5,7 @@ function error($message) { header('Content-Type: application/json'); $json = file_get_contents('php://input'); $data = json_decode($json); - require '../../../php/database.php'; + require '../../../../php/database.php'; $mysqli = new mysqli($database_host, $database_username, $database_password, $database_name); if ($mysqli->connect_errno) error("Can't connect to MySQL database: $mysqli->connect_error"); From 4e1afb4b68e00c7c148614110aaf67883ca775b4 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 10:49:52 +0100 Subject: [PATCH 320/459] test --- httpdocs/ajax/proto/node_insert/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/node_insert/insertable.php b/httpdocs/ajax/proto/node_insert/insertable.php index 487a4d538..5eda6a983 100644 --- a/httpdocs/ajax/proto/node_insert/insertable.php +++ b/httpdocs/ajax/proto/node_insert/insertable.php @@ -26,5 +26,5 @@ function error($message) { $row['version'] = htmlentities($row['version']); array_push($protos, $row); } - die(json_encode($protos)); + die("Bonjour"); ?> From d54492cb6baf9018acd011ea3abe6e03d20f73b3 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 10:53:37 +0100 Subject: [PATCH 321/459] htaccess --- httpdocs/ajax/proto/{node_insert => }/.htaccess | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename httpdocs/ajax/proto/{node_insert => }/.htaccess (100%) diff --git a/httpdocs/ajax/proto/node_insert/.htaccess b/httpdocs/ajax/proto/.htaccess similarity index 100% rename from httpdocs/ajax/proto/node_insert/.htaccess rename to httpdocs/ajax/proto/.htaccess From db6c502c5fd854717dd8d37a145f8be6eef3dce5 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 10:56:11 +0100 Subject: [PATCH 322/459] cors --- httpdocs/ajax/proto/.htaccess | 4 ---- httpdocs/ajax/proto/{node_insert => }/insertable.php | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 httpdocs/ajax/proto/.htaccess rename httpdocs/ajax/proto/{node_insert => }/insertable.php (96%) diff --git a/httpdocs/ajax/proto/.htaccess b/httpdocs/ajax/proto/.htaccess deleted file mode 100644 index 004dd9596..000000000 --- a/httpdocs/ajax/proto/.htaccess +++ /dev/null @@ -1,4 +0,0 @@ - - Header set Access-Control-Allow-Origin "*" - - diff --git a/httpdocs/ajax/proto/node_insert/insertable.php b/httpdocs/ajax/proto/insertable.php similarity index 96% rename from httpdocs/ajax/proto/node_insert/insertable.php rename to httpdocs/ajax/proto/insertable.php index 5eda6a983..9e0596c2a 100644 --- a/httpdocs/ajax/proto/node_insert/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -3,6 +3,7 @@ function error($message) { die("{\"error\":\"$message\"}"); } header('Content-Type: application/json'); + header("Access-Control-Allow-Origin: *"); $json = file_get_contents('php://input'); $data = json_decode($json); require '../../../../php/database.php'; From a7e7e36529ff1861a20e9312f9f40410c34dc144 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 10:57:22 +0100 Subject: [PATCH 323/459] .. --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 9e0596c2a..33b0d4b91 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -6,7 +6,7 @@ function error($message) { header("Access-Control-Allow-Origin: *"); $json = file_get_contents('php://input'); $data = json_decode($json); - require '../../../../php/database.php'; + require '../../../php/database.php'; $mysqli = new mysqli($database_host, $database_username, $database_password, $database_name); if ($mysqli->connect_errno) error("Can't connect to MySQL database: $mysqli->connect_error"); From 959e208c7447ed36872830edcff7f709f8777915 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 10:59:56 +0100 Subject: [PATCH 324/459] base_type --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 33b0d4b91..432b914ce 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -11,7 +11,7 @@ function error($message) { if ($mysqli->connect_errno) error("Can't connect to MySQL database: $mysqli->connect_error"); $mysqli->set_charset('utf8'); - $base_types = $mysqli->escape_string($data->base_types); + $base_types = $data->base_types; $branch = basename(dirname(__FILE__, 4)); $placeholders = implode(',', array_fill(0, count($base_types), '?')); $condition = "branch=\"$branch\" and base_type IN ( $placeholders)"; From 710a2dd101e72a562bbc78c0959e7270b53887bd Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:00:31 +0100 Subject: [PATCH 325/459] typo --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 432b914ce..51b150ba0 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,7 +16,7 @@ function error($message) { $placeholders = implode(',', array_fill(0, count($base_types), '?')); $condition = "branch=\"$branch\" and base_type IN ( $placeholders)"; $query = $mysqli->prepare("SELECT * FROM proto WHERE $condition"); - $query->execute($base_type); + $query->execute($base_types); $protos = array(); while($row = $query->fetch_assoc()) { settype($row['id'], 'integer'); From be0321374f2e1559c2abb3118a446fc3856db13f Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:07:04 +0100 Subject: [PATCH 326/459] free --- httpdocs/ajax/proto/insertable.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 51b150ba0..2b53a2825 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -17,8 +17,9 @@ function error($message) { $condition = "branch=\"$branch\" and base_type IN ( $placeholders)"; $query = $mysqli->prepare("SELECT * FROM proto WHERE $condition"); $query->execute($base_types); + $result = $query->get_result(); $protos = array(); - while($row = $query->fetch_assoc()) { + while($row = $result->fetch_assoc()) { settype($row['id'], 'integer'); settype($row['viewed'], 'integer'); settype($row['stars'], 'integer'); @@ -27,5 +28,6 @@ function error($message) { $row['version'] = htmlentities($row['version']); array_push($protos, $row); } + $result->free(); die("Bonjour"); ?> From d7aa6f001849d9881ff9e1c6fb6bb5df6137140c Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:08:58 +0100 Subject: [PATCH 327/459] return --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 2b53a2825..2b41cc28c 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -29,5 +29,5 @@ function error($message) { array_push($protos, $row); } $result->free(); - die("Bonjour"); + die(json_encode($protos); ?> From e3d0a1c1a5004b2d07b93a317f2adeccb6798a0f Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:12:40 +0100 Subject: [PATCH 328/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 2b41cc28c..2b53a2825 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -29,5 +29,5 @@ function error($message) { array_push($protos, $row); } $result->free(); - die(json_encode($protos); + die("Bonjour"); ?> From 287ef3f96ebfb990bb5ea2597aff52a75c27012e Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:13:22 +0100 Subject: [PATCH 329/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 2b53a2825..d9173c145 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -29,5 +29,5 @@ function error($message) { array_push($protos, $row); } $result->free(); - die("Bonjour"); + die(json_encode($base_types)); ?> From c905a045422dc605f86ddac34602caf2ac3db3a0 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:13:57 +0100 Subject: [PATCH 330/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index d9173c145..c72640116 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -29,5 +29,5 @@ function error($message) { array_push($protos, $row); } $result->free(); - die(json_encode($base_types)); + die(json_encode($row)); ?> From b4ecfe6e4f183e7ede025473a678b845cf043ff1 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:16:44 +0100 Subject: [PATCH 331/459] test --- httpdocs/ajax/proto/insertable.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index c72640116..eac84279e 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -19,15 +19,15 @@ function error($message) { $query->execute($base_types); $result = $query->get_result(); $protos = array(); - while($row = $result->fetch_assoc()) { - settype($row['id'], 'integer'); - settype($row['viewed'], 'integer'); - settype($row['stars'], 'integer'); - $row['title'] = htmlentities($row['title']); - $row['description'] = htmlentities($row['description']); - $row['version'] = htmlentities($row['version']); - array_push($protos, $row); - } + // while($row = ) { + // settype($row['id'], 'integer'); + // settype($row['viewed'], 'integer'); + // settype($row['stars'], 'integer'); + // $row['title'] = htmlentities($row['title']); + // $row['description'] = htmlentities($row['description']); + // $row['version'] = htmlentities($row['version']); + // array_push($protos, $row); + // } $result->free(); - die(json_encode($row)); + die(json_encode($result->fetch_assoc())); ?> From 082f21201ad78ae6397348f3818a4663d448e2e6 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:17:13 +0100 Subject: [PATCH 332/459] result --- httpdocs/ajax/proto/insertable.php | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index eac84279e..55254dc31 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -28,6 +28,5 @@ function error($message) { // $row['version'] = htmlentities($row['version']); // array_push($protos, $row); // } - $result->free(); die(json_encode($result->fetch_assoc())); ?> From b3224e4bb3e673355d72c11b8cb83b734638e3df Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:18:04 +0100 Subject: [PATCH 333/459] branch --- httpdocs/ajax/proto/insertable.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 55254dc31..80ca210d7 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -19,7 +19,8 @@ function error($message) { $query->execute($base_types); $result = $query->get_result(); $protos = array(); - // while($row = ) { + $row = $result->fetch_assoc() + // while() { // settype($row['id'], 'integer'); // settype($row['viewed'], 'integer'); // settype($row['stars'], 'integer'); @@ -28,5 +29,6 @@ function error($message) { // $row['version'] = htmlentities($row['version']); // array_push($protos, $row); // } - die(json_encode($result->fetch_assoc())); + $result->free(); + die(json_encode($branch)); ?> From 0aed25bdeac554ac123393459a362123e1fe41f6 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:18:43 +0100 Subject: [PATCH 334/459] branch --- httpdocs/ajax/proto/insertable.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 80ca210d7..644a88be7 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -13,6 +13,8 @@ function error($message) { $mysqli->set_charset('utf8'); $base_types = $data->base_types; $branch = basename(dirname(__FILE__, 4)); + if (!$branch) + $branch = 'proto'; $placeholders = implode(',', array_fill(0, count($base_types), '?')); $condition = "branch=\"$branch\" and base_type IN ( $placeholders)"; $query = $mysqli->prepare("SELECT * FROM proto WHERE $condition"); From 1eab2b345e532e6f81d3aeb3988369738ddfe8e0 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:23:27 +0100 Subject: [PATCH 335/459] branch --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 644a88be7..42292d2a0 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -32,5 +32,5 @@ function error($message) { // array_push($protos, $row); // } $result->free(); - die(json_encode($branch)); + die($branch); ?> From 4c4c737dd1be7451249a709ee99a0e22fd208524 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:23:58 +0100 Subject: [PATCH 336/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 42292d2a0..3e25bba68 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -14,7 +14,7 @@ function error($message) { $base_types = $data->base_types; $branch = basename(dirname(__FILE__, 4)); if (!$branch) - $branch = 'proto'; + $branch = "proto"; $placeholders = implode(',', array_fill(0, count($base_types), '?')); $condition = "branch=\"$branch\" and base_type IN ( $placeholders)"; $query = $mysqli->prepare("SELECT * FROM proto WHERE $condition"); From 0b03dedfdd560d6be121432da565af30ee4b13c8 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:24:21 +0100 Subject: [PATCH 337/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 3e25bba68..5a35e2e5e 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -32,5 +32,5 @@ function error($message) { // array_push($protos, $row); // } $result->free(); - die($branch); + die("$branch"); ?> From 6c0f4764a961e5a368539fd80558aa4245dd6655 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:25:38 +0100 Subject: [PATCH 338/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 5a35e2e5e..24f98e49d 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -32,5 +32,5 @@ function error($message) { // array_push($protos, $row); // } $result->free(); - die("$branch"); + die("\"$branch\""); ?> From a8d257e919b0446db97dad1621b4d6770b3cac2a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:30:59 +0100 Subject: [PATCH 339/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 24f98e49d..0d231717a 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -21,7 +21,7 @@ function error($message) { $query->execute($base_types); $result = $query->get_result(); $protos = array(); - $row = $result->fetch_assoc() + $row = $result->fetch_assoc(); // while() { // settype($row['id'], 'integer'); // settype($row['viewed'], 'integer'); From f98c3346147e02518511bd40888dbd08891c1a54 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:31:33 +0100 Subject: [PATCH 340/459] rowg --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 0d231717a..d964b332d 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -32,5 +32,5 @@ function error($message) { // array_push($protos, $row); // } $result->free(); - die("\"$branch\""); + die(json_encode($row)); ?> From d9edaa5bbb36bf7b1db5015551c8a059f5c0c43e Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:34:30 +0100 Subject: [PATCH 341/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index d964b332d..61c326e2f 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -17,7 +17,7 @@ function error($message) { $branch = "proto"; $placeholders = implode(',', array_fill(0, count($base_types), '?')); $condition = "branch=\"$branch\" and base_type IN ( $placeholders)"; - $query = $mysqli->prepare("SELECT * FROM proto WHERE $condition"); + $query = $mysqli->prepare("SELECT * FROM proto"); $query->execute($base_types); $result = $query->get_result(); $protos = array(); From fc5892e68b7a3efd6a1694a4faa1385a3dee66fc Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:34:55 +0100 Subject: [PATCH 342/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 61c326e2f..8e10dc9b7 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -18,7 +18,7 @@ function error($message) { $placeholders = implode(',', array_fill(0, count($base_types), '?')); $condition = "branch=\"$branch\" and base_type IN ( $placeholders)"; $query = $mysqli->prepare("SELECT * FROM proto"); - $query->execute($base_types); + $query->execute(); $result = $query->get_result(); $protos = array(); $row = $result->fetch_assoc(); From 963ea1c9a162593e9443cfe8f2cc02ced402309e Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:35:38 +0100 Subject: [PATCH 343/459] test --- httpdocs/ajax/proto/insertable.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 8e10dc9b7..e664d926c 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,9 +16,9 @@ function error($message) { if (!$branch) $branch = "proto"; $placeholders = implode(',', array_fill(0, count($base_types), '?')); - $condition = "branch=\"$branch\" and base_type IN ( $placeholders)"; - $query = $mysqli->prepare("SELECT * FROM proto"); - $query->execute(); + $condition = "branch=\"$branch\" AND base_type IN ( $placeholders)"; + $query = $mysqli->prepare("SELECT * FROM proto WHERE $condition"); + $query->execute($base_types); $result = $query->get_result(); $protos = array(); $row = $result->fetch_assoc(); From 58457dfabb4118a0975a6a23de0950da7f06356c Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:36:33 +0100 Subject: [PATCH 344/459] test --- httpdocs/ajax/proto/insertable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index e664d926c..2d4fb575f 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,9 +16,9 @@ function error($message) { if (!$branch) $branch = "proto"; $placeholders = implode(',', array_fill(0, count($base_types), '?')); - $condition = "branch=\"$branch\" AND base_type IN ( $placeholders)"; + $condition = "branch=\"$branch\""; $query = $mysqli->prepare("SELECT * FROM proto WHERE $condition"); - $query->execute($base_types); + $query->execute(); $result = $query->get_result(); $protos = array(); $row = $result->fetch_assoc(); From 004d26a306cac97794a0f635ee6a8b4a1d385fa2 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:45:59 +0100 Subject: [PATCH 345/459] array --- httpdocs/ajax/proto/insertable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 2d4fb575f..059715d95 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,9 +16,9 @@ function error($message) { if (!$branch) $branch = "proto"; $placeholders = implode(',', array_fill(0, count($base_types), '?')); - $condition = "branch=\"$branch\""; + $condition = "branch=\"$branch\" AND base_type IN ( $placeholders)"; $query = $mysqli->prepare("SELECT * FROM proto WHERE $condition"); - $query->execute(); + $query->execute(['Transform', 'Robot', 'Solid']); $result = $query->get_result(); $protos = array(); $row = $result->fetch_assoc(); From 41d954cd36064bc21aeffc9264102633d9993af4 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:46:42 +0100 Subject: [PATCH 346/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 059715d95..3204c3e24 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -18,7 +18,7 @@ function error($message) { $placeholders = implode(',', array_fill(0, count($base_types), '?')); $condition = "branch=\"$branch\" AND base_type IN ( $placeholders)"; $query = $mysqli->prepare("SELECT * FROM proto WHERE $condition"); - $query->execute(['Transform', 'Robot', 'Solid']); + $query->execute(('Transform', 'Robot', 'Solid')); $result = $query->get_result(); $protos = array(); $row = $result->fetch_assoc(); From 56a532d21508fa849997bba59b16033ebacb07a9 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:47:44 +0100 Subject: [PATCH 347/459] test --- httpdocs/ajax/proto/insertable.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 3204c3e24..9094540a3 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -18,7 +18,8 @@ function error($message) { $placeholders = implode(',', array_fill(0, count($base_types), '?')); $condition = "branch=\"$branch\" AND base_type IN ( $placeholders)"; $query = $mysqli->prepare("SELECT * FROM proto WHERE $condition"); - $query->execute(('Transform', 'Robot', 'Solid')); + $arr = ['\"Transform\"', '\"Robot\"', '\"Solid\"']; + $query->execute($arr); $result = $query->get_result(); $protos = array(); $row = $result->fetch_assoc(); From fedf3d5bf15f2f302dfdad1fd46dfe4f07e0df7c Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:48:19 +0100 Subject: [PATCH 348/459] arrayg --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 9094540a3..7e56accc0 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -18,7 +18,7 @@ function error($message) { $placeholders = implode(',', array_fill(0, count($base_types), '?')); $condition = "branch=\"$branch\" AND base_type IN ( $placeholders)"; $query = $mysqli->prepare("SELECT * FROM proto WHERE $condition"); - $arr = ['\"Transform\"', '\"Robot\"', '\"Solid\"']; + $arr = ('\"Transform\"', '\"Robot\"', '\"Solid\"'); $query->execute($arr); $result = $query->get_result(); $protos = array(); From 4657fe5eb8a432b32a65b5f32ebaf7bd003ed660 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:54:25 +0100 Subject: [PATCH 349/459] test --- httpdocs/ajax/proto/insertable.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 7e56accc0..bea6620b3 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -15,12 +15,10 @@ function error($message) { $branch = basename(dirname(__FILE__, 4)); if (!$branch) $branch = "proto"; - $placeholders = implode(',', array_fill(0, count($base_types), '?')); - $condition = "branch=\"$branch\" AND base_type IN ( $placeholders)"; - $query = $mysqli->prepare("SELECT * FROM proto WHERE $condition"); - $arr = ('\"Transform\"', '\"Robot\"', '\"Solid\"'); - $query->execute($arr); - $result = $query->get_result(); + $condition = "branch=\"$branch\" AND base_type IN ('" + . implode("','", array_map('mysqli_real_escape_string', $base_types)) + . "')"; + $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); $row = $result->fetch_assoc(); // while() { From c2d40902062ed638b787faf2e06781af0afb6ea1 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:56:14 +0100 Subject: [PATCH 350/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index bea6620b3..979eb2665 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,7 +16,7 @@ function error($message) { if (!$branch) $branch = "proto"; $condition = "branch=\"$branch\" AND base_type IN ('" - . implode("','", array_map('mysqli_real_escape_string', $base_types)) + . implode("','", array_map('mysqli_real_escape_string', $mysqli, $base_types)) . "')"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From ff05edfee2a5245f2443ec607a245111c5f7b571 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 11:57:25 +0100 Subject: [PATCH 351/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 979eb2665..d172cca09 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,7 +16,7 @@ function error($message) { if (!$branch) $branch = "proto"; $condition = "branch=\"$branch\" AND base_type IN ('" - . implode("','", array_map('mysqli_real_escape_string', $mysqli, $base_types)) + . implode("','", array_map('mysql_real_escape_string', $base_types)) . "')"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From 5e15670bcd7376bfa03637a76684705c7ac54a96 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:01:15 +0100 Subject: [PATCH 352/459] test --- httpdocs/ajax/proto/insertable.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index d172cca09..2c1ce1378 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,7 +16,8 @@ function error($message) { if (!$branch) $branch = "proto"; $condition = "branch=\"$branch\" AND base_type IN ('" - . implode("','", array_map('mysql_real_escape_string', $base_types)) + . implode("','", array_map($base_types, function(&$string) use ($mysqli) { + mysqli_real_escape_string($mysqli, $base_types);})) . "')"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From c24377364b385ab33ab200d60c9b468756499963 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:04:12 +0100 Subject: [PATCH 353/459] test --- httpdocs/ajax/proto/insertable.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 2c1ce1378..55828bb02 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,8 +16,7 @@ function error($message) { if (!$branch) $branch = "proto"; $condition = "branch=\"$branch\" AND base_type IN ('" - . implode("','", array_map($base_types, function(&$string) use ($mysqli) { - mysqli_real_escape_string($mysqli, $base_types);})) + . implode("','", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) . "')"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From 207be31d86a35778d9495e949c538e9e77e5db5c Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:04:36 +0100 Subject: [PATCH 354/459] condition --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 55828bb02..2f6c208de 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -31,5 +31,5 @@ function error($message) { // array_push($protos, $row); // } $result->free(); - die(json_encode($row)); + die(json_encode($condition)); ?> From bd4c867f94d6774e29b0deff5e5d9b146d076bf0 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:06:26 +0100 Subject: [PATCH 355/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 2f6c208de..168debad2 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,7 +16,7 @@ function error($message) { if (!$branch) $branch = "proto"; $condition = "branch=\"$branch\" AND base_type IN ('" - . implode("','", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) + . implode("'\",\"'", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) . "')"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From a9d462a9226de876cc6803341c82ef8a3568dc6a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:06:54 +0100 Subject: [PATCH 356/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 168debad2..d57eba837 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,7 +16,7 @@ function error($message) { if (!$branch) $branch = "proto"; $condition = "branch=\"$branch\" AND base_type IN ('" - . implode("'\",\"'", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) + . implode("'\',\''", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) . "')"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From ac9cca5d0f17c57afd9b04b00df96cc36ea60b00 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:07:52 +0100 Subject: [PATCH 357/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index d57eba837..94811dff0 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,7 +16,7 @@ function error($message) { if (!$branch) $branch = "proto"; $condition = "branch=\"$branch\" AND base_type IN ('" - . implode("'\',\''", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) + . implode("'\\',\\''", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) . "')"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From 88141eca14e9cfe6fc2ac81a779ad9550cadd569 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:09:47 +0100 Subject: [PATCH 358/459] test --- httpdocs/ajax/proto/insertable.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 94811dff0..5b8ea7e54 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -15,9 +15,9 @@ function error($message) { $branch = basename(dirname(__FILE__, 4)); if (!$branch) $branch = "proto"; - $condition = "branch=\"$branch\" AND base_type IN ('" - . implode("'\\',\\''", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) - . "')"; + $condition = "branch=\"$branch\" AND base_type IN (\"" + . implode("'\",\"", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) + . "\")"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); $row = $result->fetch_assoc(); From 039b9cc3fb3ecf08ad59988ba771c62aecce6fc1 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:11:40 +0100 Subject: [PATCH 359/459] test --- httpdocs/ajax/proto/insertable.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 5b8ea7e54..2c65c5a65 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -15,9 +15,9 @@ function error($message) { $branch = basename(dirname(__FILE__, 4)); if (!$branch) $branch = "proto"; - $condition = "branch=\"$branch\" AND base_type IN (\"" - . implode("'\",\"", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) - . "\")"; + $condition = "branch=\"$branch\" AND base_type IN ('" + . implode("','", "\"".array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)."\"") + . "')"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); $row = $result->fetch_assoc(); From 37aadbe7665b4a10d580ab778a29dbcafcc5a4ac Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:12:54 +0100 Subject: [PATCH 360/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 2c65c5a65..84c06f5c5 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,7 +16,7 @@ function error($message) { if (!$branch) $branch = "proto"; $condition = "branch=\"$branch\" AND base_type IN ('" - . implode("','", "\"".array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)."\"") + . implode("',\\\"'", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) . "')"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From 273280b217f1b01df438c413b4662144736484b8 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:13:26 +0100 Subject: [PATCH 361/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 84c06f5c5..7784aadc4 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,7 +16,7 @@ function error($message) { if (!$branch) $branch = "proto"; $condition = "branch=\"$branch\" AND base_type IN ('" - . implode("',\\\"'", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) + . implode("',\\\\\"'", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) . "')"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From a87044142a52877bf26de117eb3f007deac54eb3 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:14:04 +0100 Subject: [PATCH 362/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 7784aadc4..ece27f883 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,7 +16,7 @@ function error($message) { if (!$branch) $branch = "proto"; $condition = "branch=\"$branch\" AND base_type IN ('" - . implode("',\\\\\"'", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) + . implode("\',\'", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) . "')"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From eb75eaa581269d6de1293fcba4fdb7df13d626e8 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:15:59 +0100 Subject: [PATCH 363/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index ece27f883..c82cdbad1 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -31,5 +31,5 @@ function error($message) { // array_push($protos, $row); // } $result->free(); - die(json_encode($condition)); + die(json_encode($row)); ?> From 3349d17570207b8e500aa3f498221760f24908e1 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:16:39 +0100 Subject: [PATCH 364/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index c82cdbad1..55828bb02 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,7 +16,7 @@ function error($message) { if (!$branch) $branch = "proto"; $condition = "branch=\"$branch\" AND base_type IN ('" - . implode("\',\'", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) + . implode("','", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) . "')"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From 5b4e2987b199a4f8173c7c2e186e9497830b923f Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:17:10 +0100 Subject: [PATCH 365/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 55828bb02..9387cfcb1 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,7 +16,7 @@ function error($message) { if (!$branch) $branch = "proto"; $condition = "branch=\"$branch\" AND base_type IN ('" - . implode("','", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) + . implode("','", $base_types) . "')"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From a1a0cbfe28d763e7ae9776b22dfc3ded0cd95cd4 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:17:33 +0100 Subject: [PATCH 366/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 9387cfcb1..1af0d4f6b 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -31,5 +31,5 @@ function error($message) { // array_push($protos, $row); // } $result->free(); - die(json_encode($row)); + die(json_encode($condition)); ?> From 3403d85a87d2cb753c7b12d7e6923cbb98068719 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:18:10 +0100 Subject: [PATCH 367/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 1af0d4f6b..c8b9a0b15 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,7 +16,7 @@ function error($message) { if (!$branch) $branch = "proto"; $condition = "branch=\"$branch\" AND base_type IN ('" - . implode("','", $base_types) + . implode("',1'", $base_types) . "')"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From fc7c9b302c51560b9e775df71d3583c31ad0ad77 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:19:49 +0100 Subject: [PATCH 368/459] test --- httpdocs/ajax/proto/insertable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index c8b9a0b15..55828bb02 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -16,7 +16,7 @@ function error($message) { if (!$branch) $branch = "proto"; $condition = "branch=\"$branch\" AND base_type IN ('" - . implode("',1'", $base_types) + . implode("','", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) . "')"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); @@ -31,5 +31,5 @@ function error($message) { // array_push($protos, $row); // } $result->free(); - die(json_encode($condition)); + die(json_encode($row)); ?> From bd8332b3282623cf2ce6647c60c903bf12119487 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:23:17 +0100 Subject: [PATCH 369/459] test --- httpdocs/ajax/proto/insertable.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 55828bb02..495a97bbe 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -20,16 +20,9 @@ function error($message) { . "')"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); - $row = $result->fetch_assoc(); - // while() { - // settype($row['id'], 'integer'); - // settype($row['viewed'], 'integer'); - // settype($row['stars'], 'integer'); - // $row['title'] = htmlentities($row['title']); - // $row['description'] = htmlentities($row['description']); - // $row['version'] = htmlentities($row['version']); - // array_push($protos, $row); - // } + while($row = $result->fetch_assoc()) { + array_push($protos, $row); + } $result->free(); - die(json_encode($row)); + die(json_encode($protos)); ?> From 0e350e6f248d824ed97407c8ac9a8451526603e9 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 12:35:59 +0100 Subject: [PATCH 370/459] slot_type --- httpdocs/ajax/proto/insertable.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 495a97bbe..44db42644 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -18,6 +18,9 @@ function error($message) { $condition = "branch=\"$branch\" AND base_type IN ('" . implode("','", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) . "')"; + $slot_type = $data->slotType; + if ($slot_type) + $condition .= " AND slot_type=".$mysqli->escape_string($slot_type); $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); while($row = $result->fetch_assoc()) { From d8c31340b89399f64c7246f97529cc4374892ac9 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 13:40:00 +0100 Subject: [PATCH 371/459] test --- httpdocs/ajax/proto/insertable.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 44db42644..5a916a1c9 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -18,8 +18,9 @@ function error($message) { $condition = "branch=\"$branch\" AND base_type IN ('" . implode("','", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) . "')"; - $slot_type = $data->slotType; - if ($slot_type) + + if (isset($data->slotType)); + $slot_type = $data->slotType; $condition .= " AND slot_type=".$mysqli->escape_string($slot_type); $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From 88ebfc122b6bd6b57e18bd372ee2f12daea78f05 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 13:58:15 +0100 Subject: [PATCH 372/459] test --- httpdocs/ajax/proto/insertable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 5a916a1c9..8016b76f2 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -19,8 +19,8 @@ function error($message) { . implode("','", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) . "')"; - if (isset($data->slotType)); - $slot_type = $data->slotType; + if (isset($data->slot_type)); + $slot_type = $data->slot_type; $condition .= " AND slot_type=".$mysqli->escape_string($slot_type); $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From 977de55bcdedb5c183fef08b3709275542399fba Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 13:58:52 +0100 Subject: [PATCH 373/459] test --- httpdocs/ajax/proto/insertable.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 8016b76f2..9afdee322 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -19,9 +19,10 @@ function error($message) { . implode("','", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) . "')"; - if (isset($data->slot_type)); + if (isset($data->slot_type)){ $slot_type = $data->slot_type; $condition .= " AND slot_type=".$mysqli->escape_string($slot_type); + } $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); while($row = $result->fetch_assoc()) { From 8592d1d17cd41a56368460dc07d5623eea954b71 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 14:04:21 +0100 Subject: [PATCH 374/459] test --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 9afdee322..6a91a50ae 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -21,7 +21,7 @@ function error($message) { if (isset($data->slot_type)){ $slot_type = $data->slot_type; - $condition .= " AND slot_type=".$mysqli->escape_string($slot_type); + $condition .= " AND slot_type=\"".$mysqli->escape_string($slot_type)."\""; } $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From 15baf892a8dd28b8d569c6d67d26f373c576bd63 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 14:19:11 +0100 Subject: [PATCH 375/459] test --- httpdocs/ajax/proto/insertable.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 6a91a50ae..d934dc12c 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -23,6 +23,9 @@ function error($message) { $slot_type = $data->slot_type; $condition .= " AND slot_type=\"".$mysqli->escape_string($slot_type)."\""; } + + if (isset($data->skip_no_robot_ancestor && $data->skip_no_robot_ancestor)) + $condition .= " AND needs_robot_ancestor=0"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); while($row = $result->fetch_assoc()) { From b448678b02cc73ad211833791b9a49626ce2ee81 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 14:19:58 +0100 Subject: [PATCH 376/459] typo --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index d934dc12c..522e056f6 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -24,7 +24,7 @@ function error($message) { $condition .= " AND slot_type=\"".$mysqli->escape_string($slot_type)."\""; } - if (isset($data->skip_no_robot_ancestor && $data->skip_no_robot_ancestor)) + if (isset($data->skip_no_robot_ancestor) && $data->skip_no_robot_ancestor) $condition .= " AND needs_robot_ancestor=0"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); From b05622a66cc0c2c489e597e50c855d04641f44c4 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 14:25:37 +0100 Subject: [PATCH 377/459] udpate --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 40de92246..170ff7a32 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -230,7 +230,7 @@ function error($message) { ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license_url\", \"$license\", \"$base_type\", \"$needs_robot_ancestor\", \"$slot_type\")"; else $query = "UPDATE proto SET viewed=$viewed, stars=$stars, title=\"$title\", description=\"$description\", " - ."version=\"$version\", updated=NOW() " + ."version=\"$version\", updated=NOW(), license_url=\"$license_url\", license=\"$license\", base_type=\"$base_type\", needs_robot_ancestor=\"$needs_robot_ancestor\", slot_type=\"$slot_type\" " ."WHERE url=\"$url\" AND id=$id"; $mysqli->query($query) or error($mysqli->error); if ($mysqli->affected_rows != 1) { From 16c41e553836d7f16a7137c79874c7ec405e1067 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 14:49:03 +0100 Subject: [PATCH 378/459] clean up --- httpdocs/ajax/proto/create.php | 106 +++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 46 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 170ff7a32..05cd11557 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -139,7 +139,8 @@ function error($message) { $line = strtok("\r\n"); } - preg_match("/(?:\]\s*)\{\s*(?:\%\<[\s\S]*?(?:\>\%\s*))?(?:DEF\s+[^\s]+)?\s+([a-zA-Z0-9\_\-\+]+)\s*\{/", $extern_proto_content, $match); + preg_match("/(?:\]\s*)\{\s*(?:\%\<[\s\S]*?(?:\>\%\s*))?(?:DEF\s+[^\s]+)?\s+([a-zA-Z0-9\_\-\+]+)\s*\{/", + $extern_proto_content, $match); if ($match) $base_type = $match[1]; @@ -158,55 +159,20 @@ function error($message) { $slot_type = ''; if ($base_type === "Slot") { $found = false; - $current_proto = $proto_content; + $current_proto_content = $proto_content; $externprotos = $original_externprotos; $parent_url = $url; while(!$found) { - preg_match("/type\s+\"([a-zA-Z0-9\_\-\+\s]+)\"/", $current_proto, $match); + preg_match("/type\s+\"([a-zA-Z0-9\_\-\+\s]+)\"/", $current_proto_content, $match); if ($match) { $slot_type = $match[1]; $found = true; } else { - for($i = 0; $i < count($externprotos); $i++) { - if ($externprotos[$i][0] === $base_proto) { - $found_parent = true; - $extern_url = $externprotos[$i][1]; - if (str_starts_with($extern_url, "webots://")) - $extern_url = str_replace("webots://", "https://github.com/cyberbotics/webots/blob/released/", $extern_url); - else if (!srt_starts_with($extern_url, "https")) - $extern_url = substr($parent_url, 0, strrpos($parent_url, '/') + 1).$extern_url; - $parent_url = $extern_url; - $check_url = proto_check_url($extern_url); - if (!is_array($check_url)) - error($check_url); - list($extern_username, $extern_repository, $extern_tag_or_branch, $extern_folder, $extern_proto) = $check_url; - $extern_proto_url = "https://raw.githubusercontent.com/$extern_username/$extern_repository/$extern_tag_or_branch$extern_folder/protos/$extern_proto"; - $extern_proto_content = @file_get_contents($extern_proto_url); - $current_proto = $extern_proto_content; - if ($extern_proto_content === false) - error("Could not retrieve parent proto with url'$extern_url'"); - - $line = strtok($extern_proto_content, "\r\n"); - $line = strtok("\r\n"); - $externprotos = []; - while ($line !== false) { - $line == trim($line); - if (substr($line, 0, 11) === 'EXTERNPROTO') { - $proto_url = trim(str_replace('"', '',str_replace('EXTERNPROTO', '', $line))); - $proto_name = str_replace('.proto"', '', $line); - $proto_name = substr($proto_name, strrpos($proto_name, '/') + 1); - array_push($externprotos, [$proto_name, $proto_url]); - } - $line = strtok("\r\n"); - } - - preg_match("/(?:\]\s*)\{\s*(?:\%\<[\s\S]*?(?:\>\%\s*))?(?:DEF\s+[^\s]+)?\s+([a-zA-Z0-9\_\-\+]+)\s*\{/", $extern_proto_content, $match); - if ($match) - $base_proto = $match[1]; - - break; - } - } + $results = get_parent($externprotos, $base_proto, $parent_url); + $externprotos = $results[0]; + $base_proto = $results[1]; + $current_proto_content = $results[2]; + $parent_url = $results[3]; if(!$found_parent) error("Seems like the parent node is missing from the EXTERNPROTO."); } @@ -226,11 +192,14 @@ function error($message) { $viewed = ($result && $row) ? $row['viewed'] : 0; $branch = basename(dirname(__FILE__, 4)); if ($id === 0) - $query = "INSERT IGNORE INTO proto(url, viewed, stars, title, description, version, branch, license_url, license, base_type, needs_robot_ancestor, slot_type) " - ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license_url\", \"$license\", \"$base_type\", \"$needs_robot_ancestor\", \"$slot_type\")"; + $query = "INSERT IGNORE INTO proto(url, viewed, stars, title, description, version, branch, license_url, license, " + ."base_type, needs_robot_ancestor, slot_type) " + ."VALUES(\"$url\", $viewed, $stars, \"$title\", \"$description\", \"$version\", \"$branch\", \"$license_url\", " + ."\"$license\", \"$base_type\", \"$needs_robot_ancestor\", \"$slot_type\")"; else $query = "UPDATE proto SET viewed=$viewed, stars=$stars, title=\"$title\", description=\"$description\", " - ."version=\"$version\", updated=NOW(), license_url=\"$license_url\", license=\"$license\", base_type=\"$base_type\", needs_robot_ancestor=\"$needs_robot_ancestor\", slot_type=\"$slot_type\" " + ."version=\"$version\", updated=NOW(), license_url=\"$license_url\", license=\"$license\", " + ."base_type=\"$base_type\", needs_robot_ancestor=\"$needs_robot_ancestor\", slot_type=\"$slot_type\" " ."WHERE url=\"$url\" AND id=$id"; $mysqli->query($query) or error($mysqli->error); if ($mysqli->affected_rows != 1) { @@ -261,4 +230,49 @@ function error($message) { $answer['updated'] = date("Y-m-d H:i:s"); $answer['total'] = $total; die(json_encode($answer)); + +function get_parent($externprotos, $base_proto, $parent_url) { + for($i = 0; $i < count($externprotos); $i++) { + if ($externprotos[$i][0] === $base_proto) { + $found_parent = true; + $extern_url = $externprotos[$i][1]; + if (str_starts_with($extern_url, "webots://")) + $extern_url = str_replace("webots://", "https://github.com/cyberbotics/webots/blob/released/", $extern_url); + else if (!srt_starts_with($extern_url, "https")) + $extern_url = substr($parent_url, 0, strrpos($parent_url, '/') + 1).$extern_url; + $parent_url = $extern_url; + $check_url = proto_check_url($extern_url); + if (!is_array($check_url)) + error($check_url); + list($extern_username, $extern_repository, $extern_tag_or_branch, $extern_folder, $extern_proto) = $check_url; + $extern_proto_url = "https://raw.githubusercontent.com/$extern_username/$extern_repository/$extern_tag_or_branch$extern_folder/protos/$extern_proto"; + $extern_proto_content = @file_get_contents($extern_proto_url); + $current_proto_content = $extern_proto_content; + if ($extern_proto_content === false) + error("Could not retrieve parent proto with url'$extern_url'"); + + $line = strtok($extern_proto_content, "\r\n"); + $line = strtok("\r\n"); + $externprotos = []; + while ($line !== false) { + $line == trim($line); + if (substr($line, 0, 11) === 'EXTERNPROTO') { + $proto_url = trim(str_replace('"', '',str_replace('EXTERNPROTO', '', $line))); + $proto_name = str_replace('.proto"', '', $line); + $proto_name = substr($proto_name, strrpos($proto_name, '/') + 1); + array_push($externprotos, [$proto_name, $proto_url]); + } + $line = strtok("\r\n"); + } + + preg_match("/(?:\]\s*)\{\s*(?:\%\<[\s\S]*?(?:\>\%\s*))?(?:DEF\s+[^\s]+)?\s+([a-zA-Z0-9\_\-\+]+)\s*\{/", + $extern_proto_content, $match); + if ($match) + $base_proto = $match[1]; + + break; + } + } + return array($externprotos, $base_proto, $current_proto_content, $parent_url); +} ?> From 05ddc691927d8944316135d79306e8c029d5637c Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 14:59:04 +0100 Subject: [PATCH 379/459] cleanup --- httpdocs/ajax/proto/create.php | 50 ++++++---------------------------- 1 file changed, 8 insertions(+), 42 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 05cd11557..9e9c3af10 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -106,47 +106,11 @@ function error($message) { # search for the base type $parent_url = $url; while(!in_array($base_type, $base_nodes)) { - $found_parent = false; - for($i = 0; $i < count($externprotos); $i++) { - if ($externprotos[$i][0] === $base_type) { - $found_parent = true; - $extern_url = $externprotos[$i][1]; - if (str_starts_with($extern_url, "webots://")) - $extern_url = str_replace("webots://", "https://github.com/cyberbotics/webots/blob/released/", $extern_url); - else if (!srt_starts_with($extern_url, "https")) - $extern_url = substr($parent_url, 0, strrpos($parent_url, '/') + 1).$extern_url; - $parent_url = $extern_url; - $check_url = proto_check_url($extern_url); - if (!is_array($check_url)) - error($check_url); - list($extern_username, $extern_repository, $extern_tag_or_branch, $extern_folder, $extern_proto) = $check_url; - $extern_proto_url = "https://raw.githubusercontent.com/$extern_username/$extern_repository/$extern_tag_or_branch$extern_folder/protos/$extern_proto"; - $extern_proto_content = @file_get_contents($extern_proto_url); - if ($extern_proto_content === false) - error("Could not retrieve parent proto with url'$extern_url'"); - - $line = strtok($extern_proto_content, "\r\n"); - $line = strtok("\r\n"); - $externprotos = []; - while ($line !== false) { - $line == trim($line); - if (substr($line, 0, 11) === 'EXTERNPROTO') { - $proto_url = trim(str_replace('"', '',str_replace('EXTERNPROTO', '', $line))); - $proto_name = str_replace('.proto"', '', $line); - $proto_name = substr($proto_name, strrpos($proto_name, '/') + 1); - array_push($externprotos, [$proto_name, $proto_url]); - } - $line = strtok("\r\n"); - } - - preg_match("/(?:\]\s*)\{\s*(?:\%\<[\s\S]*?(?:\>\%\s*))?(?:DEF\s+[^\s]+)?\s+([a-zA-Z0-9\_\-\+]+)\s*\{/", - $extern_proto_content, $match); - if ($match) - $base_type = $match[1]; - - break; - } - } + $results = get_parent($externprotos, $base_type, $parent_url); + $externprotos = $results[0]; + $base_type = $results[1]; + $parent_url = $results[3]; + $found_parent = $results[4]; if(!$found_parent) error("Seems like the parent node is missing from the EXTERNPROTO."); } @@ -173,6 +137,7 @@ function error($message) { $base_proto = $results[1]; $current_proto_content = $results[2]; $parent_url = $results[3]; + $found_parent = $results[4]; if(!$found_parent) error("Seems like the parent node is missing from the EXTERNPROTO."); } @@ -232,6 +197,7 @@ function error($message) { die(json_encode($answer)); function get_parent($externprotos, $base_proto, $parent_url) { + $found_parent = false; for($i = 0; $i < count($externprotos); $i++) { if ($externprotos[$i][0] === $base_proto) { $found_parent = true; @@ -273,6 +239,6 @@ function get_parent($externprotos, $base_proto, $parent_url) { break; } } - return array($externprotos, $base_proto, $current_proto_content, $parent_url); + return array($externprotos, $base_proto, $current_proto_content, $parent_url, $found_parent); } ?> From 33ee5dcc53ed98f476749d6b7c3763a513c0875d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 15:07:06 +0100 Subject: [PATCH 380/459] test --- httpdocs/ajax/proto/create.php | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 9e9c3af10..118d81744 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -48,6 +48,7 @@ function error($message) { $license = ''; $license_url = ''; $line = strtok($proto_content, "\r\n"); +die($proto_content) $version = $mysqli->escape_string(substr($line, 10, 6)); // "#VRML_SIM R2022b utf8" -> "R2022b" $line = strtok("\r\n"); $externprotos = []; From c43898010b1d4f9a694988bee9c051ba63161f5d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 15:07:47 +0100 Subject: [PATCH 381/459] text --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 53fffe9d0..60dd55aa3 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -905,6 +905,7 @@ document.addEventListener('DOMContentLoaded', function() { const url = event.target.getAttribute('data-url'); fetch(script, {method: 'post', body: JSON.stringify({url: url, id: id, search: searchString})}) .then(function(response) { + console.log(response.text()) return response.json(); }) .then(function(data) { From 495a8774bf7fe90b0f41a19211f14e19f5d96cb6 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 15:08:26 +0100 Subject: [PATCH 382/459] typo --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 118d81744..fd898aa6c 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -48,7 +48,7 @@ function error($message) { $license = ''; $license_url = ''; $line = strtok($proto_content, "\r\n"); -die($proto_content) +die($proto_content); $version = $mysqli->escape_string(substr($line, 10, 6)); // "#VRML_SIM R2022b utf8" -> "R2022b" $line = strtok("\r\n"); $externprotos = []; From d047150deec4d6459537d970229a0de27243eef5 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 15:10:12 +0100 Subject: [PATCH 383/459] log --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 60dd55aa3..583089ef0 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1191,6 +1191,7 @@ document.addEventListener('DOMContentLoaded', function() { }; fetch('/ajax/proto/create.php', content) .then(function(response) { + console.log(response.text()) return response.json(); }) .then(function(data) { From 645367e901bd20c3a711ad40209bc03e48b8d112 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 15:10:46 +0100 Subject: [PATCH 384/459] test --- httpdocs/ajax/proto/create.php | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index fd898aa6c..9e9c3af10 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -48,7 +48,6 @@ function error($message) { $license = ''; $license_url = ''; $line = strtok($proto_content, "\r\n"); -die($proto_content); $version = $mysqli->escape_string(substr($line, 10, 6)); // "#VRML_SIM R2022b utf8" -> "R2022b" $line = strtok("\r\n"); $externprotos = []; From cb7c2d5d2d6750925e51279f4e79248fe10d3877 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 15:11:56 +0100 Subject: [PATCH 385/459] cleanup --- httpdocs/js/webots-cloud.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 583089ef0..53fffe9d0 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -905,7 +905,6 @@ document.addEventListener('DOMContentLoaded', function() { const url = event.target.getAttribute('data-url'); fetch(script, {method: 'post', body: JSON.stringify({url: url, id: id, search: searchString})}) .then(function(response) { - console.log(response.text()) return response.json(); }) .then(function(data) { @@ -1191,7 +1190,6 @@ document.addEventListener('DOMContentLoaded', function() { }; fetch('/ajax/proto/create.php', content) .then(function(response) { - console.log(response.text()) return response.json(); }) .then(function(data) { From 2b09d8bae69230996bbe629d13a084aa3940fc60 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 17 Jan 2023 16:18:57 +0100 Subject: [PATCH 386/459] empty type slot --- httpdocs/ajax/proto/insertable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 522e056f6..5c28ef8b7 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -19,7 +19,7 @@ function error($message) { . implode("','", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) . "')"; - if (isset($data->slot_type)){ + if (isset($data->slot_type) && $data->slot_type !== ""){ $slot_type = $data->slot_type; $condition .= " AND slot_type=\"".$mysqli->escape_string($slot_type)."\""; } From bf7f6f3d288dea886b0c6e90b16bf360b4366f22 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 18 Jan 2023 16:33:00 +0100 Subject: [PATCH 387/459] update db --- database/webots-cloud.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/database/webots-cloud.sql b/database/webots-cloud.sql index ef0afece2..d227801cf 100644 --- a/database/webots-cloud.sql +++ b/database/webots-cloud.sql @@ -92,13 +92,13 @@ CREATE TABLE `proto` ( `description` varchar(2048) CHARACTER SET utf8mb4 NOT NULL, `version` varchar(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, `branch` varchar(256) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, - `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `license_url` varchar(256) CHARACTER SET utf8mb4 NOT NULL, `license` varchar(256) CHARACTER SET utf8mb4 NOT NULL, - `needs_robot_ancestor` varchar(256) CHARACTER SET utf8mb4 NOT NULL, `base_type` varchar(256) CHARACTER SET utf8mb4 NOT NULL, - `slot_type` varchar(256) CHARACTER SET utf8mb4 NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + `needs_robot_ancestor` varchar(256) CHARACTER SET utf8mb4 NOT NULL, + `slot_type` varchar(256) CHARACTER SET utf8mb4 NOT NULL, + `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8; ALTER TABLE `proto` ADD PRIMARY KEY (`id`), From 87928cbf68af4912e14a0670f260b25194c7f0ca Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 18 Jan 2023 16:42:56 +0100 Subject: [PATCH 388/459] clean up --- httpdocs/js/project.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 054686788..aa1e0f0da 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -150,7 +150,7 @@ export default class Project extends User { script.onload = () => { this._loadContent(data, resolve); }; - script.onerror = _ => { + script.onerror = () => { console.warn( 'Could not find Webots version, reloading with R2022b instead. This could cause some unwanted behaviour.'); script.remove(); From 8007fa8a17b7859cc9f2913832a1d6180a96badd Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Wed, 18 Jan 2023 16:53:00 +0100 Subject: [PATCH 389/459] style --- httpdocs/js/webots-cloud.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 250013c56..4c980cf6e 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -321,8 +321,7 @@ document.addEventListener('DOMContentLoaded', function() { if (data.type === 'demo') { const dotIndex = data.url.lastIndexOf('/') + 1; thumbnailUrl = (data.url.slice(0, dotIndex) + '.' + data.url.slice(dotIndex)).replace('github.com', - 'raw.githubusercontent.com').replace('/blob', ''); - thumbnailUrl = thumbnailUrl.replace('.wbt', '.jpg'); + 'raw.githubusercontent.com').replace('/blob', '').replace('.wbt', '.jpg'); } else if (data.type === 'competition') { const [, , , username, repo, , branch] = data.url.split('/'); thumbnailUrl = `https://raw.githubusercontent.com/${username}/${repo}/${branch}/preview/thumbnail.jpg`; @@ -342,12 +341,12 @@ document.addEventListener('DOMContentLoaded', function() { title="Delete row as administrator">`; const deleteProject = admin ? `
    ${deleteIcon} ${data.stars} ${second_column} ${secondColumn} ${title}
    @@ -1970,7 +1969,7 @@ ${deleteProject}`; return ``; } let ranking = 1; - let upper_name = ''; + let upperName = ''; for (const participant of participants['participants']) { const dateArray = participant.date.split('T'); const date = `` + @@ -1989,7 +1988,7 @@ ${deleteProject}`; if (hours > 0) performanceString = String(hours) + ':'; if (hours > 0 || minutes > 0) { - if (hours == 0 && minutes < 10) + if (hours === 0 && minutes < 10) performanceString += String(minutes) + ':'; else performanceString += String(minutes).padStart(2, '0') + ':'; @@ -2000,8 +1999,7 @@ ${deleteProject}`; performanceString += String(Math.floor(seconds)) + ':'; const cents = Math.floor(100 * (seconds % 1)); performanceString += String(cents).padStart(2, '0'); - } - else if (metric === 'distance') + } else if (metric === 'distance') performanceString = participant.performance.toFixed(3) + ' m.'; else if (metric !== 'ranking') performanceString = participant.performance; @@ -2009,10 +2007,10 @@ ${deleteProject}`; : `
    ${performanceString}
    + `; @@ -2013,7 +2013,7 @@ ${deleteProject}`; : ``; const link = participant.private ? `${participant.name}` : `${participant.name}`; - const title = (metric == 'ranking') + const title = (metric === 'ranking') ? `Game lost by ${participant.name}` : `Performance of ${participant.name}`; const button = (metric === 'ranking' && ranking === 1) @@ -2068,7 +2068,7 @@ ${deleteProject}`; function viewEntryRun(eventOrId) { createCompetitionPageButton(); const url = project.competitionUrl; - const [, , , username, repo, , branch] = url.split('/'); + const [, , , username, repo, ,] = url.split('/'); let id; if (typeof eventOrId === 'string') id = eventOrId; From 653fa3ce888cad01c17e69ed683a00916e97ea72 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 23 Jan 2023 08:45:03 +0100 Subject: [PATCH 400/459] const --- httpdocs/js/webots-cloud.js | 104 ++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index bb0211d3f..ac4bc999a 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -58,7 +58,7 @@ document.addEventListener('DOMContentLoaded', function() { }]); function footer() { - let template = document.createElement('template'); + const template = document.createElement('template'); template.innerHTML = `
    ` : ``; const versionUrl = `https://github.com/cyberbotics/webots/releases/tag/${data.version}`; const secondColumn = (data.type === 'competition') ? data.participants : data.viewed; - let row = ` + const row = ` @@ -762,7 +762,7 @@ ${deleteProject}`; sort += '-desc'; } else sort += '-desc'; - let icon = title.querySelector('.sort-icon'); + const icon = title.querySelector('.sort-icon'); if (icon) icon.style.display = 'inline'; setSorts(type, sort); @@ -774,7 +774,7 @@ ${deleteProject}`; function initSearch(searchString) { if (activeTab !== 'server') document.getElementById(activeTab + '-search-input').value = searchString; - for (let type of ['scene', 'animation', 'simulation', 'competition', 'proto']) { + for (const type of ['scene', 'animation', 'simulation', 'competition', 'proto']) { document.getElementById(type + '-search-input').addEventListener('keyup', function(event) { if (!getSearch('delay')) { setSearches('delay', true); @@ -805,7 +805,7 @@ ${deleteProject}`; const ACTIVE_CLASS = 'is-active'; TABS.forEach((tab) => { tab.addEventListener('click', (e) => { - let selected = tab.getAttribute('data-tab'); + const selected = tab.getAttribute('data-tab'); document.querySelector('a.navbar-item').href = `/${selected}`; TABS.forEach((t) => { if (t && t.classList.contains(ACTIVE_CLASS)) @@ -816,7 +816,7 @@ ${deleteProject}`; page = getPage(activeTab); sort = getSort(activeTab); search = getSearch(activeTab); - let url = new URL(document.location.origin + '/' + activeTab); + const url = new URL(document.location.origin + '/' + activeTab); if (getPage(activeTab) !== 1) url.searchParams.append('p', getPage(activeTab)); if (getSort(activeTab) && getSort(activeTab) !== 'default') @@ -829,7 +829,7 @@ ${deleteProject}`; CONTENT.forEach((item) => { if (item && item.classList.contains(ACTIVE_CLASS)) item.classList.remove(ACTIVE_CLASS); - let data = item.getAttribute('data-content'); + const data = item.getAttribute('data-content'); if (data === selected) item.classList.add(ACTIVE_CLASS); }); @@ -838,7 +838,7 @@ ${deleteProject}`; } function searchAndSortTable(type, isSearch) { - let url = new URL(document.location.origin + document.location.pathname); + const url = new URL(document.location.origin + document.location.pathname); if (getPage(type) !== 1 && !isSearch) url.searchParams.append('p', getPage(type)); else @@ -912,7 +912,7 @@ ${deleteProject}`; cyberbotics.com/doc/guide/webots-cloud#yaml-file`; } - let dialog = ModalDialog.run('Project deletion from synchronization', errorMsg); + const dialog = ModalDialog.run('Project deletion from synchronization', errorMsg); dialog.error('Project has been deleted.'); dialog.querySelector('form').addEventListener('submit', function(e) { e.preventDefault(); @@ -922,7 +922,7 @@ ${deleteProject}`; event.target.classList.remove('fa-spin'); project.load(`/${typeName}${(page > 1) ? ('?p=' + page) : ''}`); } else { - let tr = document.createElement('tr'); + const tr = document.createElement('tr'); tr.innerHTML = githubRow(data, proto); parent.replaceChild(tr, old); parent.querySelector('#sync-' + data.id).addEventListener('click', _ => synchronizeGithub(_, proto)); @@ -957,7 +957,7 @@ ${deleteProject}`; ModalDialog.run('Server synchronization error', data.error); parent.removeChild(old); } else { - let tr = document.createElement('tr'); + const tr = document.createElement('tr'); tr.innerHTML = serverRow(data); parent.replaceChild(tr, old); parent.querySelector('#sync-server-' + data.id).addEventListener('click', synchronizeServer); @@ -968,7 +968,7 @@ ${deleteProject}`; } function addAnimation(type) { - let content = {}; + const content = {}; if (type === 'A') content.innerHTML = `
    @@ -1025,15 +1025,15 @@ ${deleteProject}`;
    `; let cancelled = false; const title = (type === 'A') ? 'Add an animation' : 'Add a scene'; - let modal = ModalDialog.run(title, content.innerHTML, 'Cancel', 'Add'); + const modal = ModalDialog.run(title, content.innerHTML, 'Cancel', 'Add'); const typeName = (type === 'A') ? 'animation' : 'scene'; - let input = modal.querySelector(`#${typeName}-file`); + const input = modal.querySelector(`#${typeName}-file`); input.focus(); modal.querySelector('button.cancel').addEventListener('click', function() { cancelled = true; }); modal.querySelector('form').addEventListener('submit', function(event) { event.preventDefault(); modal.querySelector('button[type="submit"]').classList.add('is-loading'); - let body = new FormData(modal.querySelector('form')); + const body = new FormData(modal.querySelector('form')); body.append('user', project.id); body.append('password', project.password); fetch('/ajax/animation/create.php', { method: 'post', body: body }) @@ -1079,7 +1079,7 @@ ${deleteProject}`; function addSimulation(type) { let demoExample = 'https://github.com/cyberbotics/webots/blob/R2022b/projects/languages/python/worlds/example.wbt'; let competitionExample = 'https://github.com/cyberbotics/robot-programming-competition/blob/main/worlds/robot_programming.wbt'; - let content = {}; + const content = {}; content.innerHTML = `
    Please enter the full URL link to the world file of your project's repository: @@ -1098,9 +1098,9 @@ ${deleteProject}`; WARNING: your world must be from version R2022b or newer.
    `; - let typeName = (type === 'D') ? 'simulation' : 'competition'; - let modal = ModalDialog.run(`Add a ${typeName}`, content.innerHTML, 'Cancel', 'Add'); - let input = modal.querySelector('#world-file'); + const typeName = (type === 'D') ? 'simulation' : 'competition'; + const modal = ModalDialog.run(`Add a ${typeName}`, content.innerHTML, 'Cancel', 'Add'); + const input = modal.querySelector('#world-file'); input.focus(); input.selectionStart = input.selectionEnd = input.value.length; modal.querySelector('form').addEventListener('submit', function(event) { @@ -1146,7 +1146,7 @@ ${deleteProject}`; } function addProto() { - let content = {}; + const content = {}; content.innerHTML = `
    @@ -1163,8 +1163,8 @@ ${deleteProject}`; WARNING: your proto must be from version R2022b or newer.
    `; - let modal = ModalDialog.run('Add a proto', content.innerHTML, 'Cancel', 'Add'); - let input = modal.querySelector('#proto-file'); + const modal = ModalDialog.run('Add a proto', content.innerHTML, 'Cancel', 'Add'); + const input = modal.querySelector('#proto-file'); input.focus(); input.selectionStart = input.selectionEnd = input.value.length; modal.querySelector('form').addEventListener('submit', function(event) { @@ -1233,12 +1233,12 @@ ${deleteProject}`; let line = ``; for (let i = 0; i < data.animations.length; i++) line += '' + animationRow(data.animations[i]) + ''; - let table = project.content.querySelector(`section[data-content="${typeName}"] > div > table`); + const table = project.content.querySelector(`section[data-content="${typeName}"] > div > table`); table.style.marginBottom = (50 * (pageLimit - data.animations.length)) + 'px'; - let tbody = table.querySelector(`tbody`); + const tbody = table.querySelector(`tbody`); tbody.innerHTML = line; for (let i = 0; i < data.animations.length; i++) { - let node = tbody.querySelector(`#${typeName}-${data.animations[i].id}`); + const node = tbody.querySelector(`#${typeName}-${data.animations[i].id}`); if (node) { let p = (data.animations.length === 1) ? page - 1 : page; if (p === 0) @@ -1260,7 +1260,7 @@ ${deleteProject}`; return 'competition'; })(); const capitalizedTypeName = typeName.charAt(0).toUpperCase() + typeName.slice(1); - let offset = (page - 1) * pageLimit; + const offset = (page - 1) * pageLimit; fetch('/ajax/project/list.php', { method: 'post', body: JSON.stringify({ offset: offset, limit: pageLimit, type: type, sortBy: sortBy, search: searchString }) @@ -1281,11 +1281,11 @@ ${deleteProject}`; let line = ``; for (let i = 0; i < data.projects.length; i++) // compute the GitHub repo URL from the simulation URL. line += '' + githubRow(data.projects[i]) + ''; - let table = project.content.querySelector(`section[data-content="${typeName}"] > div > table`); + const table = project.content.querySelector(`section[data-content="${typeName}"] > div > table`); table.style.marginBottom = (50 * (pageLimit - data.projects.length)) + 'px'; table.querySelector('tbody').innerHTML = line; for (let i = 0; i < data.projects.length; i++) { - let id = data.projects[i].id; + const id = data.projects[i].id; project.content.querySelector('#sync-' + id).addEventListener('click', synchronizeGithub); if (project.content.querySelector('#delete-' + id) !== null) project.content.querySelector('#delete-' + id) @@ -1299,7 +1299,7 @@ ${deleteProject}`; } function listProtos(page, sortBy, searchString) { - let offset = (page - 1) * pageLimit; + const offset = (page - 1) * pageLimit; fetch('/ajax/proto/list.php', {method: 'post', body: JSON.stringify({offset: offset, limit: pageLimit, sortBy: sortBy, search: searchString})}) .then(function(response) { @@ -1334,7 +1334,7 @@ ${deleteProject}`; } function listServers(page) { - let offset = (page - 1) * pageLimit; + const offset = (page - 1) * pageLimit; fetch('/ajax/server/list.php', { method: 'post', body: JSON.stringify({ offset: offset, limit: pageLimit }) }) .then(function(response) { return response.json(); @@ -1346,7 +1346,7 @@ ${deleteProject}`; let line = ``; for (let i = 0; i < data.servers.length; i++) line += '' + serverRow(data.servers[i]) + ''; - let table = project.content.querySelector('section[data-content="server"] > div > table'); + const table = project.content.querySelector('section[data-content="server"] > div > table'); table.style.marginBottom = (50 * (pageLimit - data.servers.length)) + 'px'; table.querySelector('tbody').innerHTML = line; for (let i = 0; i < data.servers.length; i++) @@ -1361,7 +1361,7 @@ ${deleteProject}`; const animation = parseInt(event.target.id.substring((type === 'A') ? 10 : 6)); // skip 'animation-' or 'scene-' const typeName = (type === 'A') ? 'animation' : 'scene'; const capitalizedTypeName = typeName.charAt(0).toUpperCase() + typeName.slice(1); - let dialog = ModalDialog.run(`Really delete ${typeName}?`, '

    There is no way to recover deleted data.

    ', 'Cancel', + const dialog = ModalDialog.run(`Really delete ${typeName}?`, '

    There is no way to recover deleted data.

    ', 'Cancel', `Delete ${capitalizedTypeName}`, 'is-danger'); dialog.querySelector('form').addEventListener('submit', function(event) { event.preventDefault(); @@ -1399,7 +1399,7 @@ ${deleteProject}`; function deleteSimulation(event, project) { const id = event.target.id.substring(7); - let dialog = ModalDialog.run(`Really delete simulation?`, '

    There is no way to recover deleted data.

    ', 'Cancel', + const dialog = ModalDialog.run(`Really delete simulation?`, '

    There is no way to recover deleted data.

    ', 'Cancel', `Delete simulation`, 'is-danger'); dialog.querySelector('form').addEventListener('submit', function(event) { event.preventDefault(); @@ -1423,7 +1423,7 @@ ${deleteProject}`; function deleteProto(event, project) { const id = event.target.id.substring(7); - let dialog = ModalDialog.run(`Really delete proto?`, '

    There is no way to recover deleted data.

    ', 'Cancel', + const dialog = ModalDialog.run(`Really delete proto?`, '

    There is no way to recover deleted data.

    ', 'Cancel', `Delete proto`, 'is-danger'); dialog.querySelector('form').addEventListener('submit', function(event) { event.preventDefault(); @@ -1444,7 +1444,7 @@ ${deleteProject}`; } function whatIsCompetitionPopUp() { - let content = {}; + const content = {}; content.innerHTML = `
    A competition is a simulation scenario which proposes a challenge. @@ -1471,9 +1471,9 @@ ${deleteProject}`; if (type === 'demo') project.runWebotsView(); else if (type === 'competition') { - let url = searchParams.get('url'); + const url = searchParams.get('url'); project.competitionUrl = url; - let context = searchParams.get('context'); + const context = searchParams.get('context'); switch (context) { case 'try': createCompetitionPageButton(); @@ -1532,7 +1532,7 @@ ${deleteProject}`; } function loadMd(url) { - let protoURl = url; + const protoURl = url; if (url.includes('github.com')) { url = url.replace('github.com', 'raw.githubusercontent.com'); url = url.replace('blob/', ''); @@ -1549,8 +1549,8 @@ ${deleteProject}`; return response.text(); }) .then(content => { - let results = parseProtoHeader(proto); - let infoArray = createProtoArray(results[0], results[1], results[2], protoURl); + const results = parseProtoHeader(proto); + const infoArray = createProtoArray(results[0], results[1], results[2], protoURl); populateProtoViewDiv(content, prefix, infoArray); }).catch(() => { // No md file, so we read the description from the proto file @@ -1671,7 +1671,7 @@ ${deleteProject}`; matches = fieldsDefinition.matchAll(spacingRegex); let minSpaces = 2000; for (const match of matches) { - let spaces = match[2]; + const spaces = match[2]; if (spaces.length < minSpaces) minSpaces = spaces.length; } @@ -1780,13 +1780,13 @@ ${deleteProject}`; const license = content.license; const licenseUrl = content.license_url; - let version = content.version; + const version = content.version; populateProtoViewDiv(file, prefix, createProtoArray(version, license, licenseUrl, protoURl)); }); } function mainContainer(project) { - let simulationUrl = new URL(window.location); + const simulationUrl = new URL(window.location); simulationUrl.searchParams.append('context', 'try'); const information = `
    + + + From 7ee89f5ab1aaf936549039fdbbb3798022dd2369 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 20 Jan 2023 16:51:43 +0100 Subject: [PATCH 393/459] remove ace --- httpdocs/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/index.html b/httpdocs/index.html index a1d244ecb..6272f3a4b 100644 --- a/httpdocs/index.html +++ b/httpdocs/index.html @@ -27,6 +27,5 @@ - From 49d799d9d267b4fde251d4377e94b11f04cc7cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20D=C3=A9l=C3=A8ze?= Date: Fri, 20 Jan 2023 17:01:10 +0100 Subject: [PATCH 394/459] Update httpdocs/js/project.js Co-authored-by: Olivier Michel --- httpdocs/js/project.js | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index aa1e0f0da..3b26fab09 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -219,7 +219,6 @@ export default class Project extends User { Project.webotsView.loadScene(`${reference}/scene.x3d`, this._isMobileDevice(), `${reference}/thumbnail.jpg`); resolve(); } else if (url.endsWith('.proto')) { - // this.setupWebotsView('proto'); let urlArray = url.substring(19).split('/'); urlArray.splice(2, 1); let rawGithubUrl = 'https://raw.githubusercontent.com/' + urlArray.join('/'); From c0de5d7bcb77e9b54846d913e30d4b5ddff6f6c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20D=C3=A9l=C3=A8ze?= Date: Fri, 20 Jan 2023 17:01:38 +0100 Subject: [PATCH 395/459] Update httpdocs/js/project.js Co-authored-by: Olivier Michel --- httpdocs/js/project.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 3b26fab09..939103c86 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -238,7 +238,7 @@ export default class Project extends User { } } _updateProtoAndSimulationViewCount(url) { - let phpFile = url.endsWith('.wbt') ? '/ajax/project/list.php' : '/ajax/proto/list.php'; + const phpFile = url.endsWith('.wbt') ? '/ajax/project/list.php' : '/ajax/proto/list.php'; fetch(phpFile, { method: 'post', body: JSON.stringify({ url: url }) }) .then(function(response) { return response.json(); From adf3879e3d67521f366baac7bef96a748bbe9e21 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Fri, 20 Jan 2023 17:03:59 +0100 Subject: [PATCH 396/459] restore testing --- httpdocs/js/project.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 939103c86..fd1bc3147 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -127,7 +127,9 @@ export default class Project extends User { } runWebotsView(data, version) { if (!version || typeof version === 'undefined') { - if (window.location.hostname === 'proto.webots.cloud') + if (window.location.hostname === 'testing.webots.cloud') + version = 'testing'; + else if (window.location.hostname === 'proto.webots.cloud') version = 'proto'; else version = data && data.version ? data.version : this.findGetParameter('version'); From b9d38076ba6b2604837637160644b232b2b9d410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20D=C3=A9l=C3=A8ze?= Date: Fri, 20 Jan 2023 17:10:34 +0100 Subject: [PATCH 397/459] Update httpdocs/js/webots-cloud.js Co-authored-by: Olivier Michel --- httpdocs/js/webots-cloud.js | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index acde996d9..faf7d82ae 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1526,7 +1526,6 @@ ${deleteProject}`; `; const template = document.createElement('template'); template.innerHTML = contentHtml; - // document.querySelector('section.is-active').innerHTML = contentHtml; project.setup('proto', template.content); project.runWebotsView(); loadMd(url); From e61c1871bc092ddf5d6a771bb7500c94c604ecfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20D=C3=A9l=C3=A8ze?= Date: Fri, 20 Jan 2023 17:11:59 +0100 Subject: [PATCH 398/459] Update httpdocs/ajax/proto/create.php Co-authored-by: Olivier Michel --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 9e9c3af10..49f8fb93e 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -1,4 +1,4 @@ - Date: Mon, 23 Jan 2023 08:30:33 +0100 Subject: [PATCH 399/459] style --- httpdocs/js/webots-cloud.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 35030527b..bb0211d3f 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1893,16 +1893,16 @@ ${deleteProject}`; document.getElementById('competition-information-description').innerHTML = description; const information = readme.getElementById('information').innerText.trim().split('\n'); const escapeHtml = (unsafe) => { - return unsafe. - replaceAll('&', '&'). - replaceAll('<', '<'). - replaceAll('>', '>'). - replaceAll('"', '"'). - replaceAll("'", '''); - } + return unsafe + .replaceAll('&', '&') + .replaceAll('<', '<') + .replaceAll('>', '>') + .replaceAll('"', '"') + .replaceAll("'", '''); + }; for (let i = information.length - 1; i >= 0; i--) { const array = information[i].split(': '); - const name = escapeHtml(array[0].substring(2)); // skip "- " + const name = escapeHtml(array[0].substring(2)); // skip "- " const value = escapeHtml(array[1]).replace(/\[([^\]]+)\]\(([^\)]+)\)/, '$1'); const tr = document.createElement('tr'); tr.innerHTML = `${name}:${value}${performanceString}${deleteIcon} ${data.stars}
    @@ -1980,7 +1980,7 @@ ${deleteProject}`; const dateArray = participant.date.split('T'); const date = `` + `${dateArray[0]}
    ${dateArray[1].slice(0, -1)}
    `; - let tableContent = document.createElement('template'); + const tableContent = document.createElement('template'); let performanceString; if (metric === 'percent') performanceString = (participant.performance * 100).toFixed(2) + '%'; @@ -2034,7 +2034,7 @@ ${deleteProject}`; `; ranking++; document.getElementById('rankings-table').appendChild(tableContent.content.firstChild); - let viewButton = document.getElementById(participant.id + '-view'); + const viewButton = document.getElementById(participant.id + '-view'); if (viewButton) viewButton.addEventListener('click', viewEntryRun); } @@ -2043,7 +2043,7 @@ ${deleteProject}`; fetch('ajax/project/queue.php', { method: 'post', body: JSON.stringify({ url: project.competitionUrl }) }) .then(function(response) { return response.json(); }) .then(function(queue) { - let item = document.getElementById('competition-queue'); + const item = document.getElementById('competition-queue'); item.innerHTML = queue.length; let title = ''; let counter = 0; @@ -2098,7 +2098,7 @@ ${deleteProject}`; document.getElementById('competition-page-button').onclick = () => { location.href = pageURL.href; }; } function registerPopUp() { - let content = {}; + const content = {}; content.innerHTML = `

    From c1261edf1b0df041e1ecbd585c2ee704ff7c2260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20D=C3=A9l=C3=A8ze?= Date: Mon, 23 Jan 2023 08:47:56 +0100 Subject: [PATCH 401/459] Update httpdocs/ajax/proto/insertable.php Co-authored-by: Olivier Michel --- httpdocs/ajax/proto/insertable.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index 5c28ef8b7..c5e8b3138 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -28,9 +28,8 @@ function error($message) { $condition .= " AND needs_robot_ancestor=0"; $result = $mysqli->query("SELECT * FROM proto WHERE $condition"); $protos = array(); - while($row = $result->fetch_assoc()) { + while($row = $result->fetch_assoc()) array_push($protos, $row); - } $result->free(); die(json_encode($protos)); ?> From e96442f2101a05324a5606bca2281d3c76746516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20D=C3=A9l=C3=A8ze?= Date: Mon, 23 Jan 2023 08:50:02 +0100 Subject: [PATCH 402/459] Update httpdocs/ajax/proto/list.php Co-authored-by: Olivier Michel --- httpdocs/ajax/proto/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/list.php b/httpdocs/ajax/proto/list.php index ea9d60108..f9fd90754 100644 --- a/httpdocs/ajax/proto/list.php +++ b/httpdocs/ajax/proto/list.php @@ -22,9 +22,9 @@ function error($message) { $order = explode("-", $sortBy)[1]; if ($parameter == "title" || $parameter == "version") { if ($order == "asc") - $order = "desc"; + $order = "DESC"; else - $order = "asc"; + $order = "ASC"; } $branch = basename(dirname(__FILE__, 4)); $condition = "branch=\"$branch\""; From 27904e02e449e59a29647a7911afd4b31d35fc5b Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 23 Jan 2023 08:53:58 +0100 Subject: [PATCH 403/459] column --- httpdocs/js/webots-cloud.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index ac4bc999a..10c12898e 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -654,7 +654,7 @@ ${deleteProject}`;

    - - ' + githubRow(data, true) + ''; document.querySelector('section[data-content="simulation"] > div > table > tbody').insertAdjacentHTML( 'beforeend', tr); + console.log(data.total) + console.log(pageLimit) const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); + console.log(total) updatePagination('proto', page, total); - console.log(data.total) + project.load(`/proto${(page > 1) ? ('?p=' + page) : ''}`); } }); From d26a41468c0ffca3371abb7a6e68fe9cab039fb6 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 12:05:30 +0100 Subject: [PATCH 450/459] remove print --- httpdocs/js/webots-cloud.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 07ce5d82e..94d4a64ed 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1196,10 +1196,7 @@ ${deleteProject}`; const tr = '' + githubRow(data, true) + ''; document.querySelector('section[data-content="simulation"] > div > table > tbody').insertAdjacentHTML( 'beforeend', tr); - console.log(data.total) - console.log(pageLimit) const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); - console.log(total) updatePagination('proto', page, total); project.load(`/proto${(page > 1) ? ('?p=' + page) : ''}`); From 89cd87d188beabe96b5d6cba566e007c7ea5dfc1 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 12:20:20 +0100 Subject: [PATCH 451/459] go to last page --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 94d4a64ed..17a982cfa 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1197,6 +1197,7 @@ ${deleteProject}`; document.querySelector('section[data-content="simulation"] > div > table > tbody').insertAdjacentHTML( 'beforeend', tr); const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); + const page = (total === 0) ? 1 : Math.ceil(total / pageLimit); updatePagination('proto', page, total); project.load(`/proto${(page > 1) ? ('?p=' + page) : ''}`); From d824f674ec3bf7b69dd66045233c58eb5446e415 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 12:21:57 +0100 Subject: [PATCH 452/459] test --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 17a982cfa..00580ba25 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1198,6 +1198,7 @@ ${deleteProject}`; 'beforeend', tr); const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); const page = (total === 0) ? 1 : Math.ceil(total / pageLimit); + console.log(page) updatePagination('proto', page, total); project.load(`/proto${(page > 1) ? ('?p=' + page) : ''}`); From 761c234510443c78f763b16d21256045b0e02952 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 12:22:53 +0100 Subject: [PATCH 453/459] test --- httpdocs/js/webots-cloud.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 00580ba25..9ecc989e0 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1197,8 +1197,7 @@ ${deleteProject}`; document.querySelector('section[data-content="simulation"] > div > table > tbody').insertAdjacentHTML( 'beforeend', tr); const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); - const page = (total === 0) ? 1 : Math.ceil(total / pageLimit); - console.log(page) + page = total; updatePagination('proto', page, total); project.load(`/proto${(page > 1) ? ('?p=' + page) : ''}`); From 3a366eb8eb6c5a0ca091d746c7b4e27e5e102e8a Mon Sep 17 00:00:00 2001 From: BenjaminDeleze Date: Thu, 2 Feb 2023 15:08:43 +0100 Subject: [PATCH 454/459] fix title --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 9ecc989e0..d503209b4 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1740,7 +1740,7 @@ ${deleteProject}`; file += '}\n'; file += '```\n\n'; - if (describedField) { + if (describedField.length > 0) { file += '### ' + protoName + ' Field Summary\n\n'; for (const [fieldType, fieldName, fielDescription] of describedField) { file += '- `' + fieldName + '` : ' + fielDescription; From 21cc81dbbf8306be7ac254296fdf8de927bf52f7 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 7 Feb 2023 10:12:03 +0100 Subject: [PATCH 455/459] remove showdown --- httpdocs/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/index.html b/httpdocs/index.html index 6272f3a4b..0d6e3a48c 100644 --- a/httpdocs/index.html +++ b/httpdocs/index.html @@ -23,7 +23,6 @@ - From 92782fbf38c93e65fe48d5aa40ff3aa043b18ff2 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 7 Feb 2023 10:13:26 +0100 Subject: [PATCH 456/459] test --- httpdocs/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/index.html b/httpdocs/index.html index 0d6e3a48c..6272f3a4b 100644 --- a/httpdocs/index.html +++ b/httpdocs/index.html @@ -23,6 +23,7 @@ + From ac4493e7581896bc4559ce6d3b686ecaa5c95137 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 7 Feb 2023 10:16:05 +0100 Subject: [PATCH 457/459] test --- httpdocs/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/index.html b/httpdocs/index.html index 6272f3a4b..0d6e3a48c 100644 --- a/httpdocs/index.html +++ b/httpdocs/index.html @@ -23,7 +23,6 @@ - From 3166d71cdbd67e8cecbe56c90bd659a044beaa51 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 7 Feb 2023 10:17:29 +0100 Subject: [PATCH 458/459] test --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 7dd84434c..dcea6271e 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1638,7 +1638,7 @@ ${deleteProject}`; function createMdFromProto(protoURl, proto, protoName, prefix, generateAll) { const fieldRegex = /\[\n((.*\n)*)\]/mg; let matches = proto.matchAll(fieldRegex); - let fieldsDefinition; + let fieldsDefinition = ''; const fieldEnumeration = new Map(); const describedField = []; let fields = ''; From 7d5983ecb45304245bb75ba2cc9a8df1591f0515 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 7 Feb 2023 10:45:57 +0100 Subject: [PATCH 459/459] cleanup --- httpdocs/ajax/proto/insertable.php | 2 +- httpdocs/js/project.js | 2 -- httpdocs/js/webots-cloud.js | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/httpdocs/ajax/proto/insertable.php b/httpdocs/ajax/proto/insertable.php index c5e8b3138..f36f2544b 100644 --- a/httpdocs/ajax/proto/insertable.php +++ b/httpdocs/ajax/proto/insertable.php @@ -14,7 +14,7 @@ function error($message) { $base_types = $data->base_types; $branch = basename(dirname(__FILE__, 4)); if (!$branch) - $branch = "proto"; + $branch = "main"; $condition = "branch=\"$branch\" AND base_type IN ('" . implode("','", array_map(fn($string): string => mysqli_real_escape_string($mysqli, $string),$base_types)) . "')"; diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 63ddca006..79ef264c8 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -129,8 +129,6 @@ export default class Project extends User { if (!version || typeof version === 'undefined') { if (window.location.hostname === 'testing.webots.cloud') version = 'testing'; - else if (window.location.hostname === 'proto.webots.cloud') - version = 'proto'; else version = data && data.version ? data.version : this.findGetParameter('version'); } diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index dcea6271e..088279d6f 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1786,7 +1786,6 @@ ${deleteProject}`; // check that the proto is at least from R2023b function checkProtoVersion(version) { - return 'proto'; // TODO: remove once feature-web-proto is merged in develop const year = version.substring(1, version.length - 2); if (year < 2023 || (year === 2023 && version[version.length - 1] === 'a')) return 'R2023b';
    @@ -671,11 +671,6 @@ ${deleteProject}`; Branch/Tag - - - Version From 7630588af969a1b3cdf93ea68d1eca9412879899 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 23 Jan 2023 09:01:39 +0100 Subject: [PATCH 404/459] try dynamic import --- httpdocs/js/webots-cloud.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 10c12898e..dbf658e6e 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1,6 +1,5 @@ import Project from './project.js'; import ModalDialog from './modal_dialog.js'; -import {populateProtoViewDiv} from 'https://cyberbotics.com/wwi/proto/proto_viewer.js'; document.addEventListener('DOMContentLoaded', function() { let scenePage = 1; @@ -1543,9 +1542,10 @@ ${deleteProject}`; throw new Error(''); return response.text(); }) - .then(content => { + .then(async function(content) { const results = parseProtoHeader(proto); const infoArray = createProtoArray(results[0], results[1], results[2], protoURl); + const {populateProtoViewDiv} = await import('https://cyberbotics.com/wwi/proto/proto_viewer.js'); populateProtoViewDiv(content, prefix, infoArray); }).catch(() => { // No md file, so we read the description from the proto file @@ -1726,7 +1726,7 @@ ${deleteProject}`; .then(function(response) { return response.json(); }) - .then(content => { + .then(async function(content) { const baseType = content.base_type; const description = content.description; file += description + '\n\n'; @@ -1776,6 +1776,7 @@ ${deleteProject}`; const license = content.license; const licenseUrl = content.license_url; const version = content.version; + const {populateProtoViewDiv} = await import('https://cyberbotics.com/wwi/proto/proto_viewer.js'); populateProtoViewDiv(file, prefix, createProtoArray(version, license, licenseUrl, protoURl)); }); } From a89de832c05d159f1452fdbe21b2b979b36b3f73 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 23 Jan 2023 09:05:27 +0100 Subject: [PATCH 405/459] debug --- httpdocs/js/project.js | 1 + httpdocs/js/webots-cloud.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 5ba45fc20..78f414620 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -126,6 +126,7 @@ export default class Project extends User { } } runWebotsView(data, version) { + console.log(version) if (!version || typeof version === 'undefined') { if (window.location.hostname === 'testing.webots.cloud') version = 'testing'; diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index dbf658e6e..f6ca30d03 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1776,7 +1776,7 @@ ${deleteProject}`; const license = content.license; const licenseUrl = content.license_url; const version = content.version; - const {populateProtoViewDiv} = await import('https://cyberbotics.com/wwi/proto/proto_viewer.js'); + const {populateProtoViewDiv} = await import('https://cyberbotics.com/wwi/' + version + '/proto_viewer.js'); populateProtoViewDiv(file, prefix, createProtoArray(version, license, licenseUrl, protoURl)); }); } From 0272db06cbcd8ba13ce38b936f2ae49a60fc8d0c Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 23 Jan 2023 09:06:48 +0100 Subject: [PATCH 406/459] log --- httpdocs/js/project.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index 78f414620..c628dc011 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -126,7 +126,7 @@ export default class Project extends User { } } runWebotsView(data, version) { - console.log(version) + console.log(data && data.version ? data.version : this.findGetParameter('version')) if (!version || typeof version === 'undefined') { if (window.location.hostname === 'testing.webots.cloud') version = 'testing'; From 2aebbf4ea3f7059d281b90b2b34c886dde4bc151 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Mon, 23 Jan 2023 09:26:38 +0100 Subject: [PATCH 407/459] get the right version --- httpdocs/js/project.js | 1 - httpdocs/js/webots-cloud.js | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/httpdocs/js/project.js b/httpdocs/js/project.js index c628dc011..5ba45fc20 100644 --- a/httpdocs/js/project.js +++ b/httpdocs/js/project.js @@ -126,7 +126,6 @@ export default class Project extends User { } } runWebotsView(data, version) { - console.log(data && data.version ? data.version : this.findGetParameter('version')) if (!version || typeof version === 'undefined') { if (window.location.hostname === 'testing.webots.cloud') version = 'testing'; diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index f6ca30d03..a436c8dc4 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1545,7 +1545,7 @@ ${deleteProject}`; .then(async function(content) { const results = parseProtoHeader(proto); const infoArray = createProtoArray(results[0], results[1], results[2], protoURl); - const {populateProtoViewDiv} = await import('https://cyberbotics.com/wwi/proto/proto_viewer.js'); + const {populateProtoViewDiv} = await import('https://cyberbotics.com/wwi/' + checkProtoVersion(results[0]) + '/proto_viewer.js'); populateProtoViewDiv(content, prefix, infoArray); }).catch(() => { // No md file, so we read the description from the proto file @@ -1776,11 +1776,21 @@ ${deleteProject}`; const license = content.license; const licenseUrl = content.license_url; const version = content.version; - const {populateProtoViewDiv} = await import('https://cyberbotics.com/wwi/' + version + '/proto_viewer.js'); + const {populateProtoViewDiv} = await import('https://cyberbotics.com/wwi/' + checkProtoVersion(version) + '/proto_viewer.js'); populateProtoViewDiv(file, prefix, createProtoArray(version, license, licenseUrl, protoURl)); }); } + // check that the proto is at least from R2023b + function checkProtoVersion(version) { + return 'proto'; // TODO: remove once feature-web-proto is merged in develop + const year = version.substring(1, version.length - 2); + if (year < 2023 || (year === 2023 && version[version.length - 1] === 'a')) + return 'R2023b'; + + return version; + } + function mainContainer(project) { const simulationUrl = new URL(window.location); simulationUrl.searchParams.append('context', 'try'); From a8ea58cf63db490e8e67ce57b2b0a62c17cda268 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 09:21:41 +0100 Subject: [PATCH 408/459] test --- httpdocs/ajax/project/create.php | 2 +- httpdocs/ajax/proto/create.php | 4 ++-- php/github_asset.php | 14 ++------------ 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/httpdocs/ajax/project/create.php b/httpdocs/ajax/project/create.php index 331225b60..897917434 100644 --- a/httpdocs/ajax/project/create.php +++ b/httpdocs/ajax/project/create.php @@ -23,7 +23,7 @@ function error($message) { if (!is_array($check_url)) error($check_url); list($username, $repository, $tag_or_branch, $folder, $world) = $check_url; -$world_url = "https://raw.githubusercontent.com/$username/$repository/$tag_or_branch$folder/worlds/$world"; +$world_url = "https://raw.githubusercontent.com/$username/$repository/$tag_or_branch$folder/$world"; $world_content = @file_get_contents($world_url); if ($world_content === false) { $query = "DELETE FROM project WHERE id=$id"; diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 49f8fb93e..8445a8b17 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -23,7 +23,7 @@ function error($message) { if (!is_array($check_url)) error($check_url); list($username, $repository, $tag_or_branch, $folder, $proto) = $check_url; -$proto_url = "https://raw.githubusercontent.com/$username/$repository/$tag_or_branch$folder/protos/$proto"; +$proto_url = "https://raw.githubusercontent.com/$username/$repository/$tag_or_branch$folder/$proto"; $proto_content = @file_get_contents($proto_url); if ($proto_content === false) { $query = "DELETE FROM proto WHERE id=$id"; @@ -211,7 +211,7 @@ function get_parent($externprotos, $base_proto, $parent_url) { if (!is_array($check_url)) error($check_url); list($extern_username, $extern_repository, $extern_tag_or_branch, $extern_folder, $extern_proto) = $check_url; - $extern_proto_url = "https://raw.githubusercontent.com/$extern_username/$extern_repository/$extern_tag_or_branch$extern_folder/protos/$extern_proto"; + $extern_proto_url = "https://raw.githubusercontent.com/$extern_username/$extern_repository/$extern_tag_or_branch$extern_folder/$extern_proto"; $extern_proto_content = @file_get_contents($extern_proto_url); $current_proto_content = $extern_proto_content; if ($extern_proto_content === false) diff --git a/php/github_asset.php b/php/github_asset.php index 82612eb91..05bc415c1 100644 --- a/php/github_asset.php +++ b/php/github_asset.php @@ -31,7 +31,7 @@ function check_url($url, $proto = false) { $tag_or_branch = $exploded[3]; if (!preg_match('/^[a-z\d_.-]{0,100}$/i', $tag_or_branch)) return 'Wrong GitHub tag or branch name'; - $folder = implode('/', array_slice($exploded, 4, $count - 6)); + $folder = implode('/', array_slice($exploded, 4, $count - 5)); if ($folder !=='' and (!preg_match('/^[-a-z\d_.-\/]{1,100}$/i', $folder) # no fancy folder name or substr($folder, 0, 1) === '/' # doesn't start with slash @@ -41,17 +41,7 @@ function check_url($url, $proto = false) { if ($folder !== '') $folder = "/$folder"; - $world_or_proto; - $worlds_or_protos_folder = $exploded[$count - 2]; - if ($proto) { - if ($worlds_or_protos_folder != 'protos') - return 'Missing \'/protos/\' folder in URL'; - $world_or_proto = $exploded[$count - 1]; - } else { - if ($worlds_or_protos_folder != 'worlds') - return 'Missing \'/worlds/\' folder in URL'; - $world_or_proto = $exploded[$count - 1]; - } + $world_or_proto = $exploded[$count - 1]; return array($username, $repository, $tag_or_branch, $folder, $world_or_proto); } From 689f3102effdff9fc4c62c75c218e507f38cadfa Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 09:30:57 +0100 Subject: [PATCH 409/459] yaml folder --- php/github_asset.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/php/github_asset.php b/php/github_asset.php index 05bc415c1..2a3b660b2 100644 --- a/php/github_asset.php +++ b/php/github_asset.php @@ -54,10 +54,12 @@ function yaml_error($msg) { # get file from github list($username, $repository, $version, $folder, $world_or_proto) = $check_url; - $yaml_url = "https://raw.githubusercontent.com/$username/$repository/$version$folder/webots.yaml"; + $protos_index = strpos($folder, "/protos/"); + $yaml_folder = substr($folder, 0, strlen($folder) - $protos_index); + $yaml_url = "https://raw.githubusercontent.com/$username/$repository/$version$yaml_folder/webots.yaml"; $yaml_content = @file_get_contents($yaml_url); if ($yaml_content === false) { - $yaml_url = "https://raw.githubusercontent.com/$username/$repository/$version$folder/webots.yml"; + $yaml_url = "https://raw.githubusercontent.com/$username/$repository/$version$yaml_folder/webots.yml"; $yaml_content = @file_get_contents($yaml_url); if ($yaml_content === false) return yaml_error("webots.yaml file not found."); From 312ffec83bd521ec2532efcb231f247b6c0dd424 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 09:32:15 +0100 Subject: [PATCH 410/459] yaml --- php/github_asset.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/github_asset.php b/php/github_asset.php index 2a3b660b2..61424e955 100644 --- a/php/github_asset.php +++ b/php/github_asset.php @@ -62,7 +62,7 @@ function yaml_error($msg) { $yaml_url = "https://raw.githubusercontent.com/$username/$repository/$version$yaml_folder/webots.yml"; $yaml_content = @file_get_contents($yaml_url); if ($yaml_content === false) - return yaml_error("webots.yaml file not found."); + return yaml_error("webots.yaml file not found.".$yaml_folder); } # yaml file variables From 6cd3b2d4143e5eceb3dabe67390287e4f6a14b90 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 09:33:13 +0100 Subject: [PATCH 411/459] test --- php/github_asset.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/github_asset.php b/php/github_asset.php index 61424e955..8e4d65122 100644 --- a/php/github_asset.php +++ b/php/github_asset.php @@ -54,7 +54,7 @@ function yaml_error($msg) { # get file from github list($username, $repository, $version, $folder, $world_or_proto) = $check_url; - $protos_index = strpos($folder, "/protos/"); + $protos_index = strpos($folder, "/protos"); $yaml_folder = substr($folder, 0, strlen($folder) - $protos_index); $yaml_url = "https://raw.githubusercontent.com/$username/$repository/$version$yaml_folder/webots.yaml"; $yaml_content = @file_get_contents($yaml_url); From e2f8ec4dd753b4eee521cf60451e31d2f10bcf24 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 09:35:47 +0100 Subject: [PATCH 412/459] try with ending slash --- httpdocs/ajax/project/create.php | 2 +- httpdocs/ajax/proto/create.php | 4 ++-- php/github_asset.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/httpdocs/ajax/project/create.php b/httpdocs/ajax/project/create.php index 897917434..ee3713123 100644 --- a/httpdocs/ajax/project/create.php +++ b/httpdocs/ajax/project/create.php @@ -23,7 +23,7 @@ function error($message) { if (!is_array($check_url)) error($check_url); list($username, $repository, $tag_or_branch, $folder, $world) = $check_url; -$world_url = "https://raw.githubusercontent.com/$username/$repository/$tag_or_branch$folder/$world"; +$world_url = "https://raw.githubusercontent.com/$username/$repository/$tag_or_branch$folder$world"; $world_content = @file_get_contents($world_url); if ($world_content === false) { $query = "DELETE FROM project WHERE id=$id"; diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 8445a8b17..a56e7b8b6 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -23,7 +23,7 @@ function error($message) { if (!is_array($check_url)) error($check_url); list($username, $repository, $tag_or_branch, $folder, $proto) = $check_url; -$proto_url = "https://raw.githubusercontent.com/$username/$repository/$tag_or_branch$folder/$proto"; +$proto_url = "https://raw.githubusercontent.com/$username/$repository/$tag_or_branch$folder$proto"; $proto_content = @file_get_contents($proto_url); if ($proto_content === false) { $query = "DELETE FROM proto WHERE id=$id"; @@ -211,7 +211,7 @@ function get_parent($externprotos, $base_proto, $parent_url) { if (!is_array($check_url)) error($check_url); list($extern_username, $extern_repository, $extern_tag_or_branch, $extern_folder, $extern_proto) = $check_url; - $extern_proto_url = "https://raw.githubusercontent.com/$extern_username/$extern_repository/$extern_tag_or_branch$extern_folder/$extern_proto"; + $extern_proto_url = "https://raw.githubusercontent.com/$extern_username/$extern_repository/$extern_tag_or_branch$extern_folder$extern_proto"; $extern_proto_content = @file_get_contents($extern_proto_url); $current_proto_content = $extern_proto_content; if ($extern_proto_content === false) diff --git a/php/github_asset.php b/php/github_asset.php index 8e4d65122..57c427229 100644 --- a/php/github_asset.php +++ b/php/github_asset.php @@ -39,7 +39,7 @@ function check_url($url, $proto = false) { or substr($folder, -1) === '/')) # doesn't end with slash return 'Wrong folder name'; if ($folder !== '') - $folder = "/$folder"; + $folder = "/$folder/"; $world_or_proto = $exploded[$count - 1]; @@ -54,7 +54,7 @@ function yaml_error($msg) { # get file from github list($username, $repository, $version, $folder, $world_or_proto) = $check_url; - $protos_index = strpos($folder, "/protos"); + $protos_index = strpos($folder, "/protos/"); $yaml_folder = substr($folder, 0, strlen($folder) - $protos_index); $yaml_url = "https://raw.githubusercontent.com/$username/$repository/$version$yaml_folder/webots.yaml"; $yaml_content = @file_get_contents($yaml_url); From 51777b250f8193de286f1377b121ab37f1896afc Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 09:36:43 +0100 Subject: [PATCH 413/459] escape --- php/github_asset.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/github_asset.php b/php/github_asset.php index 57c427229..b13e977df 100644 --- a/php/github_asset.php +++ b/php/github_asset.php @@ -54,7 +54,7 @@ function yaml_error($msg) { # get file from github list($username, $repository, $version, $folder, $world_or_proto) = $check_url; - $protos_index = strpos($folder, "/protos/"); + $protos_index = strpos($folder, "\/protos\/"); $yaml_folder = substr($folder, 0, strlen($folder) - $protos_index); $yaml_url = "https://raw.githubusercontent.com/$username/$repository/$version$yaml_folder/webots.yaml"; $yaml_content = @file_get_contents($yaml_url); From df28c6cbaba6281af32c615cb82074ffccba86bd Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 09:37:18 +0100 Subject: [PATCH 414/459] test --- php/github_asset.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/github_asset.php b/php/github_asset.php index b13e977df..04beeb227 100644 --- a/php/github_asset.php +++ b/php/github_asset.php @@ -54,7 +54,7 @@ function yaml_error($msg) { # get file from github list($username, $repository, $version, $folder, $world_or_proto) = $check_url; - $protos_index = strpos($folder, "\/protos\/"); + $protos_index = strpos($folder, "/protos\/"); $yaml_folder = substr($folder, 0, strlen($folder) - $protos_index); $yaml_url = "https://raw.githubusercontent.com/$username/$repository/$version$yaml_folder/webots.yaml"; $yaml_content = @file_get_contents($yaml_url); From 5fd50a7f395d4662b6c49dc4737603648aeb9303 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 09:38:11 +0100 Subject: [PATCH 415/459] test --- php/github_asset.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/php/github_asset.php b/php/github_asset.php index 04beeb227..00aefe04d 100644 --- a/php/github_asset.php +++ b/php/github_asset.php @@ -54,7 +54,7 @@ function yaml_error($msg) { # get file from github list($username, $repository, $version, $folder, $world_or_proto) = $check_url; - $protos_index = strpos($folder, "/protos\/"); + $protos_index = strpos($folder, "/protos/"); $yaml_folder = substr($folder, 0, strlen($folder) - $protos_index); $yaml_url = "https://raw.githubusercontent.com/$username/$repository/$version$yaml_folder/webots.yaml"; $yaml_content = @file_get_contents($yaml_url); @@ -62,7 +62,7 @@ function yaml_error($msg) { $yaml_url = "https://raw.githubusercontent.com/$username/$repository/$version$yaml_folder/webots.yml"; $yaml_content = @file_get_contents($yaml_url); if ($yaml_content === false) - return yaml_error("webots.yaml file not found.".$yaml_folder); + return yaml_error("webots.yaml file not $protos_index found.".$yaml_folder); } # yaml file variables From 7865e7f2e5218514c1f5da9bca9c49b39f5de74e Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 09:39:15 +0100 Subject: [PATCH 416/459] test --- php/github_asset.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/github_asset.php b/php/github_asset.php index 00aefe04d..8b3a777e0 100644 --- a/php/github_asset.php +++ b/php/github_asset.php @@ -55,7 +55,7 @@ function yaml_error($msg) { # get file from github list($username, $repository, $version, $folder, $world_or_proto) = $check_url; $protos_index = strpos($folder, "/protos/"); - $yaml_folder = substr($folder, 0, strlen($folder) - $protos_index); + $yaml_folder = substr($folder, 0, $protos_index); $yaml_url = "https://raw.githubusercontent.com/$username/$repository/$version$yaml_folder/webots.yaml"; $yaml_content = @file_get_contents($yaml_url); if ($yaml_content === false) { From a2964a0c49c9934858797a45c0dc7d1fb5696520 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 09:52:58 +0100 Subject: [PATCH 417/459] worlds --- php/github_asset.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/php/github_asset.php b/php/github_asset.php index 8b3a777e0..8b858c61c 100644 --- a/php/github_asset.php +++ b/php/github_asset.php @@ -54,8 +54,10 @@ function yaml_error($msg) { # get file from github list($username, $repository, $version, $folder, $world_or_proto) = $check_url; - $protos_index = strpos($folder, "/protos/"); - $yaml_folder = substr($folder, 0, $protos_index); + $index = strpos($folder, "/protos/"); + if (!$index) + $index = strpos($folder, "/worlds/"); + $yaml_folder = substr($folder, 0, $index); $yaml_url = "https://raw.githubusercontent.com/$username/$repository/$version$yaml_folder/webots.yaml"; $yaml_content = @file_get_contents($yaml_url); if ($yaml_content === false) { From 27615a6ad349e497657ad00cf8d01a69287618e0 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 10:20:10 +0100 Subject: [PATCH 418/459] debug --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index c4ba45d7f..c37e8fa69 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1178,6 +1178,7 @@ ${deleteProject}`; }; fetch('/ajax/proto/create.php', content) .then(function(response) { + console.log(response.text()) return response.json(); }) .then(function(data) { From e86d00bbb70d1bf4857917da5a4614c980e76867 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 10:30:15 +0100 Subject: [PATCH 419/459] debug --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index a56e7b8b6..e3d6b16e8 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -213,9 +213,9 @@ function get_parent($externprotos, $base_proto, $parent_url) { list($extern_username, $extern_repository, $extern_tag_or_branch, $extern_folder, $extern_proto) = $check_url; $extern_proto_url = "https://raw.githubusercontent.com/$extern_username/$extern_repository/$extern_tag_or_branch$extern_folder$extern_proto"; $extern_proto_content = @file_get_contents($extern_proto_url); - $current_proto_content = $extern_proto_content; if ($extern_proto_content === false) error("Could not retrieve parent proto with url'$extern_url'"); + $current_proto_content = $extern_proto_content; $line = strtok($extern_proto_content, "\r\n"); $line = strtok("\r\n"); From 9174e18b611a22f98c3c124bc871710a9bcc18d1 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 10:31:13 +0100 Subject: [PATCH 420/459] debug --- httpdocs/ajax/proto/create.php | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index e3d6b16e8..d14fdbe01 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -212,6 +212,7 @@ function get_parent($externprotos, $base_proto, $parent_url) { error($check_url); list($extern_username, $extern_repository, $extern_tag_or_branch, $extern_folder, $extern_proto) = $check_url; $extern_proto_url = "https://raw.githubusercontent.com/$extern_username/$extern_repository/$extern_tag_or_branch$extern_folder$extern_proto"; + die($extern_proto_url); $extern_proto_content = @file_get_contents($extern_proto_url); if ($extern_proto_content === false) error("Could not retrieve parent proto with url'$extern_url'"); From 509195a3055ac1402a6701f6a62e19f77fdc76d4 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 10:32:12 +0100 Subject: [PATCH 421/459] test --- httpdocs/ajax/proto/create.php | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index d14fdbe01..e3d6b16e8 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -212,7 +212,6 @@ function get_parent($externprotos, $base_proto, $parent_url) { error($check_url); list($extern_username, $extern_repository, $extern_tag_or_branch, $extern_folder, $extern_proto) = $check_url; $extern_proto_url = "https://raw.githubusercontent.com/$extern_username/$extern_repository/$extern_tag_or_branch$extern_folder$extern_proto"; - die($extern_proto_url); $extern_proto_content = @file_get_contents($extern_proto_url); if ($extern_proto_content === false) error("Could not retrieve parent proto with url'$extern_url'"); From 77eee31e4d8757f635d70469401d4b081b1dc404 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 10:35:52 +0100 Subject: [PATCH 422/459] test --- httpdocs/ajax/proto/create.php | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index e3d6b16e8..5ee890575 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -198,6 +198,7 @@ function error($message) { function get_parent($externprotos, $base_proto, $parent_url) { $found_parent = false; + $current_proto_content = false; for($i = 0; $i < count($externprotos); $i++) { if ($externprotos[$i][0] === $base_proto) { $found_parent = true; From f78af6f69669cb09b93cc5324251a56f88cb0b47 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 10:37:39 +0100 Subject: [PATCH 423/459] remove debug --- httpdocs/js/webots-cloud.js | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index c37e8fa69..c4ba45d7f 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1178,7 +1178,6 @@ ${deleteProject}`; }; fetch('/ajax/proto/create.php', content) .then(function(response) { - console.log(response.text()) return response.json(); }) .then(function(data) { From 57160873959c2ea09ca7b8c7adf84b41984ce549 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 10:54:33 +0100 Subject: [PATCH 424/459] differentiate errors --- httpdocs/ajax/proto/create.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 5ee890575..1f3b38c06 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -112,7 +112,7 @@ function error($message) { $parent_url = $results[3]; $found_parent = $results[4]; if(!$found_parent) - error("Seems like the parent node is missing from the EXTERNPROTO."); + error("Base type: Seems like the parent node is missing from the EXTERNPROTO."); } $device_regex = "/(\s+Brake\s*|\s+LinearMotor\s*|\s+PositionSensor\s*|\s+RotationalMotor\s*|\s+Skin\s*|\s+Accelerometer\s*|\s+Altimeter\s*|\s+Camera\s*|\s+Compass\s*|\s+Compass\s*|\s+Display\s*|\s+DistanceSensor\s*|\s+Emitter\s*|\s+GPS\s*|\s+Gyro\s*|\s+InertialUnit\s*|\s+LED\s*|\s+Lidar\s*|\s+LightSensor\s*|\s+Pen\s*|\s+Radar\s*|\s+RangeFinder\s*|\s+Receiver\s*|\s+Speaker\s*|\s+TouchSensor\s*|\s+Track\s*)/"; @@ -139,7 +139,7 @@ function error($message) { $parent_url = $results[3]; $found_parent = $results[4]; if(!$found_parent) - error("Seems like the parent node is missing from the EXTERNPROTO."); + error("Slot type: Seems like the parent node is missing from the EXTERNPROTO."); } } } From 1c2ce21dcd9a5f2961b4feb0b10b74967e8a499a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 10:57:07 +0100 Subject: [PATCH 425/459] lower case --- httpdocs/ajax/proto/create.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 1f3b38c06..61ab11bb1 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -112,7 +112,7 @@ function error($message) { $parent_url = $results[3]; $found_parent = $results[4]; if(!$found_parent) - error("Base type: Seems like the parent node is missing from the EXTERNPROTO."); + error("Base type: seems like the parent node is missing from the EXTERNPROTO."); } $device_regex = "/(\s+Brake\s*|\s+LinearMotor\s*|\s+PositionSensor\s*|\s+RotationalMotor\s*|\s+Skin\s*|\s+Accelerometer\s*|\s+Altimeter\s*|\s+Camera\s*|\s+Compass\s*|\s+Compass\s*|\s+Display\s*|\s+DistanceSensor\s*|\s+Emitter\s*|\s+GPS\s*|\s+Gyro\s*|\s+InertialUnit\s*|\s+LED\s*|\s+Lidar\s*|\s+LightSensor\s*|\s+Pen\s*|\s+Radar\s*|\s+RangeFinder\s*|\s+Receiver\s*|\s+Speaker\s*|\s+TouchSensor\s*|\s+Track\s*)/"; @@ -139,7 +139,7 @@ function error($message) { $parent_url = $results[3]; $found_parent = $results[4]; if(!$found_parent) - error("Slot type: Seems like the parent node is missing from the EXTERNPROTO."); + error("Slot type: seems like the parent node is missing from the EXTERNPROTO."); } } } From 5486e7caa4ea4e27dd3b2c630deda93dcc581adb Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 10:59:36 +0100 Subject: [PATCH 426/459] base_type --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 61ab11bb1..0719cdd8c 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -112,7 +112,7 @@ function error($message) { $parent_url = $results[3]; $found_parent = $results[4]; if(!$found_parent) - error("Base type: seems like the parent node is missing from the EXTERNPROTO."); + error("Base type: seems like the parent node ($base_type) is missing from the EXTERNPROTO."); } $device_regex = "/(\s+Brake\s*|\s+LinearMotor\s*|\s+PositionSensor\s*|\s+RotationalMotor\s*|\s+Skin\s*|\s+Accelerometer\s*|\s+Altimeter\s*|\s+Camera\s*|\s+Compass\s*|\s+Compass\s*|\s+Display\s*|\s+DistanceSensor\s*|\s+Emitter\s*|\s+GPS\s*|\s+Gyro\s*|\s+InertialUnit\s*|\s+LED\s*|\s+Lidar\s*|\s+LightSensor\s*|\s+Pen\s*|\s+Radar\s*|\s+RangeFinder\s*|\s+Receiver\s*|\s+Speaker\s*|\s+TouchSensor\s*|\s+Track\s*)/"; From 4b923403998774fb57f9df3ffbc9b92b67bd6141 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 10:59:59 +0100 Subject: [PATCH 427/459] url --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 0719cdd8c..2c70cc3c3 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -112,7 +112,7 @@ function error($message) { $parent_url = $results[3]; $found_parent = $results[4]; if(!$found_parent) - error("Base type: seems like the parent node ($base_type) is missing from the EXTERNPROTO."); + error("Base type: seems like the parent node ($parent_url) is missing from the EXTERNPROTO."); } $device_regex = "/(\s+Brake\s*|\s+LinearMotor\s*|\s+PositionSensor\s*|\s+RotationalMotor\s*|\s+Skin\s*|\s+Accelerometer\s*|\s+Altimeter\s*|\s+Camera\s*|\s+Compass\s*|\s+Compass\s*|\s+Display\s*|\s+DistanceSensor\s*|\s+Emitter\s*|\s+GPS\s*|\s+Gyro\s*|\s+InertialUnit\s*|\s+LED\s*|\s+Lidar\s*|\s+LightSensor\s*|\s+Pen\s*|\s+Radar\s*|\s+RangeFinder\s*|\s+Receiver\s*|\s+Speaker\s*|\s+TouchSensor\s*|\s+Track\s*)/"; From 94c7a665460f673d5b218b0ec03bf0d21943e555 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:02:45 +0100 Subject: [PATCH 428/459] test --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 2c70cc3c3..a9c33df84 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -112,7 +112,7 @@ function error($message) { $parent_url = $results[3]; $found_parent = $results[4]; if(!$found_parent) - error("Base type: seems like the parent node ($parent_url) is missing from the EXTERNPROTO."); + error("Base type: seems like the parent node ($externprotos) is missing from the EXTERNPROTO."); } $device_regex = "/(\s+Brake\s*|\s+LinearMotor\s*|\s+PositionSensor\s*|\s+RotationalMotor\s*|\s+Skin\s*|\s+Accelerometer\s*|\s+Altimeter\s*|\s+Camera\s*|\s+Compass\s*|\s+Compass\s*|\s+Display\s*|\s+DistanceSensor\s*|\s+Emitter\s*|\s+GPS\s*|\s+Gyro\s*|\s+InertialUnit\s*|\s+LED\s*|\s+Lidar\s*|\s+LightSensor\s*|\s+Pen\s*|\s+Radar\s*|\s+RangeFinder\s*|\s+Receiver\s*|\s+Speaker\s*|\s+TouchSensor\s*|\s+Track\s*)/"; From 123e07833c59b6acb683b8d89b64cd324d64f0e9 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:04:12 +0100 Subject: [PATCH 429/459] debug --- httpdocs/ajax/proto/create.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index a9c33df84..7deef9224 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -111,8 +111,9 @@ function error($message) { $base_type = $results[1]; $parent_url = $results[3]; $found_parent = $results[4]; + $str = implode(', ', $externprotos) if(!$found_parent) - error("Base type: seems like the parent node ($externprotos) is missing from the EXTERNPROTO."); + error("Base type: seems like the parent node ($str) is missing from the EXTERNPROTO."); } $device_regex = "/(\s+Brake\s*|\s+LinearMotor\s*|\s+PositionSensor\s*|\s+RotationalMotor\s*|\s+Skin\s*|\s+Accelerometer\s*|\s+Altimeter\s*|\s+Camera\s*|\s+Compass\s*|\s+Compass\s*|\s+Display\s*|\s+DistanceSensor\s*|\s+Emitter\s*|\s+GPS\s*|\s+Gyro\s*|\s+InertialUnit\s*|\s+LED\s*|\s+Lidar\s*|\s+LightSensor\s*|\s+Pen\s*|\s+Radar\s*|\s+RangeFinder\s*|\s+Receiver\s*|\s+Speaker\s*|\s+TouchSensor\s*|\s+Track\s*)/"; From 2aefc7b08e43eaa9596bdd761f133ce3e63ee806 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:04:42 +0100 Subject: [PATCH 430/459] typo --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 7deef9224..2512c7b4f 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -111,7 +111,7 @@ function error($message) { $base_type = $results[1]; $parent_url = $results[3]; $found_parent = $results[4]; - $str = implode(', ', $externprotos) + $str = implode(', ', $externprotos); if(!$found_parent) error("Base type: seems like the parent node ($str) is missing from the EXTERNPROTO."); } From 82ea7c0a7617a7fb481e5c7d7209f7618417f20e Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:05:27 +0100 Subject: [PATCH 431/459] debug text --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index c4ba45d7f..c37e8fa69 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1178,6 +1178,7 @@ ${deleteProject}`; }; fetch('/ajax/proto/create.php', content) .then(function(response) { + console.log(response.text()) return response.json(); }) .then(function(data) { From 0f1a6d016c44d284b3e5010e9362a9b0e333c0f5 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:09:39 +0100 Subject: [PATCH 432/459] debug --- httpdocs/ajax/proto/create.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 2512c7b4f..d9e6f16d5 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -111,9 +111,8 @@ function error($message) { $base_type = $results[1]; $parent_url = $results[3]; $found_parent = $results[4]; - $str = implode(', ', $externprotos); if(!$found_parent) - error("Base type: seems like the parent node ($str) is missing from the EXTERNPROTO."); + error("Base type: seems like the parent node is missing from the EXTERNPROTO."); } $device_regex = "/(\s+Brake\s*|\s+LinearMotor\s*|\s+PositionSensor\s*|\s+RotationalMotor\s*|\s+Skin\s*|\s+Accelerometer\s*|\s+Altimeter\s*|\s+Camera\s*|\s+Compass\s*|\s+Compass\s*|\s+Display\s*|\s+DistanceSensor\s*|\s+Emitter\s*|\s+GPS\s*|\s+Gyro\s*|\s+InertialUnit\s*|\s+LED\s*|\s+Lidar\s*|\s+LightSensor\s*|\s+Pen\s*|\s+Radar\s*|\s+RangeFinder\s*|\s+Receiver\s*|\s+Speaker\s*|\s+TouchSensor\s*|\s+Track\s*)/"; @@ -241,6 +240,13 @@ function get_parent($externprotos, $base_proto, $parent_url) { break; } } + if (!$found_parent) { + $str = ''; + for($i = 0; $i < count($externprotos); $i++) { + $str .= $externprotos[i][0]; + } + error("$str base: $base_proto parent_url: $parent_url") + } return array($externprotos, $base_proto, $current_proto_content, $parent_url, $found_parent); } ?> From 4650c99bacff71f209e4c65bca6e5f5695e10d38 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:12:31 +0100 Subject: [PATCH 433/459] test --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index d9e6f16d5..af896981f 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -245,7 +245,7 @@ function get_parent($externprotos, $base_proto, $parent_url) { for($i = 0; $i < count($externprotos); $i++) { $str .= $externprotos[i][0]; } - error("$str base: $base_proto parent_url: $parent_url") + error("$str base: $base_proto parent_url: $parent_url"); } return array($externprotos, $base_proto, $current_proto_content, $parent_url, $found_parent); } From 14d27b79790d130dc3c03bb624552e7176a22f65 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:12:59 +0100 Subject: [PATCH 434/459] test --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index af896981f..a768e5fd4 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -243,7 +243,7 @@ function get_parent($externprotos, $base_proto, $parent_url) { if (!$found_parent) { $str = ''; for($i = 0; $i < count($externprotos); $i++) { - $str .= $externprotos[i][0]; + $str .= $externprotos[$i][0]; } error("$str base: $base_proto parent_url: $parent_url"); } From 7a5c8fbba83a7a3bae34388c9977a6b2af46a8fb Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:16:04 +0100 Subject: [PATCH 435/459] test --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index a768e5fd4..7fbaeabf4 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -245,7 +245,7 @@ function get_parent($externprotos, $base_proto, $parent_url) { for($i = 0; $i < count($externprotos); $i++) { $str .= $externprotos[$i][0]; } - error("$str base: $base_proto parent_url: $parent_url"); + error(" $str base: $base_proto parent_url: $parent_url"); } return array($externprotos, $base_proto, $current_proto_content, $parent_url, $found_parent); } From 0eca7512480cfa216afd9778cbc952035114286f Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:24:03 +0100 Subject: [PATCH 436/459] remove print --- httpdocs/js/webots-cloud.js | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index c37e8fa69..c4ba45d7f 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1178,7 +1178,6 @@ ${deleteProject}`; }; fetch('/ajax/proto/create.php', content) .then(function(response) { - console.log(response.text()) return response.json(); }) .then(function(data) { From 5c01a40dd63a573ce42bdfcfc52c9bd8ff18978a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:24:31 +0100 Subject: [PATCH 437/459] test --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index c4ba45d7f..c37e8fa69 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1178,6 +1178,7 @@ ${deleteProject}`; }; fetch('/ajax/proto/create.php', content) .then(function(response) { + console.log(response.text()) return response.json(); }) .then(function(data) { From e076a6b25736fb5d44bc0fd355d6e0cda491d52c Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:29:09 +0100 Subject: [PATCH 438/459] test --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 7fbaeabf4..1b1903e99 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -72,7 +72,7 @@ function error($message) { } } elseif (substr($line, 0, 11) === 'EXTERNPROTO') { $proto_url = trim(str_replace('"', '',str_replace('EXTERNPROTO', '', $line))); - $proto_name = str_replace('.proto"', '', $line); + $proto_name = str_replace('.proto"', '', $proto_url); $proto_name = substr($proto_name, strrpos($proto_name, '/') + 1); array_push($externprotos, [$proto_name, $proto_url]); } elseif (substr($line, 0, 6) === 'PROTO ') From 7545acd367ccbe69a88d4f4b9d813ccc6a74e31c Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:31:21 +0100 Subject: [PATCH 439/459] test --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 1b1903e99..8313386b6 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -243,7 +243,7 @@ function get_parent($externprotos, $base_proto, $parent_url) { if (!$found_parent) { $str = ''; for($i = 0; $i < count($externprotos); $i++) { - $str .= $externprotos[$i][0]; + $str .= ' '.$externprotos[$i][0]; } error(" $str base: $base_proto parent_url: $parent_url"); } From d01b4065d9202627b6d6f7173d46a495150e41ea Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:34:38 +0100 Subject: [PATCH 440/459] index --- httpdocs/ajax/proto/create.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 8313386b6..3d9053974 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -226,7 +226,8 @@ function get_parent($externprotos, $base_proto, $parent_url) { if (substr($line, 0, 11) === 'EXTERNPROTO') { $proto_url = trim(str_replace('"', '',str_replace('EXTERNPROTO', '', $line))); $proto_name = str_replace('.proto"', '', $line); - $proto_name = substr($proto_name, strrpos($proto_name, '/') + 1); + if (strrpos($proto_name, '/')) + $proto_name = substr($proto_name, strrpos($proto_name, '/') + 1); array_push($externprotos, [$proto_name, $proto_url]); } $line = strtok("\r\n"); From 56ab71b9b8d1810a64dead85380c2b450052c9ee Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:36:41 +0100 Subject: [PATCH 441/459] test --- httpdocs/ajax/proto/create.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 3d9053974..c4b80d5bb 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -73,7 +73,8 @@ function error($message) { } elseif (substr($line, 0, 11) === 'EXTERNPROTO') { $proto_url = trim(str_replace('"', '',str_replace('EXTERNPROTO', '', $line))); $proto_name = str_replace('.proto"', '', $proto_url); - $proto_name = substr($proto_name, strrpos($proto_name, '/') + 1); + if (strrpos($proto_name, '/')) + $proto_name = substr($proto_name, strrpos($proto_name, '/') + 1); array_push($externprotos, [$proto_name, $proto_url]); } elseif (substr($line, 0, 6) === 'PROTO ') $title = trim(substr($line, 6)); @@ -221,11 +222,11 @@ function get_parent($externprotos, $base_proto, $parent_url) { $line = strtok($extern_proto_content, "\r\n"); $line = strtok("\r\n"); $externprotos = []; - while ($line !== false) { + while ($line !== false) {if (strrpos($proto_name, '/')) $line == trim($line); if (substr($line, 0, 11) === 'EXTERNPROTO') { $proto_url = trim(str_replace('"', '',str_replace('EXTERNPROTO', '', $line))); - $proto_name = str_replace('.proto"', '', $line); + $proto_name = str_replace('.proto"', '', $proto_url); if (strrpos($proto_name, '/')) $proto_name = substr($proto_name, strrpos($proto_name, '/') + 1); array_push($externprotos, [$proto_name, $proto_url]); @@ -244,7 +245,7 @@ function get_parent($externprotos, $base_proto, $parent_url) { if (!$found_parent) { $str = ''; for($i = 0; $i < count($externprotos); $i++) { - $str .= ' '.$externprotos[$i][0]; + $str .= $externprotos[$i][0]; } error(" $str base: $base_proto parent_url: $parent_url"); } From 1ef933f909794353fb518fe0b5aad2da2b478f67 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:40:36 +0100 Subject: [PATCH 442/459] typo --- httpdocs/ajax/proto/create.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index c4b80d5bb..26efe0497 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -72,7 +72,7 @@ function error($message) { } } elseif (substr($line, 0, 11) === 'EXTERNPROTO') { $proto_url = trim(str_replace('"', '',str_replace('EXTERNPROTO', '', $line))); - $proto_name = str_replace('.proto"', '', $proto_url); + $proto_name = str_replace('.proto', '', $proto_url); if (strrpos($proto_name, '/')) $proto_name = substr($proto_name, strrpos($proto_name, '/') + 1); array_push($externprotos, [$proto_name, $proto_url]); @@ -226,7 +226,7 @@ function get_parent($externprotos, $base_proto, $parent_url) { $line == trim($line); if (substr($line, 0, 11) === 'EXTERNPROTO') { $proto_url = trim(str_replace('"', '',str_replace('EXTERNPROTO', '', $line))); - $proto_name = str_replace('.proto"', '', $proto_url); + $proto_name = str_replace('.proto', '', $proto_url); if (strrpos($proto_name, '/')) $proto_name = substr($proto_name, strrpos($proto_name, '/') + 1); array_push($externprotos, [$proto_name, $proto_url]); From 16b60528e52da4951dff207b5e1ee7bc92676dd3 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:42:05 +0100 Subject: [PATCH 443/459] typo --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 26efe0497..917846a67 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -222,7 +222,7 @@ function get_parent($externprotos, $base_proto, $parent_url) { $line = strtok($extern_proto_content, "\r\n"); $line = strtok("\r\n"); $externprotos = []; - while ($line !== false) {if (strrpos($proto_name, '/')) + while ($line !== false) { $line == trim($line); if (substr($line, 0, 11) === 'EXTERNPROTO') { $proto_url = trim(str_replace('"', '',str_replace('EXTERNPROTO', '', $line))); From 5afb4d33d7609e2fd6063e825a69c7fe7498ba51 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:43:23 +0100 Subject: [PATCH 444/459] typo --- httpdocs/ajax/proto/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/ajax/proto/create.php b/httpdocs/ajax/proto/create.php index 917846a67..fe19d6ff0 100644 --- a/httpdocs/ajax/proto/create.php +++ b/httpdocs/ajax/proto/create.php @@ -206,7 +206,7 @@ function get_parent($externprotos, $base_proto, $parent_url) { $extern_url = $externprotos[$i][1]; if (str_starts_with($extern_url, "webots://")) $extern_url = str_replace("webots://", "https://github.com/cyberbotics/webots/blob/released/", $extern_url); - else if (!srt_starts_with($extern_url, "https")) + else if (!str_starts_with($extern_url, "https")) $extern_url = substr($parent_url, 0, strrpos($parent_url, '/') + 1).$extern_url; $parent_url = $extern_url; $check_url = proto_check_url($extern_url); From 1a664822ee5f93746d18cff0da83109807176c31 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:54:16 +0100 Subject: [PATCH 445/459] remove print --- httpdocs/js/webots-cloud.js | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index c37e8fa69..c4ba45d7f 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1178,7 +1178,6 @@ ${deleteProject}`; }; fetch('/ajax/proto/create.php', content) .then(function(response) { - console.log(response.text()) return response.json(); }) .then(function(data) { From d1089efcd8e340f958f42ab1955fee94c3ba72a9 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 11:59:42 +0100 Subject: [PATCH 446/459] page --- httpdocs/js/webots-cloud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index c4ba45d7f..8a34e60f4 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1198,6 +1198,7 @@ ${deleteProject}`; 'beforeend', tr); const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); updatePagination('proto', page, total); + console.log(page) project.load(`/proto${(page > 1) ? ('?p=' + page) : ''}`); } }); From f362a819937b562347c5309a93615193296a8c7d Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 12:00:35 +0100 Subject: [PATCH 447/459] test --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 8a34e60f4..977c8fcb7 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1198,7 +1198,7 @@ ${deleteProject}`; 'beforeend', tr); const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); updatePagination('proto', page, total); - console.log(page) + console.log(total) project.load(`/proto${(page > 1) ? ('?p=' + page) : ''}`); } }); From 7faa2528a0f3849330caca70d11820759bea7e83 Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 12:01:30 +0100 Subject: [PATCH 448/459] test --- httpdocs/js/webots-cloud.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 977c8fcb7..0f5baaa2a 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1198,7 +1198,7 @@ ${deleteProject}`; 'beforeend', tr); const total = (data.total === 0) ? 1 : Math.ceil(data.total / pageLimit); updatePagination('proto', page, total); - console.log(total) + console.log(data.total) project.load(`/proto${(page > 1) ? ('?p=' + page) : ''}`); } }); From 4d3c3d8fc756f9544698b80d3aa4dceffd1e402a Mon Sep 17 00:00:00 2001 From: Benjamin Deleze Date: Tue, 31 Jan 2023 12:02:24 +0100 Subject: [PATCH 449/459] test --- httpdocs/js/webots-cloud.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/httpdocs/js/webots-cloud.js b/httpdocs/js/webots-cloud.js index 0f5baaa2a..07ce5d82e 100644 --- a/httpdocs/js/webots-cloud.js +++ b/httpdocs/js/webots-cloud.js @@ -1196,9 +1196,12 @@ ${deleteProject}`; const tr = '