Изменения документа Загрузить документ

Редактировал(а) HRlink 30.05.2025

От версии 76.1
отредактировано HRlink
на 30.05.2025
Изменить комментарий: К данной версии нет комментариев
К версии 74.1
отредактировано HRlink
на 30.05.2025
Изменить комментарий: К данной версии нет комментариев

Сводка

Подробности

Свойства страницы
Содержимое
... ... @@ -143,81 +143,40 @@
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 144  
145 145  ----
146 -
147 -(% class="box" %)
148 -(((
149 -{{icon name="handshake-o"}}{{/icon}} Оставить заявку на подробное **демо Start Link** можно по [[ссылке>>https://hr.start-link.ru/?utm_source=hr-link&utm_medium=wiki&utm_campaign=main]]
150 -)))
151 -
152 152  {{velocity}}
153 -#set($likesKey = $doc.fullName)
154 -#set($likesDoc = $xwiki.getDocument("XWiki.LikesStorage"))
155 -#set($likesObject = $likesDoc.getObject("XWiki.LikesStorageClass", "key", $likesKey))
156 -
157 -#if(!$likesObject)
158 - #set($likesObject = $likesDoc.newObject("XWiki.LikesStorageClass"))
159 - $likesObject.set("key", $likesKey)
160 - $likesObject.set("value", 0)
147 +#set($likesKey = "$doc.fullName_LikeCount")
148 +#set($cookieName = "like_given_${likesKey}")
149 +#set($hasLiked = $request.getCookie($cookieName))
150 +#set($likesDoc = $xwiki.getDocument("XWiki.XWikiPreferences"))
151 +#set($obj = $likesDoc.getObject("XWiki.LikesStorageClass", "key", $likesKey))
152 +#if(!$obj)
153 + #set($discard = $likesDoc.newObject("XWiki.LikesStorageClass"))
154 + #set($obj = $likesDoc.getObject("XWiki.LikesStorageClass", "key", $likesKey))
155 + $obj.set("key", $likesKey)
156 + $obj.set("value", 0)
161 161   $xwiki.saveDocument($likesDoc)
162 162  #end
163 163  
164 -#set($likes = $likesObject.get("value"))
165 -#set($liked = $request.getCookie("liked-$likesKey"))
166 -#set($userLiked = false)
167 -#if("$!liked" == "true")
168 - #set($userLiked = true)
160 +#set($likes = $obj.getIntValue("value"))
161 +
162 +## Увеличение, если кнопка нажата и не было лайка
163 +#if($request.getParameter("like") && !$hasLiked)
164 + #set($likes = $likes + 1)
165 + $obj.set("value", $likes)
166 + $xwiki.saveDocument($likesDoc)
167 + $response.setCookie($cookieName, "true", 365*24*60*60)
169 169  #end
169 +{{/velocity}}
170 170  
171 171  {{html clean="false"}}
172 -<div id="like-container" style="margin-top:20px; display:flex; align-items:center; gap:10px;">
173 - <button id="like-button" style="cursor:pointer; font-size: 20px; background: none; border: none;" title="Нравится">
174 - <span id="heart" style="color:#e74c3c;">❤️</span>
175 - </button>
176 - <span id="like-count" style="font-size:18px;">$likes</span>
177 - <span style="font-size:14px; color: #555;">Нравится статья?</span>
172 +<div style="margin-top:30px; display:flex; align-items:center; gap:10px; font-size:16px;">
173 + <form method="post">
174 + <input type="hidden" name="like" value="1"/>
175 + <button type="submit" title="Поставить лайк" style="background:none; border:none; font-size:24px; cursor:pointer;">❤️</button>
176 + </form>
177 + <span style="font-size:18px;">$likes</span>
178 + <span>Нравится статья?</span>
178 178  </div>
179 -<script>
180 - document.addEventListener('DOMContentLoaded', function () {
181 - const key = "$likesKey";
182 - const likeButton = document.getElementById('like-button');
183 - const likeCount = document.getElementById('like-count');
184 -
185 - function setCookie(name, value, days) {
186 - const d = new Date();
187 - d.setTime(d.getTime() + (days*24*60*60*1000));
188 - document.cookie = name + "=" + value + "; expires=" + d.toUTCString() + "; path=/";
189 - }
190 -
191 - function getCookie(name) {
192 - const value = `; ${document.cookie}`;
193 - const parts = value.split(`; ${name}=`);
194 - if (parts.length === 2) return parts.pop().split(';').shift();
195 - }
196 -
197 - if (getCookie("liked-" + key) === "true") {
198 - likeButton.disabled = true;
199 - likeButton.style.opacity = 0.6;
200 - }
201 -
202 - likeButton.addEventListener('click', function () {
203 - if (getCookie("liked-" + key) !== "true") {
204 - fetch(window.location.href + "?like=1", { method: 'GET' })
205 - .then(() => {
206 - let current = parseInt(likeCount.innerText);
207 - likeCount.innerText = current + 1;
208 - setCookie("liked-" + key, "true", 365);
209 - likeButton.disabled = true;
210 - likeButton.style.opacity = 0.6;
211 - });
212 - }
213 - });
214 - });
215 -</script>
216 216  {{/html}}
217 217  
218 -#if($request.getParameter("like") == "1")
219 - #set($likes = $likesObject.get("value"))
220 - $likesObject.set("value", $math.add($likes, 1))
221 - $xwiki.saveDocument($likesDoc)
222 -#end
223 -{{/velocity}}
182 +