var host = window.location.host; var YCanPDF = null; var newestVersion = "3.5.5.3"; if (!window.JSON) { var JSON = { parse: function (s) { return eval('(' + s + ')') }, stringify: function (o) { function stringifyValue(v) { var result = '' switch (typeof v) { case 'string': result = '"' + v + '"' break case 'boolean': result = v ? 'true' : 'false' break case 'number': result = '' + v break case 'object': if (v instanceof String) { result = '"' + v + '"' } else if (v instanceof Boolean) { result = v ? 'true' : 'false' } else if (v instanceof Number) { result = '' + v } else { result = JSON.stringify(v) } break case 'undefined': result = 'undefined' break default: break } return result } var result = '' switch (typeof o) { case 'undefined': break case 'object': if (Array.isArray(o)) { result += '[' var count = o.length for (var i = 0; i < count; ++i) { result += stringifyValue(o[i]) + ', ' } result = result.substr(0, result.length - 2) result += ']' } else { result += '{' for (var prop in o) { result += '"' + prop + '": ' + stringifyValue(o[prop]) + ', ' } result = result.substr(0, result.length - 2) result += '}' } break case 'boolean': break case 'number': break case 'string': break case 'function': break default: break } return result } } } function checkVersion(CurVersion) { var result = false; var newV = newestVersion.split('.'); var curV = CurVersion.split('.'); if (parseInt(newV[0]) > parseInt(curV[0])) { result = true; } if (parseInt(newV[0]) == parseInt(curV[0]) && parseInt(newV[1]) > parseInt(curV[1])) { result = true; } if (parseInt(newV[0]) == parseInt(curV[0]) && parseInt(newV[1]) == parseInt(curV[1]) && parseInt(newV[2]) > parseInt(curV[2])) { result = true; } if (parseInt(newV[0]) == parseInt(curV[0]) && parseInt(newV[1]) == parseInt(curV[1]) && parseInt(newV[2]) == parseInt(curV[2]) && parseInt(newV[3]) > parseInt(curV[3])) { result = true; } return result } function prepareController() { var tips = ''; if (window.ActiveXObject || 'ActiveXObject' in window) { try { var Eobj = new ActiveXObject('PDFVIEWYC.PDFViewCtrl.1'); } catch (e) { tips = '您尚未安装PDF控件,点这里进行安装...'; } YCanPDF = document.getElementById('YCanPDFIE'); } else { //非IE var plugin = navigator.plugins['npPDFViewyc dll']; if (plugin == undefined) { isInstalled = false; alert('插件未注册!'); tips = '您尚未安装PDF控件,点这里进行安装...'; } else { YCanPDF = document.getElementById('YCanPDFNOTIE'); } } if (tips == '') { var CurVer = YCanPDF.GetVersion(); if (checkVersion(CurVer)) { alert('控件有更新,请下载更新'); tips = '点这里进行更新安装...'; } } if (tips != '') { document.getElementById('controlContainer').innerHTML = '' + tips + ''; } } function f_OnCompleteDrawNote(StrInfoLen, StrInfo) { selectionRegionComplete(StrInfoLen, StrInfo); } function f_OnNoteDelete(StrInfoLen, StrInfo) { removeRegion(StrInfoLen, StrInfo); } function f_OnPageChanged(CurPage, MaxPage) { changedPage(CurPage, MaxPage); } function OpenURL(link) { var n = YCanPDF.SetURL(link, ""); } function CommentsTools(type) { YCanPDF.CommentsTool(type); } function doKeyEvent(event) { var event = event ? event : (window.event ? window.event : null); var eventCode = event.keyCode; if(eventCode==39) { nextPage(1); } else if(eventCode==37) { nextPage(-1); } } function getNoteRegionsSingle(CommentIndex) { var CommentInfo = YCanPDF.getNoteRegions(CommentIndex,""); return CommentInfo; } function f_OnVScrollPagePos(StrInfoLen, StrInfo) { scrollPlugin(StrInfo); } function scrollPlugin(strInfo) { if(strInfo=="Bootom"){ var l = document.documentElement.scrollLeft || document.body.scrollLeft; var t = document.documentElement.scrollTop || document.body.scrollTop; window.scrollTo(l,t+20); } else if(strInfo=="Top"){ var l = document.documentElement.scrollLeft || document.body.scrollLeft; var t = document.documentElement.scrollTop || document.body.scrollTop; window.scrollTo(l,t-20); } }