From b4e923ab5f1ef9d3d7887fe869f42e8076274ec0 Mon Sep 17 00:00:00 2001
From: denis-skripnik
Date: Tue, 29 Dec 2020 23:35:29 +0700
Subject: [PATCH] Add viz/votes, update viz/custom-generater menu item,
hive/post, steem/post, cyber/explorer menu items
---
blockchains/cyber/apps/explorer/config.json | 2 +-
blockchains/hive/apps/post/config.json | 2 +-
blockchains/steem/apps/post/config.json | 2 +-
.../viz/apps/custom-generator/config.json | 2 +-
blockchains/viz/apps/polls/config.json | 6 ++
blockchains/viz/apps/polls/content.php | 5 ++
blockchains/viz/apps/polls/index.php | 22 ++++++
.../viz/apps/polls/pages/create/config.json | 4 +
.../viz/apps/polls/pages/create/content.php | 30 ++++++++
.../viz/apps/polls/pages/create/page.js | 75 +++++++++++++++++++
.../viz/apps/polls/pages/list/config.json | 4 +
.../viz/apps/polls/pages/list/content.php | 14 ++++
.../viz/apps/polls/pages/results/config.json | 4 +
.../viz/apps/polls/pages/results/content.php | 46 ++++++++++++
.../results/get_dynamic_global_properties.php | 18 +++++
.../viz/apps/polls/pages/voteing/config.json | 4 +
.../viz/apps/polls/pages/voteing/content.php | 44 +++++++++++
.../viz/apps/polls/pages/voteing/page.js | 43 +++++++++++
functions.php | 2 +-
menu.json | 2 +-
template/css/style.css | 22 +++++-
21 files changed, 346 insertions(+), 7 deletions(-)
create mode 100644 blockchains/viz/apps/polls/config.json
create mode 100644 blockchains/viz/apps/polls/content.php
create mode 100644 blockchains/viz/apps/polls/index.php
create mode 100644 blockchains/viz/apps/polls/pages/create/config.json
create mode 100644 blockchains/viz/apps/polls/pages/create/content.php
create mode 100644 blockchains/viz/apps/polls/pages/create/page.js
create mode 100644 blockchains/viz/apps/polls/pages/list/config.json
create mode 100644 blockchains/viz/apps/polls/pages/list/content.php
create mode 100644 blockchains/viz/apps/polls/pages/results/config.json
create mode 100644 blockchains/viz/apps/polls/pages/results/content.php
create mode 100644 blockchains/viz/apps/polls/pages/results/get_dynamic_global_properties.php
create mode 100644 blockchains/viz/apps/polls/pages/voteing/config.json
create mode 100644 blockchains/viz/apps/polls/pages/voteing/content.php
create mode 100644 blockchains/viz/apps/polls/pages/voteing/page.js
diff --git a/blockchains/cyber/apps/explorer/config.json b/blockchains/cyber/apps/explorer/config.json
index 12cc381f..b03a0440 100644
--- a/blockchains/cyber/apps/explorer/config.json
+++ b/blockchains/cyber/apps/explorer/config.json
@@ -1,6 +1,6 @@
{
"title": "Блок-эксплорер для Cyber",
"description": "block explorer (просмотр блоков) в Cyber",
-"in_menu": "Блок-эксплорер",
+"in_menu": "Explorer",
"category": "no_category"
}
\ No newline at end of file
diff --git a/blockchains/hive/apps/post/config.json b/blockchains/hive/apps/post/config.json
index abc88daa..318df005 100644
--- a/blockchains/hive/apps/post/config.json
+++ b/blockchains/hive/apps/post/config.json
@@ -1,6 +1,6 @@
{
"title": "Публикация постов",
"description": "Сервис публикации постов в блокчейне Golos",
-"in_menu": "Добавить пост",
+"in_menu": "Редактор",
"category": "no_category"
}
\ No newline at end of file
diff --git a/blockchains/steem/apps/post/config.json b/blockchains/steem/apps/post/config.json
index abc88daa..318df005 100644
--- a/blockchains/steem/apps/post/config.json
+++ b/blockchains/steem/apps/post/config.json
@@ -1,6 +1,6 @@
{
"title": "Публикация постов",
"description": "Сервис публикации постов в блокчейне Golos",
-"in_menu": "Добавить пост",
+"in_menu": "Редактор",
"category": "no_category"
}
\ No newline at end of file
diff --git a/blockchains/viz/apps/custom-generator/config.json b/blockchains/viz/apps/custom-generator/config.json
index 7e51a02a..ff6ea373 100644
--- a/blockchains/viz/apps/custom-generator/config.json
+++ b/blockchains/viz/apps/custom-generator/config.json
@@ -1,6 +1,6 @@
{
"title": "Генератор custom операций",
"description": "Сервис генерации custom операций для блокчейна Viz.",
-"in_menu": "custom генератор",
+"in_menu": "JSON-генератор",
"category": "tools"
}
\ No newline at end of file
diff --git a/blockchains/viz/apps/polls/config.json b/blockchains/viz/apps/polls/config.json
new file mode 100644
index 00000000..3668f2ff
--- /dev/null
+++ b/blockchains/viz/apps/polls/config.json
@@ -0,0 +1,6 @@
+{
+"title": "Опросы в Viz",
+"description": "Страница опросов Viz",
+"in_menu": "Опросы",
+"category": "tools"
+}
\ No newline at end of file
diff --git a/blockchains/viz/apps/polls/content.php b/blockchains/viz/apps/polls/content.php
new file mode 100644
index 00000000..7a6d5b2c
--- /dev/null
+++ b/blockchains/viz/apps/polls/content.php
@@ -0,0 +1,5 @@
+Меню
+
+'; ?>
\ No newline at end of file
diff --git a/blockchains/viz/apps/polls/index.php b/blockchains/viz/apps/polls/index.php
new file mode 100644
index 00000000..fdf3e830
--- /dev/null
+++ b/blockchains/viz/apps/polls/index.php
@@ -0,0 +1,22 @@
+
\ No newline at end of file
diff --git a/blockchains/viz/apps/polls/pages/create/config.json b/blockchains/viz/apps/polls/pages/create/config.json
new file mode 100644
index 00000000..c8e48eaa
--- /dev/null
+++ b/blockchains/viz/apps/polls/pages/create/config.json
@@ -0,0 +1,4 @@
+{
+"title": "Создание опроса в Viz",
+"description": "Страница создания опросов в Viz"
+}
\ No newline at end of file
diff --git a/blockchains/viz/apps/polls/pages/create/content.php b/blockchains/viz/apps/polls/pages/create/content.php
new file mode 100644
index 00000000..21994ff3
--- /dev/null
+++ b/blockchains/viz/apps/polls/pages/create/content.php
@@ -0,0 +1,30 @@
+
+Создание опроса Список
+';
+return $page;
+?>
\ No newline at end of file
diff --git a/blockchains/viz/apps/polls/pages/create/page.js b/blockchains/viz/apps/polls/pages/create/page.js
new file mode 100644
index 00000000..589825f8
--- /dev/null
+++ b/blockchains/viz/apps/polls/pages/create/page.js
@@ -0,0 +1,75 @@
+$(document).ready(function() {
+ if (active_key) {
+ var objSel = document.getElementById("clients");
+ console.log(JSON.stringify(objSel));
+ //Создаем новый объект Option и заносим его в коллекцию options
+ objSel.options[0] = new Option("Dpos.space", "dpos.space", false, true);
+ }
+
+});
+
+var answers = [];
+ function updateText() {
+let result = '';
+for (let answer of answers) {
+result += `${answer}`;
+}
+ document.getElementById('out').innerHTML = 'Итоговый список:
' + result + '
';
+ }
+
+ function add() {
+ var a = document.getElementById('answer').value;
+ if (!a) {
+ return alert('Не ввели вариант ответа');
+ }
+if (answers.indexOf(a) > -1) {
+ return alert('Такой вариант ответа уже есть.');
+}
+answers.push(a);
+
+ updateText()
+ }
+
+ updateText();
+
+function sendData(operations) {
+ var q = window.confirm('Вы действительно хотите создать опрос? Операция платная: стоит 100 VIZ');
+ if (q === true) {
+ viz.broadcast.send({extensions: [], operations}, [active_key], function(err, res) {
+if (!err) {
+ window.alert('Опрос успешно создан.');
+} else {
+ window.alert('Ошибка: ' + JSON.stringify(err));
+}
+ });
+ }
+}
+
+ function submitPoll(sender, q, end_date, consider, clients) {
+ if (end_date) {
+ let endDate = parseInt(new Date(end_date).getTime()/1000);
+ let memo_array = {};
+memo_array.contractName = "viz-votes";
+memo_array.contractAction = "createVote";
+memo_array.contractPayload = {};
+memo_array.contractPayload.question = q;
+memo_array.contractPayload.answers = answers;
+memo_array.contractPayload.end_date = endDate;
+memo_array.contractPayload.consider = parseFloat(consider);
+let memo = JSON.stringify(memo_array);
+ let data_url = [];
+ data_url.push(["transfer",{"from":sender,"to":"committee","amount":"100.000 VIZ","memo":memo}]);
+ let str_data_url = JSON.stringify(data_url);
+ if (answers.length > 0) {
+ if (clients === "sign") {
+window.open("https://viz.dpos.space/viz-sign/?user=" + sender + "&tr=" + str_data_url);
+ } else if (clients === 'dpos.space') {
+sendData(data_url);
+ }
+} else {
+window.alert('Нет добавленных вариантов ответа.');
+}
+} else {
+window.alert('Вы не указали дату и время окончания опроса.');
+}
+}
diff --git a/blockchains/viz/apps/polls/pages/list/config.json b/blockchains/viz/apps/polls/pages/list/config.json
new file mode 100644
index 00000000..f7242efa
--- /dev/null
+++ b/blockchains/viz/apps/polls/pages/list/config.json
@@ -0,0 +1,4 @@
+{
+"title": "Список опросов в Viz",
+"description": "Страница со списком опросов в блокчейне Viz."
+}
\ No newline at end of file
diff --git a/blockchains/viz/apps/polls/pages/list/content.php b/blockchains/viz/apps/polls/pages/list/content.php
new file mode 100644
index 00000000..29687dcd
--- /dev/null
+++ b/blockchains/viz/apps/polls/pages/list/content.php
@@ -0,0 +1,14 @@
+Список опросов Создание нового опроса
';
+$html = file_get_contents('http://138.201.91.11:3100/viz-api?service=votes&type=list');
+$table = json_decode($html, true);
+$page['content'] .= '';
+foreach ($table as $poll) {
+ $page['content'] .= '- '.$poll['question'].'
+';
+}
+$page['content'] .= '
';
+return $page;
+?>
\ No newline at end of file
diff --git a/blockchains/viz/apps/polls/pages/results/config.json b/blockchains/viz/apps/polls/pages/results/config.json
new file mode 100644
index 00000000..5f5dcd08
--- /dev/null
+++ b/blockchains/viz/apps/polls/pages/results/config.json
@@ -0,0 +1,4 @@
+{
+"title": "Результаты опроса ",
+"description": "Страница с результатами опроса. Вопрос: "
+}
\ No newline at end of file
diff --git a/blockchains/viz/apps/polls/pages/results/content.php b/blockchains/viz/apps/polls/pages/results/content.php
new file mode 100644
index 00000000..476be62f
--- /dev/null
+++ b/blockchains/viz/apps/polls/pages/results/content.php
@@ -0,0 +1,46 @@
+execute($commandQuery3);
+$mass3 = $res3['result'];
+ $tvsh = (float)$mass3['total_vesting_shares'];
+ global $conf;
+ $page = [];
+ $page['content'] = 'Результаты голосование Список опросов
';
+$html = file_get_contents('http://138.201.91.11:3100/viz-api?service=votes&type=vote&permlink='.pageUrl()[3]);
+if (pageUrl()[3] && $html) {
+$table = json_decode($html, true);
+$d = new DateTime();
+$d->setTimestamp($table['end_date']);
+// или createFromFormat с форматом U
+$d = DateTime::createFromFormat('U', $table['end_date']);
+$sp = $table['all_shares'];
+$sp = round($sp, 3);
+$page['content'] .= '
+Вопрос: '.$table['question'].'
+Дата и время завершения: '.$d->format('d.m.Y H:i:s').' GMT
+
+'.$table['type'].'. Всего проголосовало '.$sp.' соц. капитала ('.round(($table['all_shares']/$tvsh*100), 2).'% от всех SHARES).
+
+Вариант ответа | Процент | Процент от общего соц. капитала по варианту |
+';
+$voters_str = 'Топ 100 пользователей по соц. капиталу (каждый вариант, за который есть голоса)
';
+foreach ($table['variants'] as $answer) {
+ $answer_gests_percent = round(($answer['shares'] / $tvsh)*100, 2);
+ $page['content'] .= ''.$answer['answer'].' |
+'.$answer['percent'].'% |
+'.$answer_gests_percent.'% |
';
+$voters_str .= 'За вариант "'.$answer['answer'].'" проголосовали:
+
'.$answer['voters'].'
+';
+}
+$page['content'] .= '
+
'.$voters_str;
+} else {
+ $page['content'] .= 'Такого опроса нет.
';
+}
+$page['title'] = $table['question'];
+$page['description'] = $table['question'];
+return $page;
+}
+?>
\ No newline at end of file
diff --git a/blockchains/viz/apps/polls/pages/results/get_dynamic_global_properties.php b/blockchains/viz/apps/polls/pages/results/get_dynamic_global_properties.php
new file mode 100644
index 00000000..9724e332
--- /dev/null
+++ b/blockchains/viz/apps/polls/pages/results/get_dynamic_global_properties.php
@@ -0,0 +1,18 @@
+setParams($data3);
+
+$connector = new $connector_class();
+
+$command3 = new GetDynamicGlobalPropertiesCommand($connector);
+
diff --git a/blockchains/viz/apps/polls/pages/voteing/config.json b/blockchains/viz/apps/polls/pages/voteing/config.json
new file mode 100644
index 00000000..e3aa1501
--- /dev/null
+++ b/blockchains/viz/apps/polls/pages/voteing/config.json
@@ -0,0 +1,4 @@
+{
+"title": "Голосование по опросу ",
+"description": "Страница голосования по опросу в Viz. Вопрос: "
+}
\ No newline at end of file
diff --git a/blockchains/viz/apps/polls/pages/voteing/content.php b/blockchains/viz/apps/polls/pages/voteing/content.php
new file mode 100644
index 00000000..0ce2c4ae
--- /dev/null
+++ b/blockchains/viz/apps/polls/pages/voteing/content.php
@@ -0,0 +1,44 @@
+
+Голосование Предварительные или окончательные результаты Список опросов
';
+$html = file_get_contents('http://138.201.91.11:3100/viz-api?service=votes&type=voteing&permlink='.pageUrl()[3]);
+if (pageUrl()[3] && $html) {
+$table = json_decode($html, true);
+$answers = $table['answers'];
+if ($answers && $table['end_date'] > gmmktime()) {
+ $d = new DateTime();
+ $d->setTimestamp($table['end_date']);
+
+ // или createFromFormat с форматом U
+ $d = DateTime::createFromFormat('U', $table['end_date']);
+ $page['content'] .= '
+ Вопрос: '.$table['question'].'
+ Дата и время завершения: '.$d->format('d.m.Y H:i:s').' GMT
+ Если вы авторизовались здесь с указанием логина и постинг ключа, сможете проголосовать, не выходя с этого сайта.
+ ';
+} else if ($table['end_date'] <= gmmktime()) {
+ $page['content'] .= 'Опрос закончен.
';
+}
+} else {
+ $page['content'] .= 'Такого опроса нет.
';
+}
+$page['title'] = $table['question'];
+$page['description'] = $table['question'];
+return $page;
+}
+?>
\ No newline at end of file
diff --git a/blockchains/viz/apps/polls/pages/voteing/page.js b/blockchains/viz/apps/polls/pages/voteing/page.js
new file mode 100644
index 00000000..d5a4b0e5
--- /dev/null
+++ b/blockchains/viz/apps/polls/pages/voteing/page.js
@@ -0,0 +1,43 @@
+$(document).ready(function() {
+ if (viz_login) {
+ $('input[name=sender]').val(viz_login);
+ }
+});
+
+function sendData(operations, variant) {
+ variant = parseInt(variant) + 1;
+ var q = window.confirm('Вы действительно хотите проголосовать за вариант №' + variant + '?');
+ if (q === true) {
+ viz.broadcast.send({extensions: [], operations}, [active_key], function(err, res) {
+if (!err) {
+ window.alert('Вы успешно проголосовали.');
+} else {
+ window.alert('Ошибка: ' + JSON.stringify(err));
+}
+ });
+ }
+}
+
+function submitVoteing(permlink, sender, answer) {
+ let memo_array = {};
+memo_array.contractName = "viz-votes";
+memo_array.contractAction = "voteing";
+memo_array.contractPayload = {};
+memo_array.contractPayload.votePermlink = permlink;
+memo_array.contractPayload.answerId = answer;
+let memo = JSON.stringify(memo_array);
+ let data_url = [];
+ data_url.push(["custom",{"required_auths":[], "required_regular_auths": [sender],"id":"viz-votes","json":memo}]);
+ let str_data_url = JSON.stringify(data_url);
+ if (sender && answer) {
+ if (viz_login && posting_key) {
+ sendData(data_url, answer);
+ } else {
+ window.open("https://viz.dpos.space/viz-sign/?user=" + sender + "&tr=" + str_data_url);
+ }
+ } else if (!sender) {
+window.alert('Вы не ввели логин');
+} else if (!answer) {
+ window.alert('Вы не добавили ответы');
+}
+}
diff --git a/functions.php b/functions.php
index 4d58d087..88fac5d5 100644
--- a/functions.php
+++ b/functions.php
@@ -198,7 +198,7 @@ function generateMenu() {
foreach ($val as $permlink => $ankor) {
$ankor = mb_strtoupper($ankor);
if ($permlink != 'name') {
- $str .= ''.$ankor.'';
+ $str .= ''.$ankor.'';
} // if not category name
} // foreach category services
$str .= '';
diff --git a/menu.json b/menu.json
index 66697017..e1031f85 100644
--- a/menu.json
+++ b/menu.json
@@ -1 +1 @@
-{"viz":{"name":"Viz","services":{"no_category":{"name":"","accounts":"Аккаунты","profiles":"Профили","projects":"Проекты","wallet":"Кошелёк"},"tools":{"name":"Инструменты","awards":"Награждение","calc":"Калькулятор","custom-generator":"custom генератор","randomblockchain":"ГСЧ","search":"Viz-links","exchange":"Обмен","manage":"Управление"},"reytings":{"name":"Топы","top":"Пользователи","witnesses-rewards":"Делегаты"},"info":{"name":"Информация","explorer":"Explorer","buy":"Купить VIZ","help":"Справка"}}},"golos":{"name":"Golos","services":{"reytings":{"name":"Топы","activities":"Активность","donates":"Донаты","referrers":"Рефереры","top":"Пользователи","witnesses-rewards":"Делегаты"},"tools":{"name":"Инструменты","backup":"Бекап постов","calc":"Калькулятор","polls":"Опросы","randomblockchain":"ГСЧ","swap":"Swap","post":"Редактор","manage":"Управление"},"games":{"name":"Игры","stakebot":"Stake_bot"},"no_category":{"name":"","accounts":"Аккаунты","profiles":"Профили","wallet":"кошелёк","explorer":"Explorer","help":"Справка"}}},"steem":{"name":"Steem","services":{"no_category":{"name":"","accounts":"Аккаунты","wallet":"Кошелёк","profiles":"Профили","post":"Добавить пост","manage":"Управление"},"tools":{"name":"Инструменты","randomblockchain":"ГСЧ","calc":"Калькулятор","backup":"Бекап постов"}}},"hive":{"name":"Hive","services":{"tools":{"name":"Инструменты","calc":"Калькулятор","randomblockchain":"ГСЧ","backup":"Бекап постов"},"no_category":{"name":"","profiles":"Профили","accounts":"Аккаунты","wallet":"Кошелёк","post":"Добавить пост","manage":"Управление"}}},"minter":{"name":"Minter","services":{"no_category":{"name":"","randomblockchain":"ГСЧ","profiles":"Профили"}}},"cyber":{"name":"Cyber","services":{"no_category":{"name":"","profiles":"Профили","wallet":"Кошелёк","validators":"Валидаторы","explorer":"Блок-эксплорер","accounts":"Аккаунты"},"tools":{"name":"Инструменты","linker":"Линкер","randomblockchain":"ГСЧ","ipfs":"IPFS"}}}}
\ No newline at end of file
+{"viz":{"name":"Viz","services":{"no_category":{"name":"","accounts":"Аккаунты","profiles":"Профили","projects":"Проекты","wallet":"Кошелёк"},"tools":{"name":"Инструменты","awards":"Награждение","calc":"Калькулятор","custom-generator":"JSON-генератор","randomblockchain":"ГСЧ","search":"Viz-links","exchange":"Обмен","manage":"Управление","polls":"Опросы"},"reytings":{"name":"Рейтинги","top":"Пользователи","witnesses-rewards":"Делегаты"},"info":{"name":"Информация","explorer":"Explorer","buy":"Купить VIZ","help":"Справка"}}},"golos":{"name":"Golos","services":{"reytings":{"name":"Рейтинги","activities":"Активность","donates":"Донаты","referrers":"Рефереры","top":"Пользователи","witnesses-rewards":"Делегаты"},"tools":{"name":"Инструменты","backup":"Бекап постов","calc":"Калькулятор","polls":"Опросы","randomblockchain":"ГСЧ","swap":"Swap","post":"Редактор","manage":"Управление"},"games":{"name":"Игры","stakebot":"Stake_bot"},"no_category":{"name":"","accounts":"Аккаунты","profiles":"Профили","wallet":"кошелёк","explorer":"Explorer","help":"Справка"}}},"steem":{"name":"Steem","services":{"no_category":{"name":"","accounts":"Аккаунты","wallet":"Кошелёк","profiles":"Профили","post":"Редактор","manage":"Управление"},"tools":{"name":"Инструменты","randomblockchain":"ГСЧ","calc":"Калькулятор","backup":"Бекап постов"}}},"hive":{"name":"Hive","services":{"tools":{"name":"Инструменты","calc":"Калькулятор","randomblockchain":"ГСЧ","backup":"Бекап постов"},"no_category":{"name":"","profiles":"Профили","accounts":"Аккаунты","wallet":"Кошелёк","post":"Редактор","manage":"Управление"}}},"minter":{"name":"Minter","services":{"no_category":{"name":"","randomblockchain":"ГСЧ","profiles":"Профили"}}},"cyber":{"name":"Cyber","services":{"no_category":{"name":"","profiles":"Профили","wallet":"Кошелёк","validators":"Валидаторы","explorer":"Explorer","accounts":"Аккаунты"},"tools":{"name":"Инструменты","linker":"Линкер","randomblockchain":"ГСЧ","ipfs":"IPFS"}}}}
\ No newline at end of file
diff --git a/template/css/style.css b/template/css/style.css
index f7f05bdf..aaa14e5e 100644
--- a/template/css/style.css
+++ b/template/css/style.css
@@ -186,8 +186,13 @@ h1 > p {color: #0371A8; font: 16px/24px Verdana, sans-serif;}
/* Стили для списка меню */
.nav-list{
display: flex;
+ Width:105%;
height: 100%;
align-items: center;
+ Padding-left:2Px;
+ Padding-right:2px;
+ Margin-right:5px;
+ Margin-left:-5px;
}
/* стили для элементов списка меню */
@@ -200,7 +205,21 @@ h1 > p {color: #0371A8; font: 16px/24px Verdana, sans-serif;}
background-color: #808080;
border-radius: 10px;
}
- /* отступы кроме последнего элемента */
+
+ .nav-link1 {
+ Width:105%;
+ z-index: 10;
+ height: 40px;
+ background-color: #808080;
+ border-radius:10px;
+ margin-top:2px;
+ Padding-left:2Px;
+ Padding-right:2px;
+ Margin-right:5px;
+ Margin-left:-5px;
+ }
+
+/* отступы кроме последнего элемента */
.nav-link{
margin-right: 10px;
}
@@ -221,6 +240,7 @@ h1 > p {color: #0371A8; font: 16px/24px Verdana, sans-serif;}
color: white;
font-size: 14px;
font-weight: 500;
+ cursor:pointer;
}
/* ниже анимации и стили для бургера */