mirror of
https://github.com/MarshalX/telegram-crawler.git
synced 2024-12-29 15:59:13 +01:00
Update content of files
This commit is contained in:
parent
7cc6e07db5
commit
4314d19fdc
5 changed files with 63 additions and 21 deletions
|
@ -217,7 +217,7 @@
|
|||
<script src="/js/bootstrap.min.js"></script>
|
||||
<script src="/js/core-widgets.js?1"></script>
|
||||
|
||||
<script>DiscussionWidget.init({"default_link":"https:\/\/t.me\/durov\/126","link_error":"Invalid post link","widget_script":"https:\/\/telegram.org\/js\/telegram-widget.js?14"});
|
||||
<script>DiscussionWidget.init({"default_link":"https:\/\/t.me\/durov\/126","link_error":"Invalid post link","widget_script":"https:\/\/telegram.org\/js\/telegram-widget.js?15"});
|
||||
backToTopInit("Go up");
|
||||
removePreloadInit();
|
||||
</script>
|
||||
|
|
|
@ -317,7 +317,7 @@ function updateWidget(widget_update, init) {
|
|||
attrs += ' data-radius="' + escapeHTML(radius_value) + '"';
|
||||
}
|
||||
if (widget_update) {
|
||||
var code = '<script async src="https://telegram.org/js/telegram-widget.js?14" data-telegram-login="samplebot" data-size="' + escapeHTML(size) + '"' + (!userpic ? ' data-userpic="false"' : '') + ' data-onauth="onTelegramAuth(user)"' + attrs + (form.request_write.checked ? ' data-request-access="write"' : '') + '><\/script>';
|
||||
var code = '<script async src="https://telegram.org/js/telegram-widget.js?15" data-telegram-login="samplebot" data-size="' + escapeHTML(size) + '"' + (!userpic ? ' data-userpic="false"' : '') + ' data-onauth="onTelegramAuth(user)"' + attrs + (form.request_write.checked ? ' data-request-access="write"' : '') + '><\/script>';
|
||||
$('#widget_container').html(code);
|
||||
}
|
||||
var post_link = $('#post_link').val() || 'https://t.me/telegram/83',
|
||||
|
@ -330,7 +330,7 @@ function updateWidget(widget_update, init) {
|
|||
attrs += ' data-onauth="onTelegramAuth(user)"';
|
||||
html += "\n<script type=\"text/javascript\">\n function onTelegramAuth(user) {\n alert('Logged in as ' + user.first_name + ' ' + user.last_name + ' (' + user.id + (user.username ? ', @' + user.username : '') + ')');\n }\n<\/script>";
|
||||
}
|
||||
var code = '<script async src="https://telegram.org/js/telegram-widget.js?14" data-telegram-login="' + escapeHTML(bot_username || 'samplebot') + '" data-size="' + escapeHTML(size) + '"' + (!userpic ? ' data-userpic="false"' : '') + attrs + (form.request_write.checked ? ' data-request-access="write"' : '') + '><\/script>' + html;
|
||||
var code = '<script async src="https://telegram.org/js/telegram-widget.js?15" data-telegram-login="' + escapeHTML(bot_username || 'samplebot') + '" data-size="' + escapeHTML(size) + '"' + (!userpic ? ' data-userpic="false"' : '') + attrs + (form.request_write.checked ? ' data-request-access="write"' : '') + '><\/script>' + html;
|
||||
$('#embed_code').val(code);
|
||||
$('#embed_code').height(0);
|
||||
$('#embed_code').height($('#embed_code').get(0).scrollHeight);
|
||||
|
|
|
@ -231,7 +231,7 @@
|
|||
<script src="/js/bootstrap.min.js"></script>
|
||||
<script src="/js/core-widgets.js?1"></script>
|
||||
|
||||
<script>PostWidget.init({"default_link":"https:\/\/t.me\/telegram\/83","link_error":"Invalid post link","widget_script":"https:\/\/telegram.org\/js\/telegram-widget.js?14"});
|
||||
<script>PostWidget.init({"default_link":"https:\/\/t.me\/telegram\/83","link_error":"Invalid post link","widget_script":"https:\/\/telegram.org\/js\/telegram-widget.js?15"});
|
||||
backToTopInit("Go up");
|
||||
removePreloadInit();
|
||||
</script>
|
||||
|
|
|
@ -231,7 +231,7 @@ function telegramForwardButton($url, $text = '') {
|
|||
var button_size = form.button_size.value;
|
||||
var button_text = form.button_text.value;
|
||||
tfi.removeClass('is-invalid');
|
||||
var code = '<script async src="https://telegram.org/js/telegram-widget.js?14" data-telegram-share-url="' + escapeHTML(share_url) + '"' + (share_comment ? ' data-comment="' + escapeHTML(share_comment) + '"' : '') + (button_size ? ' data-size="' + escapeHTML(button_size) + '"' : '') + (button_text ? ' data-text="' + escapeHTML(button_text) + '"' : '') + '><\/script>';
|
||||
var code = '<script async src="https://telegram.org/js/telegram-widget.js?15" data-telegram-share-url="' + escapeHTML(share_url) + '"' + (share_comment ? ' data-comment="' + escapeHTML(share_comment) + '"' : '') + (button_size ? ' data-size="' + escapeHTML(button_size) + '"' : '') + (button_text ? ' data-text="' + escapeHTML(button_text) + '"' : '') + '><\/script>';
|
||||
$('#embed_code').val(code);
|
||||
$('#embed_code').height(0);
|
||||
$('#embed_code').height($('#embed_code').get(0).scrollHeight);
|
||||
|
|
|
@ -87,18 +87,34 @@
|
|||
}
|
||||
}
|
||||
|
||||
function postMessageToIframe(iframe, event, data) {
|
||||
if (!window.Telegram) {
|
||||
window.Telegram = {};
|
||||
}
|
||||
if (!window.Telegram.__WidgetUuid) {
|
||||
window.Telegram.__WidgetUuid = 0;
|
||||
}
|
||||
if (!window.Telegram.__WidgetLastId) {
|
||||
window.Telegram.__WidgetLastId = 0;
|
||||
}
|
||||
if (!window.Telegram.__WidgetCallbacks) {
|
||||
window.Telegram.__WidgetCallbacks = {};
|
||||
}
|
||||
|
||||
function postMessageToIframe(iframe, event, data, callback) {
|
||||
try {
|
||||
data = data || {};
|
||||
data.event = event;
|
||||
if (callback) {
|
||||
data._cb = ++window.Telegram.__WidgetLastId;
|
||||
window.Telegram.__WidgetCallbacks[data._cb] = {
|
||||
iframe: iframe,
|
||||
callback: callback
|
||||
};
|
||||
}
|
||||
iframe.contentWindow.postMessage(JSON.stringify(data), '*');
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
if (!window.__TgWidgetUuid) {
|
||||
window.__TgWidgetUuid = 0;
|
||||
}
|
||||
|
||||
function initWidget(widgetEl) {
|
||||
var widgetId, widgetElId, widgetsOrigin, existsEl,
|
||||
src, styles = {}, allowedAttrs = [],
|
||||
|
@ -124,7 +140,7 @@
|
|||
}
|
||||
else if (widgetId = widgetEl.getAttribute('data-telegram-discussion')) {
|
||||
widgetsOrigin = getWidgetsOrigin('https://t.me', 'https://post.tg.dev');
|
||||
widgetElId = 'telegram-discussion-' + widgetId.replace(/[^a-z0-9_]/ig, '-') + '-' + (++window.__TgWidgetUuid);
|
||||
widgetElId = 'telegram-discussion-' + widgetId.replace(/[^a-z0-9_]/ig, '-') + '-' + (++window.Telegram.__WidgetUuid);
|
||||
var websitePageUrl = widgetEl.getAttribute('data-page-url');
|
||||
if (!websitePageUrl) {
|
||||
websitePageUrl = getPageCanonical();
|
||||
|
@ -273,6 +289,17 @@
|
|||
else if (data.event == 'unauthorized') {
|
||||
onUnauth && onUnauth();
|
||||
}
|
||||
else if (data.event == 'callback') {
|
||||
var cb_data = null;
|
||||
if (cb_data = window.Telegram.__WidgetCallbacks[data._cb]) {
|
||||
if (cb_data.iframe === iframe) {
|
||||
cb_data.callback(data.value);
|
||||
delete window.Telegram.__WidgetCallbacks[data._cb];
|
||||
}
|
||||
} else {
|
||||
console.warn('Callback #' + data._cb + ' not found');
|
||||
}
|
||||
}
|
||||
}
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.id = widgetElId;
|
||||
|
@ -342,8 +369,23 @@
|
|||
return widgets;
|
||||
}
|
||||
|
||||
function getWidgetInfo(el_or_id, callback) {
|
||||
var e = null, iframe = null;
|
||||
if (el = geById(el_or_id)) {
|
||||
if (el.tagName &&
|
||||
el.tagName.toUpperCase() == 'IFRAME') {
|
||||
iframe = el;
|
||||
} else if (el._iframe) {
|
||||
iframe = el._iframe;
|
||||
}
|
||||
if (iframe && callback) {
|
||||
postMessageToIframe(iframe, 'get_info', {}, callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setWidgetOptions(options, el_or_id) {
|
||||
var iframe;
|
||||
var e = null, iframe = null;
|
||||
if (typeof el_or_id === 'undefined') {
|
||||
var widgets = getAllWidgets();
|
||||
for (var i = 0; i < widgets.length; i++) {
|
||||
|
@ -352,12 +394,14 @@
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (iframe = geById(el_or_id)) {
|
||||
if (iframe.tagName &&
|
||||
iframe.tagName.toUpperCase() == 'IFRAME') {
|
||||
postMessageToIframe(iframe, 'set_options', {options: options});
|
||||
} else if (iframe._iframe) {
|
||||
iframe = iframe._iframe;
|
||||
if (el = geById(el_or_id)) {
|
||||
if (el.tagName &&
|
||||
el.tagName.toUpperCase() == 'IFRAME') {
|
||||
iframe = el;
|
||||
} else if (el._iframe) {
|
||||
iframe = el._iframe;
|
||||
}
|
||||
if (iframe) {
|
||||
postMessageToIframe(iframe, 'set_options', {options: options});
|
||||
}
|
||||
}
|
||||
|
@ -460,9 +504,7 @@
|
|||
}
|
||||
};
|
||||
|
||||
if (!window.Telegram) {
|
||||
window.Telegram = {};
|
||||
}
|
||||
window.Telegram.getWidgetInfo = getWidgetInfo;
|
||||
window.Telegram.setWidgetOptions = setWidgetOptions;
|
||||
window.Telegram.Login = {
|
||||
auth: TelegramLogin.auth,
|
||||
|
|
Loading…
Reference in a new issue