Изменения документа Загрузить документ
Редактировал(а) HRlink 30.05.2025
Сводка
-
Свойства страницы (1 изменено, 0 добавлено, 0 удалено)
Подробности
- Свойства страницы
-
- Содержимое
-
... ... @@ -141,3 +141,65 @@ 141 141 == Дальнейшие действия == 142 142 143 143 [[Добавьте к документу сотрудников>>https://wiki.myhrlink.ru/bin/view/Main/Кадровик/Документы/Добавить%20в%20документ%20нескольких%20сотрудников%20/]] или отправьте загруженные документы на [[подпись>>https://wiki.myhrlink.ru/bin/view/Main/Кадровик/Документы/Отправить%20документ%20на%20подпись%20/]] 144 + 145 +---- 146 + 147 +{{velocity}} 148 +#set($likesDocName = "XWiki.LikesStorage." + $doc.fullName.replaceAll("[^a-zA-Z0-9]", "_")) 149 +#set($likesDoc = $xwiki.getDocument($likesDocName)) 150 +#set($likesObject = $likesDoc.getObject("XWiki.LikesStorageClass")) 151 + 152 +#if(!$likesObject) 153 + #set($likesObject = $likesDoc.newObject("XWiki.LikesStorageClass")) 154 + $likesObject.set("key", $doc.fullName) 155 + $likesObject.set("value", 0) 156 + $xwiki.saveDocument($likesDoc) 157 +#end 158 + 159 +#if($request.getParameter("like") == "1") 160 + #set($likes = $likesObject.get("value")) 161 + $likesObject.set("value", $math.add($likes, 1)) 162 + $xwiki.saveDocument($likesDoc) 163 +#end 164 + 165 +#set($likes = $likesObject.get("value")) 166 +{{html clean="false"}} 167 +<div id="like-container" style="margin-top:20px; display:flex; align-items:center; gap:10px;"> 168 + <button id="like-button" style="cursor:pointer; font-size: 22px; background: none; border: none;" title="Лайк"> 169 + 👍 170 + </button> 171 + <span id="like-count" style="font-size:18px;">$likes</span> 172 + <span style="font-size:14px; color:#555;">Нравится статья?</span> 173 +</div> 174 +<script> 175 + document.addEventListener('DOMContentLoaded', function () { 176 + const key = "$doc.fullName"; 177 + const likeButton = document.getElementById('like-button'); 178 + 179 + function setCookie(name, value, days) { 180 + const d = new Date(); 181 + d.setTime(d.getTime() + (days*24*60*60*1000)); 182 + document.cookie = name + "=" + value + "; expires=" + d.toUTCString() + "; path=/"; 183 + } 184 + 185 + function getCookie(name) { 186 + const value = `; ${document.cookie}`; 187 + const parts = value.split(`; ${name}=`); 188 + if (parts.length === 2) return parts.pop().split(';').shift(); 189 + } 190 + 191 + if (getCookie("liked-" + key) === "true") { 192 + likeButton.disabled = true; 193 + likeButton.style.opacity = 0.6; 194 + } 195 + 196 + likeButton.addEventListener('click', function () { 197 + if (getCookie("liked-" + key) !== "true") { 198 + setCookie("liked-" + key, "true", 365); 199 + window.location.href = window.location.href + (window.location.href.indexOf('?') > -1 ? '&' : '?') + "like=1"; 200 + } 201 + }); 202 + }); 203 +</script> 204 +{{/html}} 205 +{{/velocity}}