/**
 * given an url with query parameters, this function returns all the 
 * query parameters as an object with name and value as key and value respectively.
 */
function parseQueryString(url) {
    var urlObj = {};
    var reg = /([^?=&]+)=([^?=&]+)/g;
    url.replace(reg, ($0, $1, $2) => {
        urlObj[$1] = decodeURIComponent($2);
    })
    return urlObj;
}

//复制
function goCopy (data) {
//	var data = document.getElementById('copy').innerHTML;
	copy_2.innerHTML = data;
	copy_1.setAttribute('value',data)
	if(Boolean(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i))){
		//区分iPhone设备
		window.getSelection().removeAllRanges();//这段代码必须放在前面否则无效
		var Url2=document.getElementById("copy_2");//要复制的节点
		var range = document.createRange();
		//选中需要复制的节点
		range.selectNode(Url2);
		//执行选中元素
		window.getSelection().addRange(range);
		//执行copy操作
		var successful = document.execCommand("copy");
		//移除选中的元素
		window.getSelection().removeAllRanges();
	}else{
		var Url2=document.getElementById("copy_1");//要复制的节点
		Url2.select();//选择对象
		document.execCommand("Copy");//执行浏览器复制命令
	}
	showMsg("复制成功，请到浏览器中打开链接")
 }

/**
 * [showMsg 提示各种错误信息,3s后消失]
 */
function showMsg(msg) {
    var msgBox = $('.alert-info');
    msgBox.children('p').text(msg);
    msgBox.show();

    setTimeout(function() {
        msgBox.hide();
    }, 1500);
}