Jump to content
View in the app

A better way to browse. Learn more.

IPBMafia.ru - поддержка Invision Community, релизы, темы, плагины и приложения

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Добавление текста при копировании информации с сайта

Статья написано с подачи пользователя Poliik.

В общем, задача:

При копировании текста с сайта добавить в этот текст свою информацию.
Другими словами, если кто-то скопирует с вашего сайта текст, скажем, Привет, то при вставке будет что-то вроде
Привет

Источник: ссылка

Решение

Нетривиальное. Простейший способ, который работает (что важно).

Переходим в АЦ → Внешний вид → ваш стиль

Открываем шаблон globalTemplate.
Почти в самом начале ищем:
 

//<![CDATA[
jsDebug = {parse expression="intval($this->settings['_jsDebug'])"}; /* Must come before JS includes */
USE_RTE = 1;
DISABLE_AJAX = parseInt({$this->settings['disable_text_ajax']}); /* Disables ajax requests where text is sent to the DB; helpful for charset issues */
inACP = false;
var isRTL = false;
var rtlIe = '';
var rtlFull = '';
//]]>
</script>


Ниже вставляем:
 

<script type="text/javascript">
//<![CDATA[
function addLink() {
var eBody = document.getElementsByTagName('body')[0];
var selection = window.getSelection();

// Вы можете изменить текст в этой строчке
var info = "Источник: <a href='"+document.location.href+"'>"+document.location.href+"</a>";

var copytext = selection + info;
var newdiv = document.createElement('div');
newdiv.style.position = 'absolute';
newdiv.style.left = '-99999px';
eBody.appendChild(newdiv);
newdiv.innerHTML = copytext;
selection.selectAllChildren(newdiv);
window.setTimeout( function() {
	 eBody.removeChild(newdiv);
}, 0);
}
document.oncopy = addLink;
//]]>
</script>


Сохраняем.

В строчке

var info = "Источник: <a href='"+document.location.href+"'>"+document.location.href+"</a>";

можете написать любой свой текст.

document.location.href

заменится на страницу, с которой текст был скопирован.

Первоначальный автор: ссылка

Статья эксклюзивно для IPBMafia.Ru

User Feedback

Recommended Comments

Комментариев пока нет

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Добавить комментарий...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.