{"comment":{"url":"https://api.github.com/repos/checkstyle/checkstyle/comments/10757479","html_url":"https://github.com/checkstyle/checkstyle/commit/ee518dfe86b29d1fa4d76f0dc0c11fb83afafda1#commitcomment-10757479","id":10757479,"user":{"login":"roniest","id":11977389,"avatar_url":"https://avatars.githubusercontent.com/u/11977389?v=3","gravatar_id":"","url":"https://api.github.com/users/roniest","html_url":"https://github.com/roniest","followers_url":"https://api.github.com/users/roniest/followers","following_url":"https://api.github.com/users/roniest/following{/other_user}","gists_url":"https://api.github.com/users/roniest/gists{/gist_id}","starred_url":"https://api.github.com/users/roniest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roniest/subscriptions","organizations_url":"https://api.github.com/users/roniest/orgs","repos_url":"https://api.github.com/users/roniest/repos","events_url":"https://api.github.com/users/roniest/events{/privacy}","received_events_url":"https://api.github.com/users/roniest/received_events","type":"User","site_admin":false},"position":null,"line":null,"path":"","commit_id":"ee518dfe86b29d1fa4d76f0dc0c11fb83afafda1","created_at":"2015-04-16T13:45:19Z","updated_at":"2015-04-16T13:45:19Z","body":"<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\r\n<title>Google Drive Files to Dropbox</title>\r\n<meta name=\"description\" content=\"Drive Files to Dropbox is a file transfer, backup tool for Google Drive. It allow you to save Google Drive's files to Dropbox folder directly. You can backup your Google Drive to Dropbox.\">\r\n<meta name=\"keywords\" content=\"google drive to dropbox, save file to dropbox, google drive backup, drive file transfer, drive file backup, cloud file transfer, cloud backup\">\r\n\r\n<meta property=\"og:title\" content=\"Google Drive Files to Dropbox\"> \r\n<meta property=\"og:description\" content=\"Drive Files to Dropbox is a file transfer, backup tool for Google Drive. It allow you to save Google Drive's files to Dropbox folder directly. You can backup your Google Drive to Dropbox.\">\r\n<meta property=\"og:type\" content=\"website\">\r\n<meta property=\"og:url\" content=\"http://cloudtransfer.nsspot.net/\">\r\n<meta property=\"og:image\" content=\"http://cloudtransfer.nsspot.net/img/logo128.png\">\r\n\r\n\r\n<link rel=\"shortcut icon\" href=\"./favicon.ico\">\r\n<head>\r\n<style>\r\nbody,table,td,span,select,input,textarea{\r\n\tfont-size:14px;\r\n\tfont-family: Verdana, Arial, Helvetica, sans-serif;\r\n}\r\nbutton{\r\n\tfont-size:14px;\r\n\tfont-family: Verdana, Arial, Helvetica, sans-serif;\r\n}\r\n\r\nbody{\r\n\tbackground:#e3e3e3;\r\n}\r\n\r\nA:link    {color:#0860A8;text-decoration:none;}\r\nA:visited {color:#0860A8;text-decoration:none;}\r\nA:active  {color:#0860A8;text-decoration:underline;}\r\nA:hover  {color:#0860A8;text-decoration:underline;}\r\n\r\n.divopt{\r\n\t-webkit-box-shadow: 0 0 10px #999;\r\n\t-moz-box-shadow: 0 0 10px #999;\r\n\tbox-shadow: 0 0 10px #999;\r\n\t/*border-radius:7px;\r\n\t-moz-border-radius:7px;*/\r\n}\r\n.menulink{\r\n\tfont-size:15px;\r\n}\r\n.input{\r\n\twidth:630px;\r\n}\r\n.small{\r\n\tfont-size:13px;\r\n}\r\n</style>\r\n\r\n<script src=\"js/common.js\" type=\"text/javascript\"></script>\r\n\r\n<script>\r\nvar g_debug=false;\r\nvar g_expires=1000*60*60*6;\r\nvar henc=html_entity_encode;\r\nfunction setstorage(name,value){\r\n\tif (window.localStorage){\r\n\t\tlocalStorage[name]=value+'';\r\n\t}else{\r\n\t\t//setCookie(name, value, 1000*60*60*24*365*10); \r\n\t}\r\n}\r\n\r\nfunction getstorage(name){\r\n\tvar s;\r\n\tif (window.localStorage){\r\n\t\ts=localStorage[name];\r\n\t}else{\r\n\t\t//s=getCookie(name);\r\n\t}\r\n\treturn s;\r\n}\r\n\r\nfunction init(){\r\n\twindow.onunload=function(){\r\n\t\tproc_saveopt();\r\n\t}\t\r\n}\r\n</script>\r\n</head>\r\n<body onload=\"init()\">\r\n\r\n<table align=center>\r\n<tr><td height=10>\r\n</table>\r\n\r\n<table id=\"maintable\" width=810 border=0 align=center class=\"divopt\" style=\"background-color:white;padding:6px 6px 6px 6px;border: 0px solid #2E79DB;\">\r\n<tr><td>\r\n<center>\r\n<script type=\"text/javascript\">\r\n    google_ad_client = \"ca-pub-1113541014872557\";\r\n    google_ad_slot = \"3307749504\";\r\n    google_ad_width = 728;\r\n    google_ad_height = 15;\r\n</script>\r\n<script type=\"text/javascript\"\r\nsrc=\"//pagead2.googlesyndication.com/pagead/show_ads.js\">\r\n</script>\r\n</center>\r\n\r\n<table width=100%><tr>\r\n<td><img src=\"img/logo65.png\" width=65>\r\n<td>\r\n<td><a id=\"toptitle\" href=\"./\" title=\"Go Home\" style=\"color:#1667A0\"><span style=\"font-size:27px;font-family:Verdana, Arial;white-space:nowrap;\">Google Drive Files to Dropbox</span></a>\r\n<div style=\"margin-left:2px;margin-top:3px\">\r\nDrive Files to Dropbox is a file transfer, backup tool for Google Drive. It allow you to save Google Drive's files to Dropbox folder directly. You can backup your Google Drive to Dropbox.<br>\r\nYou don't need to install any further software or extension. This app only works locally without going through the server. Your files are completely safe, guarantees privacy.<br>\r\nIntegrate your Google Drive with Dropbox. Provides connect with Google Drive. You can directly use this app with your drive.<br>\r\nNote: You can save up to 100 files at a time.\r\n</div>\r\n</table>\r\n\r\n<center>\r\n<script type=\"text/javascript\">\r\n    google_ad_client = \"ca-pub-1113541014872557\";\r\n    google_ad_slot = \"1831016305\";\r\n    google_ad_width = 728;\r\n    google_ad_height = 90;\r\n</script>\r\n<script type=\"text/javascript\"\r\nsrc=\"//pagead2.googlesyndication.com/pagead/show_ads.js\">\r\n</script>\r\n</center>\r\n\r\n<tr><td>\r\n<script>\r\nfunction fillnumber(s){\r\n\ts=String(s);\r\n\tif ( s.length==1 ) { \r\n\t\treturn '0'+s;  \r\n\t}\r\n\treturn s;\r\n}\t\r\nfunction datetimetostring(ts,onlytime){\r\n\tvar t=new Date(ts);\r\n\tvar s='';\r\n\tif(!isNaN(t)){\r\n\t\tvar y=t.getFullYear();\r\n\t\tvar m=t.getMonth()+1;\r\n\t\tvar d=t.getDate();\r\n\t\tif(onlytime) s=fillnumber(t.getHours())+':'+fillnumber(t.getMinutes())+':'+fillnumber(t.getSeconds());\r\n\t\telse s=y+'-'+fillnumber(m)+'-'+fillnumber(d)+' '+fillnumber(t.getHours())+':'+fillnumber(t.getMinutes())+':'+fillnumber(t.getSeconds());\r\n\t}\r\n\treturn s;\r\n}\r\n\r\nfunction get_data(){\r\n\tvar s=getstorage(\"c_filedata3\");\r\n\tif (!s) s=\"[]\";\r\n\tvar a=[];\r\n\ttry{\r\n\t\ta=JSON.parse(s);\r\n\t}catch(err){\r\n\t\ta=[];\r\n\t}\r\n\tif(!a) a=[];\r\n\treturn a;\r\n}\r\n\r\nfunction proc_savetohistory(){\r\n\tvar subject=getstorage('c_lastsubject') || '';\r\n\tsubject=prompt(\"Please enter a title or name.\",subject);\t\r\n\tif(!subject){\r\n\t\t//alert('You need to enter the subject.');\r\n\t\treturn;\r\n\t}\r\n\tsetstorage('c_lastsubject',subject);\r\n\tvar b={};\r\n\tb.id=(new Date()).getTime();\r\n\tb.subject=subject;\r\n\tb.files=[];\r\n\tvar d;\r\n\tfor(var i= 0; i <= gd_files.length-1;i++){\r\n\t\tif(!gd_files[i].id)continue;\r\n\t\td={};\r\n\t\td.id=gd_files[i].id;\r\n\t\td.name=gd_files[i].name;\r\n\t\tb.files.push(d);\r\n\t}\r\n\r\n\tvar a=get_data();\r\n\ta.push(b);\r\n\tif(a.length>15) a.splice(0,1);\r\n\tif(window.JSON) setstorage(\"c_filedata3\",JSON.stringify(a));\t\t\r\n\t\r\n\tproc_displayhistory();\r\n\tvar obj=_getid('history');\r\n\tif(obj.options.length>=2) obj.selectedIndex=1;\r\n}\r\nfunction proc_displayhistory(){\r\n\tvar obj=_getid('history');\r\n\tvar a=get_data();\r\n\t\r\n\tfor(var i=obj.options.length-1;i>=0;i--) obj.remove(i);\r\n\tvar c=document.createElement(\"option\");\r\n\tc.value='';\r\n\tc.appendChild(document.createTextNode('*File History'));\t\t         \r\n\tobj.appendChild(c);\t\t\r\n\r\n\tvar s;\r\n\tfor(var i=a.length-1;i>=0;i--){\r\n\t\tvar c=document.createElement(\"option\");\r\n\t\tc.value=a[i].id;\t\t\r\n\t\ts=a[i].subject+' ('+datetimetostring(a[i].id)+')';\r\n\t\tc.appendChild(document.createTextNode(s));\t\t         \r\n\t\tobj.appendChild(c);\t\t\r\n\t}\r\n}\r\n\r\nfunction proc_historychange(){\r\n\tvar obj=_getid('history');\r\n\tif(!obj.value)return;\r\n\tvar a=get_data();\r\n\tfor(i = 0; i < a.length; i++){\r\n\t\tif(a[i].id==obj.value){\r\n\t\t\tif(a[i].files && a[i].files.length>0){\r\n\t\t\t\tattach_clear();\t\t\t\t\t\t\t\t\r\n\t\t\t\tvar docs=[];var d;\r\n\t\t\t\tfor(var j = 0; j <= a[i].files.length-1;j++){\r\n\t\t\t\t\tif(!a[i].files[j].id)continue;\r\n\t\t\t\t\td={};\r\n\t\t\t\t\td.id=a[i].files[j].id;\r\n\t\t\t\t\td.name=a[i].files[j].name;\r\n\t\t\t\t\tdocs.push(d);\r\n\t\t\t\t}\r\n\t\t\t\tgd_login(function(result){\r\n\t\t\t\t\tif(!result) return;\r\n\t\t\t\t\tgd_loadfiles(docs);\r\n\t\t\t\t},true);\t\t\t\t\t\t\t\t\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\nfunction proc_deletehistory(){\r\n\tvar obj=_getid('history');\r\n\tif(!obj.value)return;\r\n\tvar a=get_data();\r\n\tfor(i = 0; i < a.length; i++){\r\n\t\tif(a[i].id==obj.value){\r\n\t\t\ta.splice(i,1);\r\n\t\t\tif(window.JSON) setstorage(\"c_filedata3\",JSON.stringify(a));\r\n\t\t\tvar idx=obj.selectedIndex;\r\n\t\t\tobj.remove(idx);\r\n\t\t\tif(idx>obj.options.length-1) idx=obj.options.length-1;\r\n\t\t\tobj.selectedIndex=idx;\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\nfunction proc_clearhistory(){\r\n\tfor(i = 1; i <= 2; i++){\r\n\t\tvar answer=confirm(\"All stored history will be deleted. [\"+i+\"/2]\"+\"\\n\\n\"+\"Are you sure?\");\t\t\t\t\r\n\t\tif(!answer) return;\r\n\t}\r\n\tsetstorage(\"c_filedata3\",\"[]\");\r\n\tvar obj=_getid('history');\r\n\tfor(var i=obj.options.length-1;i>=1;i--) obj.remove(i);\r\n}\r\n\r\nfunction proc_saveopt(){\r\n\tvar b=[];\r\n\tvar c;\r\n\tvar obj=_getid(\"optcontainer\");\r\n\tvar a=obj.getElementsByTagName('INPUT');\r\n\tfor(var i = 0; i < a.length; i++){    \r\n\t\tif(a[i].type=='checkbox'){\r\n\t\t\tc={};\r\n\t\t\tc.name=a[i].name;\r\n\t\t\tc.type=a[i].type;\r\n\t\t\tc.checked=a[i].checked;\r\n\t\t\tb.push(c);\r\n\t\t}else if(a[i].type=='text'){\r\n\t\t\tc={};\r\n\t\t\tc.name=a[i].name;\r\n\t\t\tc.type=a[i].type;\r\n\t\t\tc.value=a[i].value || '';\r\n\t\t\tb.push(c);\r\n\t\t}\r\n\t}\r\n\tvar a=obj.getElementsByTagName('SELECT');\r\n\tfor(var i = 0; i < a.length; i++){    \r\n\t\tif(a[i].form && a[i].form.name){\r\n\t\t\tc={};\r\n\t\t\tc.name=a[i].name;\r\n\t\t\tc.type='select';\r\n\t\t\tc.value=a[i].value || '';\r\n\t\t\tb.push(c);\r\n\t\t}\r\n\t}\r\n\r\n\tif(window.JSON) setstorage('c_opt',JSON.stringify(b));\r\n}\r\nfunction proc_loadopt(){\r\n\tvar s=getstorage('c_opt');\r\n\tvar b=[];\r\n\ttry{\r\n\t\tb=JSON.parse(s);\r\n\t}catch(err){\r\n\t\tb=[];\r\n\t}\r\n\tif(!b) b=[];\r\n\r\n\tvar c;\r\n\tfor(var i = 0; i < b.length; i++){    \r\n\t\tif(b[i].type=='checkbox'){\r\n\t\t\tc=document.optcontainer[b[i].name];\r\n\t\t\tif(c) c.checked=b[i].checked;\r\n\t\t}else if(b[i].type=='select' || b[i].type=='text'){\r\n\t\t\tc=document.optcontainer[b[i].name];\r\n\t\t\tif(c) c.value=b[i].value;\r\n\t\t}\r\n\t}\r\n\tvar a=_getid(\"optcontainer\").getElementsByTagName('*');\r\n\tfor(var i = 0; i < a.length; i++){    \r\n\t\tif(a[i].tagName=='SELECT'){\r\n\t\t\ta[i].onchange=proc_saveopt;\r\n\t\t}else if(a[i].type=='checkbox'){\r\n\t\t\tif(a[i].name=='o_remove'){\r\n\t\t\t\ta[i].onclick=function(){\r\n\t\t\t\t\tproc_saveopt();\r\n\t\t\t\t}\t\t\t\t\r\n\t\t\t}else{\r\n\t\t\t\ta[i].onclick=proc_saveopt;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunction proc_show(name){\r\n\tvar a=_getid(name);\r\n\tif(!a)return;\r\n\tif(a.style.display=='') a.style.display='none';\r\n\telse a.style.display='';\r\n}\r\n</script>\r\n\r\n<style>\r\n.uploaded{color:green;}\r\n.error{color:#8A0808;}\r\n.welcome{color:#45616D;}\r\n.bold1{color:green;}\r\n.log{\r\n\twidth:100%;height:170px;\r\n}\r\n.big1{\r\n\tfont-size:20px;\r\n}\r\n#logtab a{\r\n\tfont-size:14px;\r\n}\r\n#gd_progress{\r\n\twidth:650px;white-space:nowrap;overflow:hidden;border:0px solid red;\r\n}\r\n</style>\r\n\t<table width=100%>\t\t\t\t\t\r\n\t\t<tr><td>\t\t\t\r\n\t\t\t<button type=\"button\" id='btn_open' onclick=\"gd_open_picker()\" title=\"Select files and folders from Google Drive\" style=\"\"><img src=\"images/gdrive/product16.png\" width=16 align=\"absmiddle\"> Select files, folders from Google Drive</button>\r\n\t\t\t<button type=\"button\" id=\"gd_btn_reopen\" onclick=\"gd_reopen()\" style=\"display:none\" title=\"Reopen the file loaded from drive.google.com\"><img src=\"images/gdrive/product16.png\" width=16 align=\"absmiddle\"> Reopen</button>\t\t\r\n\t\t\t<button type=\"button\" onclick=\"attach_delete()\">Remove</button>\r\n\t\t\t<button type=\"button\" onclick=\"attach_clear()\">Clear</button>\t\t\t\r\n\t\t<tr><td>\t\t\t\r\n\t\t\t<div id=\"downlink\" style=\"margin-bottom:2px\">Add files, folders to the list below. Select from Google Drive. <span id=spancount></span></div>\r\n\t\t\t<select id='attachment' style=\"width:100%;height:200px\" multiple=true onchange=\"attachment_onchange(this)\" onclick=\"attachment_onchange(this)\"></select>\r\n\r\n\t\t\t<div id=\"desc\" style=\"margin-top:2px;color:green;width:700px;white-space:nowrap;overflow:hidden;border:0px solid red\"></div>\r\n\t\t\t<font style=\"font-size:13px\">*Unknown Size: Google Document Formats.</font> &nbsp;<span id=\"spandown\"></span>\r\n\r\n\t\t\t<table align=center>\r\n\t\t\t<td><button type=button onclick=\"proc_savetohistory()\">Save this file list</button>\r\n\t\t\t<td><select id='history' onchange=\"proc_historychange()\" style=\"width:300px\"></select>\r\n\t\t\t<td><button type=button onclick=\"proc_historychange()\" title=\"Select\"><img src=\"images/commit.png\"></button>\r\n\t\t\t<td><button type=button onclick=\"proc_deletehistory()\" title=\"Delete\"><img src=\"images/close.png\"></button>\r\n\t\t\t<td><button type=button onclick=\"proc_clearhistory()\">Clear all</button>\r\n\t\t\t</table>\r\n\r\n\t\t<tr><td align=center>\r\n\t\t\t<button type=button id=\"btn_ok\" onclick=\"attach_saveall()\" class=\"big1\"><img src=\"images/dropbox2.png\" width=18 align=\"absmiddle\"> Save to Dropbox</button>\r\n\t\t\t<button type=button onclick=\"proc_show('optcontainer')\" class=\"\" style=\"\">Options</button>\t\t\r\n\t\t<tr><td>\r\n\t\t\t<form id=\"optcontainer\" name=\"optcontainer\" style=\"display:none;border:2px dashed #0860A8;padding:2px\" onsubmit=\"return false\">\r\n\t\t\t\t<table>\r\n\t\t\t\t<tr><td>*Prefered Export Formats for Google Documents\r\n\t\t\t\t<tr><td>\r\n\t\t\t\t\tDocuments <select name='o_prefer_doc'><option value=\"pdf\">PDF<option value=\"docx\">DOCX<option value=\"odt\">ODT</select>\r\n\t\t\t\t\tSpreadsheet <select name='o_prefer_spr'><option value=\"pdf\">PDF<option value=\"xlsx\">XLSX</select>\r\n\t\t\t\t\tPresentation <select name='o_prefer_pre'><option value=\"pdf\">PDF<option value=\"pptx\">PPTX</select>\r\n\t\t\t\t\tDrawing <select name='o_prefer_dra'><option value=\"pdf\">PDF<option value=\"png\">PNG<option value=\"svg\">SVG</select>\r\n\t\t\t\t</table>\r\n\t\t\t</form>\r\n\r\n\t\t<tr><td>\r\n\t\t\t<div id=\"downlink2\" style=\"margin-bottom:2px\"></div>\r\n\t\t\t<div id=\"log4\" class=\"log\" style=\"overflow-y:scroll;\"></div>\t\t\t\r\n\t</table>\r\n\r\n<tr><td>\r\n<tr><td align=center>\r\n<script type=\"text/javascript\">\r\n    google_ad_client = \"ca-pub-1113541014872557\";\r\n    google_ad_slot = \"1831016305\";\r\n    google_ad_width = 728;\r\n    google_ad_height = 90;\r\n</script>\r\n<script type=\"text/javascript\"\r\nsrc=\"//pagead2.googlesyndication.com/pagead/show_ads.js\">\r\n</script>\r\n\r\n</table>\r\n\r\n<script>\r\nvar ischrome=false;\r\nif (navigator.userAgent.indexOf(\"Chrome\")>=0) ischrome=true;\r\n\r\nfunction init_load(){\r\n\tproc_displayhistory();\r\n\tproc_loadopt();\r\n\tvar sw=_getid('attachment').offsetWidth;\r\n\tfor(var i = 1; i <= 7; i++){\r\n\t\tvar a=_getid(\"log\"+i);\r\n\t\tif(a){\r\n\t\t\tif(ischrome) a.setAttribute(\"readonly\", \"true\");\r\n\t\t\ta.setAttribute(\"spellcheck\", \"false\");\r\n\t\t\ta.setAttribute(\"wrap\", \"off\");\r\n\t\t\ta.style.width=sw+'px';\r\n\t\t}\r\n\t}\r\n}\r\ninit_load();\r\n</script>\r\n\r\n<style>\r\na.bottomlink:link{text-decoration:underline;}\r\na.bottomlink:visited{text-decoration:underline;}\r\na.bottomlink:active{text-decoration:underline;}\r\na.bottomlink:hover{text-decoration:underline;}\r\n</style>\r\n\r\n<table id=\"bottomtable\" align=center>\r\n<tr><td height=7>\r\n<tr><td align=center><span id=\"bottomtitle\">ⓒ Google Drive Files to Dropbox, 2015</span>\r\n\t</table><br>\r\n\r\n<script type=\"text/javascript\" src=\"https://www.dropbox.com/static/api/2/dropins.js\" id=\"dropboxjs\" data-app-key=\"kr19li1hb5w4btr\"></script>\r\n<style>\r\n.gd_div{background-color:#FFFFE1;position:absolute;overflow:hidden;-webkit-box-shadow: 0 0 25px #999;-moz-box-shadow: 0 0 25px #999;box-shadow: 0 0 25px #999;}\r\n</style>\r\n<div id=\"layer_message\" class=\"gd_div\" style=\"z-index:10001;display:none;\"></div>\r\n<div id=\"gd_window\" class=\"gd_div\" style=\"z-index:10000001;display:none;\"></div>\r\n<div id=\"gd_btn_login\" class=\"gd_div\" style=\"z-index:10000000;display:none;\">\r\n<table>\r\n<tr><td align=center><button onclick=\"gd_login_manual()\" style=\"font-size:20px\"><img src=\"images/gdrive/product20.png\" align=\"absmiddle\"> Login & Authorize</button> <button onclick=\"gd_login_close()\" style=\"font-size:20px\">Close</button>\r\n<tr><td>To use this app, Please login to the Google Drive and authorize this app or website.\r\n<br>(Note: If your browser block or disable the third-party cookies, this login does not work correctly.)\r\n</table>\r\n</div>\r\n<script>\r\nvar CLIENT_ID = '748420716766-2aq6o93s4t1du1j7v2kgrneaipba8eg7.apps.googleusercontent.com';\r\nvar SCOPES = [\r\n\t'https://www.googleapis.com/auth/drive.install',\r\n\t'https://www.googleapis.com/auth/drive'\r\n];\r\nvar gd_developerKey='AIzaSyB7Yf_oj3QdO1CJ4BbAPGxgYG1LUCPJT4Q';\r\nvar gd_mimetype=\"\";\r\nvar gd_export_extension=[];\r\nvar gd_state='';\r\n\r\nvar gd_picker,gd_loaded,gd_pickerloaded,gd_lastprogress,gd_issupported,gd_isdownloading,gd_load_timer,gd_bloburl,gd_state2;\r\nvar gd_loginexp=0;\r\nvar gd_callback;\r\nvar ismsie=false;\r\nif(navigator.appName!=\"Netscape\"){\r\n\tif(navigator.userAgent.indexOf(\"MSIE\")>=0) ismsie=true;\r\n}\r\n\r\nfunction number_format(number, decimals, dec_point, thousands_sep) {\r\n  number = (number + '').replace(/[^0-9+\\-Ee.]/g, '');\r\n  var n = !isFinite(+number) ? 0 : +number,\r\n    prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),\r\n    sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,\r\n    dec = (typeof dec_point === 'undefined') ? '.' : dec_point,\r\n    s = '',\r\n    toFixedFix = function (n, prec) {\r\n      var k = Math.pow(10, prec);\r\n      return '' + Math.round(n * k) / k;\r\n    };\r\n  s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');\r\n  if (s[0].length > 3) {\r\n    s[0] = s[0].replace(/\\B(?=(?:\\d{3})+(?!\\d))/g, sep);\r\n  }\r\n  if ((s[1] || '').length < prec) {\r\n    s[1] = s[1] || '';\r\n    s[1] += new Array(prec - s[1].length + 1).join('0');\r\n  }\r\n  return s.join(dec);\r\n}\r\nfunction getWindowWidth(){\r\n    var windowWidth = 0;\r\n    if (typeof(window.innerWidth) == 'number'){\r\n        windowWidth = window.innerWidth;\r\n    }else{\r\n        var ieStrict = document.documentElement.clientWidth;\r\n        var ieQuirks = document.body.clientWidth; \r\n        windowWidth = (ieStrict > 0) ? ieStrict : ieQuirks;\r\n    }\r\n\tif(!windowWidth) windowWidth=0;\r\n    return windowWidth;\r\n}\r\nfunction getWindowHeight(){\r\n    var windowHeight = 0;\r\n    if (typeof(window.innerHeight) == 'number'){\r\n        windowHeight = window.innerHeight;\r\n    }else{\r\n        var ieStrict = document.documentElement.clientHeight; \r\n        var ieQuirks = document.body.clientHeight;\r\n        windowHeight = (ieStrict > 0) ? ieStrict : ieQuirks;\r\n    }\r\n\tif(!windowHeight) windowHeight=0;\r\n    return windowHeight;\r\n}\r\nfunction getScrollLeft(){\r\n    var scrollLeft;\r\n\tif(document.body && document.body.scrollLeft){\r\n\t\tscrollLeft = document.body.scrollLeft;\r\n\t}else if(document.documentElement && document.documentElement.scrollLeft){\r\n\t\tscrollLeft = document.documentElement.scrollLeft;\r\n\t}\r\n\tif(!scrollLeft) scrollLeft=0;\r\n    return scrollLeft;\r\n}\r\nfunction getScrollTop(){\r\n    var scrollTop;\r\n\tif(document.body && document.body.scrollTop){\r\n\t\tscrollTop = document.body.scrollTop;\r\n\t}else if(document.documentElement && document.documentElement.scrollTop){\r\n\t\tscrollTop = document.documentElement.scrollTop;\r\n\t}\r\n\tif(!scrollTop) scrollTop=0;\r\n    return scrollTop;\r\n} \r\n\r\nvar messagetimer=null;\r\nfunction show_message(s,x,y,padding,timeout){\r\n\tif (!x) x=10;\r\n\tif (!y) y=10;\r\n\tif (!padding) padding=5;\r\n\tif (!timeout) timeout=2000;\r\n\r\n\tvar kind=1;\r\n\tfor(var i=1; i <= 4; i++){\r\n\t\tvar s1=\"layer_message\";\r\n\t\tif (i>1) s1=\"layer_message\"+i;\r\n\t\tvar obj=document.getElementById(s1);\r\n\t\tif (obj){\r\n\t\t\tkind=i;\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\t\t\t\r\n\tobj.style.left=\"1px\";\r\n\tobj.style.top=\"1px\";\t\t\r\n\tobj.innerHTML=\"<label>\"+s+\"</label>\";\r\n\tobj.style.display=\"\";\t\r\n\t\r\n\tif (kind==1) {\r\n\t\tx=getScrollLeft()+x;\t\r\n\t\ty=getScrollTop()+y;\r\n\t} else if (kind==2) {\r\n\t\tx=getScrollLeft()+((getWindowWidth()-obj.clientWidth) / 2);\r\n\t\ty=getScrollTop()+((getWindowHeight()-obj.clientHeight) / 2);\r\n\t} else if (kind==3) {\r\n\t\tx=document.body.offsetWidth-obj.clientWidth-5;\r\n\t\ty=getScrollTop()+y;\r\n\t} else {\r\n\t\tx=getScrollLeft()+((getWindowWidth()-obj.clientWidth) / 2);\r\n\t\ty=getScrollTop()+y;\r\n\t}\r\n\tx=parseInt(x);\r\n\ty=parseInt(y);\r\n\t\r\n\tobj.style[\"border\"]=\"1px solid #000000\";\r\n\tobj.style[\"padding\"]=padding+\"px\";\r\n\tobj.style.left=x+\"px\";\r\n\tobj.style.top=y+\"px\";\r\n\t\r\n\tif (messagetimer) clearTimeout(messagetimer);\r\n\tmessagetimer=setTimeout(hide_message, timeout);\r\n}\r\nfunction hide_message(){\r\n\tfor(var i=1; i <= 4; i++){\r\n\t\tvar s1=\"layer_message\";\r\n\t\tif (i>1) s1=\"layer_message\"+i;\r\n\t\tvar obj=document.getElementById(s1);\r\n\t\tif (obj){\r\n\t\t\tobj.style.display=\"none\";\r\n\t\t}\r\n\t}\r\n}\r\nfunction gd_btn_login2(e,callback){\r\n\tfunction go(a){\r\n\t\tif(a && a.style.display==''){\r\n\t\t\tvar x=getScrollLeft()+((getWindowWidth()-a.clientWidth) / 2);\r\n\t\t\tvar y=getScrollTop()+((getWindowHeight()-a.clientHeight) / 2);\r\n\t\t\ta.style[\"border\"]=\"1px solid #000000\";\r\n\t\t\ta.style[\"padding\"]=\"10px\";\r\n\t\t\ta.style.left=x+\"px\";\r\n\t\t\ta.style.top=y+\"px\";\r\n\t\t}\r\n\t}\r\n\tgo(_getid(\"gd_btn_login\"));\r\n\tgo(_getid(\"gd_window\"));\t\r\n\tsetTimeout(function(){\r\n\t\tgo(_getid(\"gd_btn_login\"));\r\n\t\tgo(_getid(\"gd_window\"));\t\r\n\t\tif(callback)callback();\r\n\t},10);\r\n}\r\nfunction gd_btn_login(isshow){\r\n\tvar a=_getid(\"gd_btn_login\");\r\n\tif(isshow){\r\n\t\ta.style.display='';\r\n\t\tgd_btn_login2();\r\n\t}else{\r\n\t\ta.style.display='none';\r\n\t}\r\n}\r\nfunction gd_login_close(){\r\n\tgd_btn_login(false);\r\n}\r\nfunction gd_login_manual(){\r\n\tvar p={'client_id': CLIENT_ID, 'scope': SCOPES.join(' '), 'immediate': false};\r\n\tif(gd_userId){p['login_hint']=gd_userId;p['authuser']=-1;}\r\n\tgapi.auth.authorize(p, function (authResult){ \r\n\t\tif (authResult && !authResult.error){\r\n\t\t\tglastlogintime=(new Date()).getTime();\r\n\t\t\tgd_loginexp=(new Date()).getTime()+parseInt(authResult.expires_in*0.7*1000);\r\n\t\t\tgd_btn_login(false);gd_info();\r\n\t\t\tshow_message(\"Login ok!!\");\r\n\t\t\tif(gd_callback) gd_callback(true);\r\n\t\t\telse gd_open_state();\r\n\t\t}else{\r\n\t\t\tgd_btn_login(true);\r\n\t\t\tshow_message(\"Login failed!!\");\r\n\t\t}\r\n\t});\r\n}\r\nfunction gd_login(callback,react){\r\n\tif(ismsie){\r\n\t\tif(gd_loginexp==0 || gd_loginexp<(new Date()).getTime()){\r\n\t\t}else{\r\n\t\t\tglastlogintime=(new Date()).getTime();\r\n\t\t\tcallback(true);\r\n\t\t\treturn;\r\n\t\t}\r\n\t}\r\n\tvar p={'client_id': CLIENT_ID, 'scope': SCOPES.join(' '), 'immediate': true};\r\n\tif(gd_userId){p['login_hint']=gd_userId;p['authuser']=-1;}\r\n\tgapi.auth.authorize(p, function (authResult){\r\n\t\tif (authResult && !authResult.error){\r\n\t\t\tglastlogintime=(new Date()).getTime();\r\n\t\t\tgd_loginexp=(new Date()).getTime()+parseInt(authResult.expires_in*0.7*1000);\r\n\t\t\tgd_btn_login(false);gd_info();\r\n\t\t\tcallback(true);\r\n\t\t}else{\r\n\t\t\tshow_message(\"Login failed!!\");\r\n\t\t\tgd_btn_login(true);\r\n\t\t\tcallback(false);\r\n\t\t\t//if(ismsie){\r\n\t\t\t\tif(react) gd_callback=callback;\r\n\t\t\t\telse gd_callback=null;\r\n\t\t\t//}\r\n\t\t}\r\n\t});\r\n}\r\n\r\nfunction gd_loadpicker() {\t\t\r\n\tgapi.load('picker',{'callback': function(){\r\n\t\t\tgd_pickerloaded=true;\r\n\t\t}\r\n\t});\t\r\n}\r\nfunction gd_createpicker() {\r\n\tvar access_token=gapi.auth.getToken().access_token;\r\n\tif(!access_token){\r\n\t\talert('Error!! No access token.');\r\n\t\treturn;\r\n\t}\r\n\tif(!gd_picker){\r\n\t  var view2 = new google.picker.DocsView(google.picker.ViewId.DOCS);\r\n\t  if(gd_mimetype) view2.setMimeTypes(gd_mimetype);\r\n\r\n\t\tvar view4 = new google.picker.DocsView();\r\n\t\tview4.setIncludeFolders(true);\r\n\t\tview4.setSelectFolderEnabled(true);\r\n\t\tview4.setParent(\"root\");\t\t\r\n\t\tview4.setMimeTypes(gd_mimetype);\r\n\t\tvar view5 = new google.picker.View(google.picker.ViewId.RECENTLY_PICKED);\r\n\r\n      gd_picker = new google.picker.PickerBuilder()\r\n          //.enableFeature(google.picker.Feature.NAV_HIDDEN)\r\n          .enableFeature(google.picker.Feature.MULTISELECT_ENABLED)\r\n          //.setAppId('')\r\n\t\t  .setLocale(\"en\") //window.navigator.language || window.navigator.userLanguage || \"en\"\r\n\t\t  .setTitle('Select files and folders')\r\n          .setOAuthToken(access_token)\r\n          .addView(view2)\r\n\t\t  .addView(view4)\r\n\t\t  .addView(view5)\r\n          .addView(new google.picker.DocsUploadView())\r\n          .setDeveloperKey(gd_developerKey)\r\n          .setCallback(gd_pickercallback)\r\n          .build();\r\n\t}\r\n\tgd_picker.setVisible(true);\r\n}\r\nfunction gd_pickercallback(data) {\r\n\tif (data.action == google.picker.Action.PICKED) {\r\n\t\t//console.log(data);\r\n\t\tif(data.docs && data.docs.length>0){\r\n\t\t\tgd_loadfiles(data.docs);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunction getsize(fileSize){\r\n\tif(!fileSize) return 'Unknown';\r\n\tfunction humanFileSize(bytes){\r\n\t\tvar thresh = 1024;\r\n\t\tif(bytes < thresh) return bytes + ' B';\r\n\t\tvar units = ['kB','MB','GB','TB','PB','EB','ZB','YB'];\r\n\t\tvar u = -1;\r\n\t\tdo {\r\n\t\t\tbytes /= thresh;\r\n\t\t\t++u;\r\n\t\t} while(bytes >= thresh);\r\n\t\treturn bytes.toFixed(1)+' '+units[u];\r\n\t}\r\n\treturn humanFileSize(fileSize);\r\n}\t\t\t\t\t\r\n\r\nfunction gd_count(){\r\n\tvar a=_getid('spancount');\r\n\tif(a && gd_files) a.innerHTML=\"(\"+gd_files.length+\" Added)\";\r\n}\r\n\r\nvar gd_files=[];\r\nvar gd_files_total;\r\nfunction gd_loadfiles(docs){\r\n\t/*if(!glogintime){\r\n\t\tglogintime=true;\r\n\t\tproc_logintime();\r\n\t}*/\r\n\r\n\tif(gd_isdownloading){\r\n\t\talert(\"It's working... Please try again in a few minutes.\");\r\n\t\treturn;\r\n\t}\r\n\r\n\tfunction end(){\r\n\t\tgd_isdownloading=false;\r\n\t\tclearTimeout(messagetimer);\r\n\t\thide_message();\r\n\t\tvar a=_getid(\"downlink\");\r\n\t\tif(a.innerHTML && a.innerHTML.indexOf(\"adownlink\")<0){\r\n\t\t\t_getid(\"downlink\").innerHTML=\"Add files, folders to the list below. Select from Google Drive. <span id=spancount></span>\";\r\n\t\t}\r\n\t}\t\r\n\tvar canceled=false;\r\n\t_getid(\"downlink\").innerHTML=\"<table><tr><td><img src='images/wait.gif' align='absmiddle'><td><a href='#' id='gd_cancel'>Cancel</a><td><div id='gd_progress'>Getting file information...</div></table>\";\t\r\n\t_getid('gd_cancel').onclick=function(){\r\n\t\tcanceled=true;\r\n\t\treturn false;\r\n\t}\r\n\tgd_isdownloading=true;\r\n\tif(!docs){\r\n\t\tend();return;\r\n\t}\r\n\r\n\tvar files=[];\r\n\tfor(var i = 0; i <= docs.length-1; i++){\r\n\t\tif(!docs[i].id)continue;\r\n\t\tvar d={};\r\n\t\td.id=docs[i].id;\r\n\t\td.name=docs[i].name;\r\n\t\td.done=false;\r\n\t\tfiles.push(d);\r\n\t}\r\n\t\r\n\tfunction complete(){\r\n\t\tvar d,s;\r\n\t\tvar a=_getid(\"attachment\");\r\n\t\tfor(var i = 0; i <= files.length-1; i++){\r\n\t\t\td=files[i];\r\n\t\t\tif(!d.resp || !d.resp.title || d.resp.mimeType=='application/vnd.google-apps.folder')continue;\r\n\t\t\tvar c=document.createElement(\"option\");\r\n\t\t\tc.value=d.id;\r\n\t\t\ts='';\r\n\t\t\tif(d.resp.exportLinks && !getSupported(d.resp)) s='[Not Supported] ';\r\n\t\t\tif(d.parent) s+=d.parent+'/';\r\n\t\t\ts=s+d.resp.title+' ('+getsize(d.resp.fileSize)+')';\t\t\t\r\n\t\t\tc.appendChild(document.createTextNode(s));\t\t \r\n\t\t\ta.appendChild(c);\t\t\r\n\t\t\tgd_files.push(files[i]);\r\n\t\t}\t\t\r\n\t\t_getid(\"downlink\").innerHTML=\"Add files, folders to the list below. Select from Google Drive. <span id=spancount></span>\";\r\n\t\tgd_count();\t\t\r\n\t}\r\n\r\n\tvar joblist=[];\r\n\tvar jobtimer;\r\n\tfunction getentryidx(){\r\n\t\tfor(var i = 0; i <= files.length-1; i++){\r\n\t\t\tif(!files[i].done){\r\n\t\t\t\tfiles[i].done=true;\r\n\t\t\t\treturn i;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn null;\r\n\t}\r\n\tfunction checkjoblist(){\r\n\t\tif(joblist.length==0)return;\r\n\t\tfor(var i = 0; i <= joblist.length-1; i++){\r\n\t\t\tif(!joblist[i].complete)return;\r\n\t\t}\r\n\t\tclearInterval(jobtimer);\r\n\t\tend();\r\n\t\tcomplete();\r\n\t}\r\n\t\r\n\tfunction get(jobidx){\r\n\t\tfunction _call(){\r\n\t\t\tvar a=joblist[jobidx];\r\n\t\t\ta.func(jobidx)\r\n\t\t}\r\n\t\tvar idx=getentryidx();\r\n\t\tif(idx==null || canceled){\r\n\t\t\tjoblist[jobidx].complete=true;\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif(files[idx].resp){\t\t\t\r\n\t\t\t_call();\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tfunction _progress(s){\r\n\t\t\tvar a=_getid(\"gd_progress\");\r\n\t\t\tif(a) a.innerHTML='('+(idx+1)+'/'+files.length+') '+henc(s);\r\n\t\t}\r\n\t\tvar folderlist;\r\n\t\tfunction getfolder(folderidx){\r\n\t\t\tif(folderidx>folderlist.length-1 || canceled){\r\n\t\t\t\t_call();\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\t_progress('Getting files in the folder... '+folderlist[folderidx].name);\r\n\t\t\tretrieveAllFiles(\"'\"+folderlist[folderidx].id+\"' in parents and trashed=false\", function(results){\r\n\t\t\t\tvar parent=folderlist[folderidx].parent || '';\r\n\t\t\t\tif(parent) parent+='/';\r\n\t\t\t\tparent+=folderlist[folderidx].name || '';\r\n\r\n\t\t\t\tfor(var i = 0; i <= results.length-1; i++){\r\n\t\t\t\t\tvar d={};\r\n\t\t\t\t\td.id=results[i].id;\r\n\t\t\t\t\td.name=results[i].title;\r\n\t\t\t\t\td.resp=results[i];\r\n\t\t\t\t\td.parent=parent;\r\n\t\t\t\t\td.done=true;\r\n\t\t\t\t\tfiles.push(d);\r\n\t\t\t\t\tif(d.resp.mimeType=='application/vnd.google-apps.folder'){\r\n\t\t\t\t\t\tfolderlist.push(d);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\t\t\r\n\t\t\t\tfolderidx++;\t\t\t\r\n\t\t\t\tgetfolder(folderidx);\r\n\t\t\t});\t\t\r\n\t\t}\r\n\r\n\t\tvar fileId=files[idx].id;\r\n\t\t_progress('Getting file info...');\r\n\r\n\t\t\tvar request = gapi.client.drive.files.get({\r\n\t\t\t\t'fileId': fileId\r\n\t\t\t});\r\n\t\t\trequest.execute(function(resp){\t\t\t\t\r\n\t\t\t\tif(resp.error){\r\n\t\t\t\t\tvar s='Error. ';\r\n\t\t\t\t\tif(files[idx].name) s+=files[idx].name+'  ';\r\n\t\t\t\t\tif(resp.error.message) s+=resp.error.message+' ';\r\n\t\t\t\t\tif(resp.error.code==401) s+='Login or Authorize Error.';\t\t\t\t\t\r\n\t\t\t\t\t_log(\"log4\",s,\"error\");\r\n\t\t\t\t}\r\n\t\t\t\tfiles[idx].resp=resp;\r\n\t\t\t\tif(!files[idx].name) files[idx].name=resp.title;\r\n\r\n\t\t\t\tif(files[idx].resp.mimeType=='application/vnd.google-apps.folder'){\r\n\t\t\t\t\tfolderlist=[];\r\n\t\t\t\t\tfolderlist.push(files[idx]);\r\n\t\t\t\t\tgetfolder(0);\r\n\t\t\t\t}else{\r\n\t\t\t\t\t_call();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t}\r\n\r\n\tif(files.length==0){\r\n\t\tend();return;\r\n\t}\r\n\tgapi.client.load('drive', 'v2', function(){\r\n\t\tjobtimer=setInterval(checkjoblist,200);\r\n\t\tfor(var i = 0; i < 2; i++){\r\n\t\t\tvar a={};\r\n\t\t\ta.func=get;\r\n\t\t\ta.complete=false;\r\n\t\t\tjoblist.push(a);\r\n\t\t\ta.func(i);\r\n\t\t}\r\n\t});\r\n}\r\n\r\nfunction retrieveAllFiles(query,callback) {\r\n  var retrievePageOfFiles = function(request, result) {\r\n    request.execute(function(resp) {\r\n      result = result.concat(resp.items);\r\n      var nextPageToken = resp.nextPageToken;\r\n      if (nextPageToken) {\r\n        request = gapi.client.drive.files.list({\r\n          'pageToken': nextPageToken,\r\n        });\r\n        retrievePageOfFiles(request, result);\r\n      } else {\r\n        callback(result);\r\n      }\r\n    });\r\n  }\r\n  var initialRequest = gapi.client.drive.files.list({\r\n\t\t'q': query\t\t\r\n       });\r\n  retrievePageOfFiles(initialRequest, []);\r\n}\r\n\r\nfunction attach_saveall(){\r\n\tif(!gd_issupported){\r\n\t\talert(\"This browser does not support.\");\r\n\t\treturn;\r\n\t}\r\n\tif(!gd_loaded || !gd_pickerloaded){\r\n\t\talert('Not loaded library. Please try again in a few minutes.');\r\n\t\treturn;\r\n\t}\r\n\tif(!Dropbox){\r\n\t\talert('Not loaded Dropbox library. Please try again in a few minutes.');\r\n\t\treturn;\r\n\t}\r\n\tif(Dropbox.isBrowserSupported && !Dropbox.isBrowserSupported()){\r\n\t\talert(\"Your browser does not support the Dropbox. Please upgrade your browser.\");\t\t\r\n\t\treturn;\r\n\t}\r\n\tattach_saveall2();\r\n}\r\n\r\nvar g_logcount=0;\r\nfunction _log(name,s,state,nohenc){\r\nfunction proc_log(s){\r\n\tvar obj=_getid(name);\r\n\t/*if(obj.style.display!='') obj.style.display='';\r\n\tif(g_logcount>200){\r\n\t\tg_logcount=0;\r\n\t\tobj.innerHTML='';\r\n\t}*/\r\n\tvar a=document.createElement(\"div\");\r\n\ta.setAttribute('style','display:block');\r\n\tif(!state) state='';\r\n\tif(!nohenc) s=henc(s);\r\n\ta.innerHTML='<font class=\"'+state+'\">'+s+'</font>';\r\n\tobj.appendChild(a);  \r\n\tobj.scrollTop=obj.scrollHeight;\r\n\tg_logcount++;\r\n}\r\n\tif(name=='log4' || name=='log5'){\r\n\t\tproc_log(s);\r\n\t\treturn;\r\n\t}\r\n\tvar a=_getid(name);\r\n\tvar s1=a.value;\r\n\tif(s1) s1+='\\n';\r\n\ta.value=s1+s;\r\n\ta.scrollTop=a.scrollHeight;\r\n}\r\n\r\nfunction getSupported(d){\r\n\tvar m=d.mimeType || '';\r\n\tif(m.indexOf('vnd.google-apps.document')>=0 || m.indexOf('vnd.google-apps.presentation')>=0 || m.indexOf('vnd.google-apps.drawing')>=0 || m.indexOf('vnd.google-apps.spreadsheet')>=0){ \r\n\t\treturn true;\r\n\t}\r\n}\r\nfunction getPrefered(m){\r\n\tvar a=document.optcontainer['o_prefer_'+m];\r\n\tif(a) return a.value || 'pdf';\r\n\telse return 'pdf';\r\n}\r\n\r\n/*var glogintime;\r\nfunction proc_logintime(){\r\n\tfunction go(){\r\n\t\tif(gd_isdownloading){\r\n\t\t\tsetTimeout(go, 1000*60);\r\n\t\t}else{\r\n\t\t\tsetTimeout(go, 1000*60*20);\r\n\t\t\tgd_login(function(result){\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\tsetTimeout(go, 1000*60*20);\r\n}*/\r\n\r\nvar gprogresstimer,gstarttime;\r\nfunction proc_complete(){\r\n\tclearInterval(gprogresstimer);\r\n\tgprogresstimer=null;\r\n\tgd_isdownloading=false;\r\n\t_getid('btn_ok').disabled=false;\r\n\t_getid(\"downlink2\").innerHTML='';\r\n}\r\n\r\nvar goptions = {\r\n    files: [],\r\n    success: function () {\r\n\t\tproc_complete();\r\n\t\t_log(\"log4\",'Success! All Files saved to your Dropbox. <a href=\"https://www.dropbox.com/home\" target=\"_blank\">Visit Dropbox Home</a>','uploaded',true);\t\t\r\n\r\n    },\r\n    progress: function (progress) {\r\n\t\tvar a=_getid(\"gd_progress2\");\r\n\t\tif(a){\r\n\t\t\tvar s='Saving to Dropbox... '+parseInt(progress*100)+ '%';\r\n\t\t\ta.innerHTML=s;\r\n\t\t}\r\n\t\tif(!gprogresstimer){\r\n\t\t\tgstarttime=(new Date()).getTime();\r\n\t\t\tgprogresstimer=setInterval(function(){\r\n\t\t\t\tvar a=_getid('spanprogress');\r\n\t\t\t\tif(a){\r\n\t\t\t\t\tvar s=(new Date()).getTime()-gstarttime;\r\n\t\t\t\t\ts=parseInt(s/1000);\r\n\t\t\t\t\tvar min=Math.floor(s/60);\r\n\t\t\t\t\tvar sec=parseInt(s % 60);\t\t\t\t\t\r\n\t\t\t\t\ta.innerHTML='('+fillnumber(min)+':'+fillnumber(sec)+')';\r\n\t\t\t\t}\r\n\t\t\t},1000);\r\n\t\t}\r\n\t},\r\n    cancel: function () {\r\n\t\tproc_complete();\r\n\t\t_log(\"log4\",'Canceled by user.','error');\r\n\t},\r\n    error: function (errorMessage) {\r\n\t\tproc_complete();\r\n\t\t_log(\"log4\",'Error: '+errorMessage,'error');\r\n\t}\r\n}\r\n\r\nvar glastlogintime=0;\r\nfunction attach_saveall2(){\r\n\tif(gd_isdownloading){\r\n\t\talert(\"It's working... Please try again in a few minutes.\");\r\n\t\treturn;\r\n\t}\r\n\r\n\tvar files=gd_files;\r\n\tif(files.length==0){\r\n\t\talert('No selected file.');\r\n\t\treturn;\r\n\t}\r\n\tvar now=(new Date()).getTime();\r\n\tif(glastlogintime==0 || now-glastlogintime>1000*60*15){\r\n\t\t_getid('log4').innerHTML='';\r\n\t\t_log(\"log4\",'Login checking... Please wait...','welcome');\r\n\t\tgd_login(function(result){\r\n\t\t\tif(result) _log(\"log4\",'Completed login checking. Please Click the \"Save\" button to try again.','uploaded');\r\n\t\t\telse _log(\"log4\",'Login failed!!','error');\r\n\t\t});\r\n\t\treturn;\r\n\t}\r\n\r\n\tvar access_token=gapi.auth.getToken().access_token;\r\n\tif(!access_token){\r\n\t\talert('Error!! No access token.');\r\n\t\treturn;\r\n\t}\r\n\r\n\t_getid('log4').innerHTML='';\r\n\t_log(\"log4\",'Started..','welcome');\r\n\r\n\tgoptions.files=[];\r\n\r\n\t\t\tfor(var i = 0; i <= files.length-1; i++){\r\n\t\t\t\tvar downloadurl=files[i].resp.downloadUrl;\r\n\t\t\t\tif(!downloadurl && files[i].resp.exportLinks){\r\n\t\t\t\t\tif(!getSupported(files[i].resp)){\r\n\t\t\t\t\t\t_log(\"log4\",'This format is not Supported. '+files[i].resp.title,'error');\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tvar m=files[i].resp.mimeType;\r\n\t\t\t\t\tvar ext,url,match;\r\n\t\t\t\t\tif(m.indexOf('vnd.google-apps.document')>=0) ext=getPrefered('doc');\r\n\t\t\t\t\telse if(m.indexOf('vnd.google-apps.spreadsheet')>=0) ext=getPrefered('spr');\r\n\t\t\t\t\telse if(m.indexOf('vnd.google-apps.presentation')>=0) ext=getPrefered('pre');\r\n\t\t\t\t\telse if(m.indexOf('vnd.google-apps.drawing')>=0) ext=getPrefered('dra');\r\n\t\t\t\t\text=(ext || '').toLowerCase();\r\n\t\t\t\t\tfor (x in files[i].resp.exportLinks){\r\n\t\t\t\t\t\turl=files[i].resp.exportLinks[x] || '';\r\n\t\t\t\t\t\tmatch=url.match(/(exportFormat=|format=)(.*?)(&|$)/i);\r\n\t\t\t\t\t\tif(ext && match && match[2] && match[2].toLowerCase()==ext){\r\n\t\t\t\t\t\t\tdownloadurl=url;\r\n\t\t\t\t\t\t\tfiles[i].resp.title2=files[i].resp.title+'.'+ext;\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tif(!downloadurl){\r\n\t\t\t\t\t_log(\"log4\",'Error. Can not find a Download URL. '+files[i].resp.title,'error');\r\n\t\t\t\t}\r\n\t\t\t\tvar a={};\r\n\t\t\t\ta.url=downloadurl+'&access_token='+encodeURIComponent(access_token);\r\n\t\t\t\ta.filename=files[i].resp.title2 || files[i].resp.title;\r\n\t\t\t\tgoptions.files.push(a);\r\n\t\t\t\tif(goptions.files.length>100){\r\n\t\t\t\t\tvar s='Error. You can specify up to 100 files.';\r\n\t\t\t\t\t_log(\"log4\",s,'error');\r\n\t\t\t\t\tproc_complete();\r\n\t\t\t\t\talert(s);\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\r\n\t_getid('btn_ok').disabled=true;\r\n\t_getid(\"downlink2\").innerHTML=\"<table><tr><td><img id='gd_wait' src='images/wait.gif' align='absmiddle'><td><div id='gd_progress2'></div><td>&nbsp;<span id='spanprogress'></span></table>\";\t\r\n\tgd_isdownloading=true;\r\n\tclearInterval(gprogresstimer);\r\n\tgprogresstimer=null;\r\n\tDropbox.save(goptions);\r\n}\r\n\r\nfunction attach_delete(){\r\n\tfunction remove(id){\r\n\t\tfor(var i = 0; i <= gd_files.length-1; i++){\r\n\t\t\tif(gd_files[i].id==id){\r\n\t\t\t\tgd_files.splice(i,1);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tvar a=_getid(\"attachment\");\r\n\tvar k=-1;\r\n\tfor(var i=a.options.length-1;i>=0;i--){\r\n\t\tif(a.options[i].selected){\r\n\t\t\tremove(a.options[i].value);\r\n\t\t\ta.remove(i);\r\n\t\t\tk=i;\r\n\t\t}\r\n\t}\r\n\tif (k>a.options.length-1) k=a.options.length-1;\r\n\tif (k>=0){\r\n\t\ta.selectedIndex=k;\r\n\t}\r\n\tgd_count();\t\t\r\n}\r\nfunction attach_clear(){\r\n\tvar a=_getid(\"attachment\");\r\n\tfor(var i=a.options.length-1;i>=0;i--) a.remove(i);\r\n\tgd_files=[];\r\n\tgd_count();\t\t\r\n}\r\nvar gexportlist=[];\r\nfunction attachment_onchange(f){\r\n\t_getid(\"spandown\").innerHTML='';\r\n\tfunction _down(resp){\r\n\t\t\tvar accessToken=gapi.auth.getToken().access_token;\r\n\t\t\tif(resp.downloadUrl){\r\n\t\t\t\t_getid(\"spandown\").innerHTML='<a id=\"adownlink\">Download this file</a>&nbsp; ('+getsize(resp.fileSize)+')';\r\n\t\t\t\tvar a=_getid(\"adownlink\");\r\n\t\t\t\tif(a){\r\n\t\t\t\t\ta.href=resp.downloadUrl+'&access_token='+encodeURIComponent(accessToken)\r\n\t\t\t\t\ta.download=resp.title;\r\n\t\t\t\t\ta.title=resp.title;\r\n\t\t\t\t}\r\n\t\t\t}else if(resp.exportLinks){\r\n\t\t\t\tgexportlist=[];\r\n\t\t\t\tfor (x in resp.exportLinks){\r\n\t\t\t\t\tvar a={};\r\n\t\t\t\t\ta.title=resp.title;\r\n\t\t\t\t\ta.name=x;\r\n\t\t\t\t\ta.url=resp.exportLinks[x] || '';\r\n\t\t\t\t\tvar match=a.url.match(/(exportFormat=|format=)(.*?)(&|$)/i);\r\n\t\t\t\t\tif(match) a.ext=match[2];\r\n\t\t\t\t\tgexportlist.push(a);\r\n\t\t\t\t}\r\n\t\t\t\tif(gexportlist.length==0) return;\r\n\t\t\t\t\t\t\tvar prefer=getstorage('c_prefer_ext');\r\n\t\t\t\t\t\t\ts='<select id=\"adownsel\" style=\"width:250px;margin-bottom:1px\">';\r\n\t\t\t\t\t\t\tfor(var i = 0; i < gexportlist.length; i++){\r\n\t\t\t\t\t\t\t\ts+='<option value=\"'+i+'\"';\r\n\t\t\t\t\t\t\t\tif(gexportlist[i].ext){\r\n\t\t\t\t\t\t\t\t\tif(gexportlist[i].ext==prefer) s+=' selected';\r\n\t\t\t\t\t\t\t\t\ts+='>(.'+gexportlist[i].ext+') ';\r\n\t\t\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\t\t\ts+='>';\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\ts+=gexportlist[i].name;\r\n\t\t\t\t\t\t\t}\t\t\r\n\t\t\t\t\t\t\ts+='</select>&nbsp; <a id=\"adownlink\" style=\"display:none\">Download this file</a>';\r\n\t\t\t\t\t\t\t_getid(\"spandown\").innerHTML=s;\r\n\t\t\t\t\t\t\tvar a=_getid(\"adownsel\");\r\n\t\t\t\t\t\t\tif(a){\r\n\t\t\t\t\t\t\t\ta.onchange=function(){\r\n\t\t\t\t\t\t\t\t\tif(!this.value)return;\r\n\t\t\t\t\t\t\t\t\tvar d=gexportlist[this.value];\r\n\t\t\t\t\t\t\t\t\tif(!d)return;\r\n\t\t\t\t\t\t\t\t\tsetstorage('c_prefer_ext',d.ext);\r\n\t\t\t\t\t\t\t\t\tvar a=_getid(\"adownlink\");\r\n\t\t\t\t\t\t\t\t\tif(a){\r\n\t\t\t\t\t\t\t\t\t\ta.href=d.url;\r\n\t\t\t\t\t\t\t\t\t\tvar s=d.title || '';\r\n\t\t\t\t\t\t\t\t\t\tif(d.ext) s+='.'+d.ext;\r\n\t\t\t\t\t\t\t\t\t\ta.download=s;\r\n\t\t\t\t\t\t\t\t\t\ta.title=s;\r\n\t\t\t\t\t\t\t\t\t\ta.style.display='';\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\ta.onchange();\r\n\t\t\t\t\t\t\t}\r\n\t\t\t}\r\n\t}\r\n\tfunction find(id){\r\n\t\tvar resp;\r\n\t\tfor(var i = 0; i <= gd_files.length-1; i++){\r\n\t\t\tif(gd_files[i].id==id){\r\n\t\t\t\tresp=gd_files[i].resp;\r\n\t\t\t\tvar s=resp.title;\r\n\t\t\t\tvar link=resp.alternateLink || resp.webContentLink;\r\n\t\t\t\tif(link) s='<a href=\"'+link+'\" target=\"_blank\" title=\"View this file\">'+henc(s)+'</a>';\r\n\t\t\t\ts+=' ('+getsize(resp.fileSize)+')';\r\n\t\t\t\tif(resp.parents && resp.parents[0] && resp.parents[0].id){\r\n\t\t\t\t\ts+=' &nbsp;<a href=\"'+gd_weburl()+'#folders/'+resp.parents[0].id+'\" target=\"_blank\" onclick=\"gd_clickweburl(this)\" title=\"Show Folder, Folder ID: '+resp.parents[0].id+'\">Folder</a>';\r\n\t\t\t\t}\r\n\t\t\t\t_getid(\"desc\").innerHTML=s;\r\n\t\t\t\t_down(resp);\t\t\t\t\t\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tvar a=_getid(\"attachment\");\r\n\tfor(var i=a.options.length-1;i>=0;i--){\r\n\t\tif(a.options[i].selected){\r\n\t\t\tfind(a.options[i].value);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunction gd_open_picker(){\r\n\tif(!gd_issupported){\r\n\t\talert(\"This browser does not support.\");\r\n\t\treturn;\r\n\t}\r\n\tif(!gd_loaded || !gd_pickerloaded){\r\n\t\tif(!gd_load_timer) gd_loadscript(gd_open_picker);\r\n\t\telse alert('Not loaded library. Please try again in a few minutes.');\r\n\t\treturn;\r\n\t}\r\n\tgd_login(function(result){\r\n\t\tif(!result) return;\r\n\t\tgd_createpicker();\r\n\t},true);\r\n}\r\nfunction gd_getparam(s,name){\r\n\tname=name+\"=\";\r\n\tname=name.toLowerCase();\r\n\tvar p1=s.toLowerCase().indexOf(name);\r\n\tif (p1<0) return \"\";\r\n\ts=s.substr(p1+name.length);\r\n\tvar p2=s.toLowerCase().indexOf(\"&\");\r\n\tif (p2>=0) {\r\n\t\treturn s.substr(0,p2);\r\n\t} else {\r\n\t\treturn s;\r\n\t}\r\n}\r\nfunction gd_open_state(){\r\n\tvar s=gd_state;\r\n\tif(s){\r\n\t\tif(!gd_issupported){\r\n\t\t\tgd_state='';\r\n\t\t\talert(\"This browser does not support.\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t\ts=decodeURIComponent(s);\r\n\t\ttry{\r\n\t\t\tvar a=JSON.parse(s);\r\n\t\t\tvar ids=[];\r\n\t\t\tfunction find(b){\r\n\t\t\t\tif(!b)return;\r\n\t\t\t\tfor(var i=0; i <= b.length-1; i++){\r\n\t\t\t\t\tif(b[i]){\r\n\t\t\t\t\t\tvar cc={};\r\n\t\t\t\t\t\tcc.id=b[i];\r\n\t\t\t\t\t\tids.push(cc);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tfind(a.ids);\r\n\t\t\tfind(a.exportIds);\r\n\t\t\tif(ids.length>0){\r\n\t\t\t\tgd_login(function(result){\r\n\t\t\t\t\tif(!result) return;\r\n\t\t\t\t\t_getid('gd_btn_reopen').style.display='';\r\n\t\t\t\t\tgd_state='';\r\n\t\t\t\t\tgd_loadfiles(ids);\r\n\t\t\t\t});\t\t\t\t\r\n\t\t\t}\r\n\t\t}catch(err){\r\n\t\t}\r\n\t}\r\n}\r\nfunction gd_clientload(){\r\n\tgd_loaded=true;\r\n\tif (window.addEventListener){\r\n\t\twindow.addEventListener(\"resize\", gd_btn_login2, false);\r\n\t}else if (window.attachEvent){\r\n\t\twindow.attachEvent(\"onresize\", gd_btn_login2);\r\n\t}\r\n\tgd_open_state();\r\n}\r\n\r\nfunction gd_loadscript(callback){\r\n\tfunction inject(s){\r\n\t\tvar o = document.createElement('scri' + 'pt');\r\n\t\to.setAttribute('src', s);\r\n\t\to.setAttribute('type', 'text/javascript');\r\n\t\tdocument.body.appendChild(o);\r\n\t}\r\n\tif(gd_load_timer)return;\r\n\tif(gd_loaded && gd_pickerloaded)return;\r\n\tgd_load_timer=setInterval(function(){\r\n\t\tif(gd_loaded && gd_pickerloaded){\r\n\t\t\tclearInterval(gd_load_timer);\r\n\t\t\tif(callback) callback();\r\n\t\t}\r\n\t},100);\r\n\tinject('https://apis.google.com/js/client.js?onload=gd_clientload');\r\n\tinject('https://apis.google.com/js/api.js?onload=gd_loadpicker');\t\r\n}\r\nfunction gd_reopen(){\r\n\tif(gd_state2){\r\n\t\tvar m=\"\";\r\n\t\tvar s='?';\r\n\t\tif(m) s+='m='+m+'&';\r\n\t\ts+='state='+encodeURIComponent(gd_state2);\r\n\t\tlocation.href=s;\r\n\t}\r\n}\r\nfunction gd_dblclick(){\r\n\tfunction dblclick(){\r\n\t\ttry{\r\n\t\t\tif(gd_picker)gd_picker.setVisible(false);\r\n\t\t}catch(err){}\r\n\t}\r\n\tfunction keydown(e){\r\n\t\tif(!e)e=window.event;\r\n\t\tif(e && e.keyCode==27) dblclick();\r\n\t}\r\n\tif(window.addEventListener){\r\n\t\tdocument.addEventListener(\"dblclick\", dblclick, false);\r\n\t\tdocument.addEventListener(\"keydown\", keydown, false);\r\n\t}else if(window.attachEvent){\r\n\t\tdocument.attachEvent(\"ondblclick\", dblclick);\r\n\t\tdocument.attachEvent(\"onkeydown\", keydown);\r\n\t}\r\n}\r\nvar gd_userId,gd_email;\r\nfunction gd_weburl(){\r\n\tvar s;\r\n\tif(gd_email) s='https://drive.google.com/?authuser='+encodeURIComponent(gd_email);\r\n\telse s='https://drive.google.com/';\r\n\treturn s;\r\n}\r\nfunction gd_clickweburl(f){\r\n\tvar s=f.href || '';\r\n\tvar p1=s.indexOf('#');\r\n\tif(p1<0) s='';\r\n\telse s=s.substr(p1,s.length);\r\n\tf.href=gd_weburl()+s;\r\n}\r\nfunction gd_info(){\r\n\tif(gd_email)return;\r\n\tgapi.client.load('drive', 'v2', function(){\r\n\t\tvar request = gapi.client.drive.about.get();\r\n\t\trequest.execute(function(resp) {\r\n\t\t\tif(resp && resp.user){\r\n\t\t\t\tif(gd_email)return;\r\n\t\t\t\tgd_email=resp.user.emailAddress;\r\n\t\t\t\tif(gd_email){\r\n\t\t\t\t\tvar a=_getid('btn_open');\r\n\t\t\t\t\tvar b=_getid('gd_btn_reopen');\r\n\t\t\t\t\tif(a)a.title=a.title+' ('+gd_email+')';\r\n\t\t\t\t\tif(b)b.title=b.title+' ('+gd_email+')';\r\n\t\t\t\t}\t\t\t\t\r\n\t\t\t}\r\n\t\t});\r\n\t});\r\n}\r\nfunction gd_init(){\r\n\tgd_dblclick();\r\n\tgd_state2=gd_state;\r\n\tif(!window.XMLHttpRequest){//!window.FileReader || !window.URL ||\r\n\t}else{\r\n\t\tgd_issupported=true;\r\n\t\tif(gd_state){\r\n\t\t\ttry{\r\n\t\t\t\tvar a=JSON.parse(gd_state);\r\n\t\t\t\tgd_userId=a.userId;\r\n\t\t\t\tif(a.ids || a.exportIds){\r\n\t\t\t\t\t_getid(\"downlink\").innerHTML=\"<table><tr><td><div id='gd_progress'>Ready...</div></table>\";\r\n\t\t\t\t}\r\n\t\t\t}catch(err){}\t\t\t\r\n\t\t}\r\n\t\tgd_loadscript();\r\n\t}\r\n}\r\ngd_init();\r\n</script>\r\n\r\n</body>\r\n</html>"}}