Skip to content

Commit

Permalink
Major Update: All known bugs fixes && logical improvements
Browse files Browse the repository at this point in the history
And more code comments. Ready to be released.
  • Loading branch information
hifocus committed Dec 21, 2018
1 parent fff8f08 commit 47a6a93
Show file tree
Hide file tree
Showing 6 changed files with 364 additions and 144 deletions.
155 changes: 155 additions & 0 deletions elements/function.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
// HTML Template Merger - Merge your qrcode quicker.
// Released under GNU General Public License v3.0. Opensourced. (https://github.com/hifocus/merger)
// Author @hifocus (https://github.com/hifocus), @LF112 (https://github.com/lf112)
// Copyright reservation is required.

var client;
var selected;

// Set profile photo
document.getElementById("i").style.background =
"url('" + profile + "') no-repeat center/cover";

// UserAgent Verify Part Starts
var scale = window.devicePixelRatio; // Change to 1 on retina screens to see blurry canvas.

document.getElementById("titleinfo").innerHTML = "惶心最帅";

// General UserAgent verify rules
if (navigator.userAgent.match(/Alipay/i)) {
console.log("ALIPAY CLIENT");
// Redirect directly
window.location.href = alipay;
} else if (navigator.userAgent.match(/MicroMessenger\//i)) {
if (
location.href.substr(location.href.lastIndexOf("#") + 1) == "showqrcode" &&
!selected
)
document.getElementById("showqrcode").style.display = "none";
console.log("WECHAT CLIENT");
client = wechat;
// Click the button, import from js
document.getElementById("toclick").click();
document.getElementById("titleinfo").innerHTML =
"长按识别二维码 向" + myname + "支付";
// Melt the car door (((
document.getElementById("h").removeChild(document.getElementById("i")); // remove profile photo
document
.getElementById("pending")
.removeChild(document.getElementById("depends")); // remove buttons
document
.getElementById("btncontainer")
.removeChild(document.getElementById("qrcodeclose")); //remove exit buttons
} else if (navigator.userAgent.match(/QQ\//i)) {
console.log("MOBILE QQ CLIENT");
window.location.href =
window.location.href.match(/^[^\#\?]+/)[0] + "#showqrcode";
document.getElementById("titleinfo").innerHTML =
"长按识别二维码 向" + myname + "支付";
// Melt the car door (((
document.getElementById("h").removeChild(document.getElementById("i")); // remove profile photo
document
.getElementById("pending")
.removeChild(document.getElementById("depends")); // remove buttons
document
.getElementById("btncontainer")
.removeChild(document.getElementById("qrcodeclose")); // remove exit buttons
document
.getElementById("qrcontainer")
.removeChild(document.getElementById("currentqrcode")); // remove default qrcode (mobile qq only)
// Import from api
document.getElementById("tenpayonly").src = qrcodeapi + tenpay;
}

// Verify if mobile browser only
else {
if (
location.href.substr(location.href.lastIndexOf("#") + 1) == "showqrcode" &&
!selected
)
document.getElementById("showqrcode").style.display = "none";
document.getElementById("qrcodeclose").onclick = function() {
document.getElementById("currentqrcode").innerHTML = "";
if (document.getElementById("showqrcode").style.display == "flex")
document.getElementById("showqrcode").style.display = "";
};
}
if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
console.log("MOBILE BROWSER CLIENT");
} else {
console.log("DESKTOP BROWSER CLIENT");
}
// UserAgent Verify Part Ends

// Verify if `paypal` is defined
if (typeof paypal !== "string") {
document
.getElementById("depends")
.removeChild(document.getElementById("paypalbtn"));
console.log("PAYPAL BUTTON REMOVED");
} else {
function openbox() {
selected = "yes";
window.open(
paypal,
"_blank",
"toolbar=no,scrollbars=no,visible=none,width=360,height=640"
);
}
console.log("PAYPAL BUTTON OPERATING");
}

// Onclick Function Part Starts
function openwechat() {
selected = "yes";
document.getElementById("titleinfo").innerHTML =
"微信扫一扫 向" + myname + "支付";
client = wechat;
showqrcode();
}
function openalipay() {
selected = "yes";
document.getElementById("titleinfo").innerHTML =
"支付宝扫一扫 向" + myname + "支付";
client = alipay;
showqrcode();
}
function opentenpay() {
selected = "yes";
document.getElementById("titleinfo").innerHTML =
"手机QQ扫一扫 向" + myname + "支付";
client = tenpay;
showqrcode();
}
// Onclick Function Part Ends

// Fill in tile and subtitle
document.getElementById("name").innerHTML = title;
document.getElementById("description").innerHTML = subtitle;

// See if `debugmode` is defined
if (typeof debugmode !== "undefined" && debugmode !== null) {
console.log("DEBUG MODE ENABLED ↑");
// Copyright console log from https://github.com/MoePlayer/APlayer/. Thank you.
console.log(
`${"\n"} %c merger.html %c https://github.com/hifocus/merger ${"\n"}`,
"color: #fadfa3; background: #030307; padding:5px 0;",
"background: #fadfa3; padding:5px 0;"
);
} else {
console.clear();
console.log("DEBUG MODE DISABLED ↑");
}

function showqrcode() {
if (
location.href.substr(location.href.lastIndexOf("#") + 1) == "showqrcode" &&
selected == "yes"
)
document.getElementById("showqrcode").style.display = "flex";
$("#currentqrcode").qrcode({
render: "image",
size: 300 * scale,
text: client
});
}
16 changes: 16 additions & 0 deletions elements/function.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

123 changes: 123 additions & 0 deletions elements/function.original.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@

// HTML Template Merger - Merge your qrcode quicker.
// Released under GNU General Public License v3.0. Opensourced. (https://github.com/hifocus/merger)
// Author @hifocus (https://github.com/hifocus), @LF112 (https://github.com/lf112)
// Copyright reservation is required.

var client;
var selected;

// Set profile photo
document.getElementById("i").style.background = "url('" + profile + "') no-repeat center/cover";

// UserAgent Verify Part Starts
var scale = window.devicePixelRatio; // Change to 1 on retina screens to see blurry canvas.

document.getElementById("titleinfo").innerHTML = "惶心最帅";

// General UserAgent verify rules
if (navigator.userAgent.match(/Alipay/i)) {
console.log("ALIPAY CLIENT");
// Redirect directly
window.location.href = alipay;
}
else if (navigator.userAgent.match(/MicroMessenger\//i)) {
if(location.href.substr(location.href.lastIndexOf('#')+1) == "showqrcode" && !selected) document.getElementById('showqrcode').style.display = "none";
console.log("WECHAT CLIENT");
client = wechat;
// Click the button, import from js
document.getElementById("toclick").click();
document.getElementById("titleinfo").innerHTML = "长按识别二维码 向" + myname + "支付";
// Melt the car door (((
document.getElementById("h").removeChild(document.getElementById("i")); // remove profile photo
document.getElementById("pending").removeChild(document.getElementById("depends")); // remove buttons
document.getElementById("btncontainer").removeChild(document.getElementById("qrcodeclose")); //remove exit buttons
}

else if (navigator.userAgent.match(/QQ\//i)) {
console.log("MOBILE QQ CLIENT");
window.location.href = window.location.href.match(/^[^\#\?]+/)[0] + "#showqrcode";
document.getElementById("titleinfo").innerHTML = "长按识别二维码 向" + myname + "支付";
// Melt the car door (((
document.getElementById("h").removeChild(document.getElementById("i")); // remove profile photo
document.getElementById("pending").removeChild(document.getElementById("depends")); // remove buttons
document.getElementById("btncontainer").removeChild(document.getElementById("qrcodeclose")); // remove exit buttons
document.getElementById("qrcontainer").removeChild(document.getElementById("currentqrcode")); // remove default qrcode (mobile qq only)
// Import from api
document.getElementById("tenpayonly").src = qrcodeapi + tenpay;
}

// Verify if mobile browser only
else {
if(location.href.substr(location.href.lastIndexOf('#')+1) == "showqrcode" && !selected) document.getElementById('showqrcode').style.display = "none";
document.getElementById('qrcodeclose').onclick = function (){
document.getElementById('currentqrcode').innerHTML = "";
if(document.getElementById('showqrcode').style.display == "flex") document.getElementById('showqrcode').style.display = "";
}
}
if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
console.log("MOBILE BROWSER CLIENT");
}
else {
console.log("DESKTOP BROWSER CLIENT");
}
// UserAgent Verify Part Ends


// Verify if `paypal` is defined
if (typeof paypal !== "string") {
document.getElementById("depends").removeChild(document.getElementById("paypalbtn"));
console.log("PAYPAL BUTTON REMOVED");
}
else {
function openbox() {
selected = "yes";
window.open(paypal, "_blank", "toolbar=no,scrollbars=no,visible=none,width=360,height=640");
}
console.log("PAYPAL BUTTON OPERATING")
}

// Onclick Function Part Starts
function openwechat() {
selected = "yes";
document.getElementById("titleinfo").innerHTML = "微信扫一扫 向" + myname + "支付";
client = wechat;
showqrcode();
}
function openalipay() {
selected = "yes";
document.getElementById("titleinfo").innerHTML = "支付宝扫一扫 向" + myname + "支付";
client = alipay;
showqrcode();
}
function opentenpay() {
selected = "yes";
document.getElementById("titleinfo").innerHTML = "手机QQ扫一扫 向" + myname + "支付";
client = tenpay;
showqrcode();
}
// Onclick Function Part Ends

// Fill in tile and subtitle
document.getElementById("name").innerHTML = title;
document.getElementById("description").innerHTML = subtitle;

// See if `debugmode` is defined
if (typeof debugmode !== "undefined" && debugmode !== null) {
console.log("DEBUG MODE ENABLED ↑");
// Copyright console log from https://github.com/MoePlayer/APlayer/. Thank you.
console.log(`${'\n'} %c merger.html %c https://github.com/hifocus/merger ${'\n'}`, 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');
}
else {
console.clear();
console.log("DEBUG MODE DISABLED ↑");
}

function showqrcode() {
if (location.href.substr(location.href.lastIndexOf('#') + 1) == "showqrcode" && selected == "yes") document.getElementById('showqrcode').style.display = "flex";
$("#currentqrcode").qrcode({
render: "image",
size: 300 * scale,
text: client
});
}
5 changes: 5 additions & 0 deletions elements/style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/* HTML Template Merger - Merge your qrcode quicker.
Released under GNU General Public License v3.0. Opensourced. (https://github.com/hifocus/merger)
Author @hifocus (https://github.com/hifocus), @LF112 (https://github.com/lf112)
Copyright reservation is required. */

/*
HTML Templete Grouper - The Best Way To Share Your Chatting Group To The Public.
GitHub: [https:/github.com/hifocus/Grouper] , Released Under MIT Lisence
Expand Down
Loading

0 comments on commit 47a6a93

Please sign in to comment.