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

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

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

Сводка

Подробности

Свойства страницы
Содержимое
... ... @@ -144,43 +144,37 @@
144 144  
145 145  ----
146 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))
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"))
156 156  
157 157  #if(!$likesObject)
158 158   #set($likesObject = $likesDoc.newObject("XWiki.LikesStorageClass"))
159 - $likesObject.set("key", $likesKey)
154 + $likesObject.set("key", $doc.fullName)
160 160   $likesObject.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)
159 +#if($request.getParameter("like") == "1")
160 + #set($likes = $likesObject.get("value"))
161 + $likesObject.set("value", $math.add($likes, 1))
162 + $xwiki.saveDocument($likesDoc)
169 169  #end
170 170  
165 +#set($likes = $likesObject.get("value"))
171 171  {{html clean="false"}}
172 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>
168 + <button id="like-button" style="cursor:pointer; font-size: 22px; background: none; border: none;" title="Лайк">
169 + 👍
175 175   </button>
176 176   <span id="like-count" style="font-size:18px;">$likes</span>
177 - <span style="font-size:14px; color: #555;">Нравится статья?</span>
172 + <span style="font-size:14px; color:#555;">Нравится статья?</span>
178 178  </div>
179 179  <script>
180 180   document.addEventListener('DOMContentLoaded', function () {
181 - const key = "$likesKey";
176 + const key = "$doc.fullName";
182 182   const likeButton = document.getElementById('like-button');
183 - const likeCount = document.getElementById('like-count');
184 184  
185 185   function setCookie(name, value, days) {
186 186   const d = new Date();
... ... @@ -201,23 +201,11 @@
201 201  
202 202   likeButton.addEventListener('click', function () {
203 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 - });
198 + setCookie("liked-" + key, "true", 365);
199 + window.location.href = window.location.href + (window.location.href.indexOf('?') > -1 ? '&' : '?') + "like=1";
212 212   }
213 213   });
214 214   });
215 215  </script>
216 216  {{/html}}
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 223  {{/velocity}}