You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
3.0 KiB
95 lines
3.0 KiB
function Dcopy() {
|
|
var clipboard = new Clipboard('#copy-link');
|
|
$('.qrcode').hide();
|
|
Dtoast(js_pageid, L['share_copy']);
|
|
}
|
|
function Dshare(str) {
|
|
$('.poster').hide();
|
|
$('#share-img-'+DShare.pageid).css({'width':'100%','border-radius':'12px'});
|
|
$('.poster p').html(str);
|
|
$('.poster').slideDown('fast');
|
|
}
|
|
function Dshare_tips() {
|
|
$('#share-tips-'+js_pageid).fadeIn('fast');
|
|
setTimeout(function() {
|
|
Go(DShare.linkurl);
|
|
}, 3000);
|
|
}
|
|
function Dshare_FC(ctx, str, top, left, maxwidth, font, maxlen) {
|
|
ctx.lineWidth = 1;
|
|
var lineWidth = 0;
|
|
var canvasWidth = maxwidth;
|
|
var initHeight = top;
|
|
var lastSubStrIndex= 0;
|
|
if(str.length > maxlen) str = str.substring(0, maxlen - 1) + '...';
|
|
var strLength = str.length;
|
|
for(var i = 0; i < strLength; i++) {
|
|
lineWidth += ctx.measureText(str[i]).width;
|
|
if(lineWidth >= canvasWidth) {
|
|
ctx.fillText(str.substring(lastSubStrIndex, i), left, initHeight);
|
|
initHeight += font;
|
|
lineWidth = 0;
|
|
lastSubStrIndex = i;
|
|
}
|
|
if(i == strLength - 1) {
|
|
ctx.fillText(str.substring(lastSubStrIndex, i + 1), left, initHeight);
|
|
}
|
|
}
|
|
}
|
|
function Dshare_Draw() {
|
|
var id = DShare.pageid
|
|
var Dqrcode = new QRCode(Dd('share-code-'+id), {
|
|
text: DShare.linkurl ,
|
|
width: 120,
|
|
height: 120,
|
|
colorDark: "#000000",
|
|
colorLight: "#FFFFFF",
|
|
correctLevel: QRCode.CorrectLevel.H
|
|
});
|
|
var DqrcodeImg = Dd('share-code-'+id).querySelector('canvas');
|
|
var ctx = Dd('share-post-'+id).getContext('2d');
|
|
ctx.scale(2, 2);
|
|
var imgBG = new Image(); imgBG.setAttribute('crossOrigin', 'anonymous');
|
|
var imgTB = new Image(); imgTB.setAttribute('crossOrigin', 'anonymous');
|
|
var imgQR = new Image(); imgQR.setAttribute('crossOrigin', 'anonymous');
|
|
imgTB.onload = function () {
|
|
ctx.drawImage(imgQR, 290, 20, 64, 64);
|
|
ctx.drawImage(imgTB, 36, 124, 48, 48);
|
|
ctx.font = '18px Verdana';
|
|
Dshare_FC(ctx, DShare.title, 142, 96, 252, 23, 125);
|
|
ctx.font = '8px Verdana';
|
|
Dshare_FC(ctx, DShare.linkurl, 216, 56, 272, 23, 125);
|
|
Dd('share-img-'+id).src = Dd('share-post-'+id).toDataURL('image/png');
|
|
}
|
|
imgBG.onload = function () {
|
|
ctx.drawImage(imgBG, 0, 0, 375, 300);
|
|
imgTB.src = DShare.thumb;
|
|
setTimeout(function() {
|
|
if(imgTB.width < 1) {/*Cross domain OR Error load*/
|
|
ctx.drawImage(imgBG, 0, 0, 375, 300);
|
|
ctx.drawImage(imgQR, 290, 20, 64, 64);
|
|
ctx.font = '18px Verdana';
|
|
Dshare_FC(ctx, DShare.title, 152, 46, 272, 23, 125);
|
|
ctx.font = '8px Verdana';
|
|
Dshare_FC(ctx, DShare.linkurl, 216, 56, 272, 23, 125);
|
|
Dd('share-img-'+id).src = Dd('share-post-'+id).toDataURL('image/png');
|
|
}
|
|
}, 1000);
|
|
}
|
|
imgBG.src = DTMob+'static/img/poster.png';
|
|
imgQR.src = DqrcodeImg.toDataURL('image/jpeg');
|
|
if(Dbrowser == 'app' || Dbrowser == 'b2b' || Dbrowser == 'web') {
|
|
$('#share-img-'+id).click(function() {
|
|
App_Save($('#share-img-'+id).attr('src'));
|
|
});
|
|
}
|
|
}
|
|
$(function(){
|
|
if(Dbrowser == 'app' || Dbrowser == 'b2b' || Dbrowser == 'web') {
|
|
$('[data-link]').each(function() {
|
|
var url = $(this).attr('href');
|
|
$(this).attr('href', "javascript:App_Jump('"+url+"');");
|
|
});
|
|
}
|
|
Dshare_Draw();
|
|
});
|