fe-const.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. /**
  2. * 常量定义
  3. * @author zhaoxianlie
  4. */
  5. /**
  6. * 各个模块进行信息交互时的消息类型
  7. */
  8. const MSG_TYPE = {
  9. //browserAction被点击
  10. BROWSER_CLICKED : "browser-clicked",
  11. //提取CSS
  12. GET_CSS : "get-css",
  13. //提取JS
  14. GET_JS : "get-js",
  15. //提取HTML
  16. GET_HTML : "get-html",
  17. //cookie
  18. GET_COOKIE : 'get-cookie',
  19. //remvoe cookie
  20. REMOVE_COOKIE : 'remove-cookie',
  21. //set cookie
  22. SET_COOKIE : 'set-cookie',
  23. //get options
  24. GET_OPTIONS : 'get_options',
  25. //set options
  26. SET_OPTIONS : 'set_options',
  27. //css ready...
  28. CSS_READY : 'css-ready',
  29. //js ready...
  30. JS_READY : 'js-ready',
  31. //html ready...
  32. HTML_READY : 'html-ready',
  33. //启动项
  34. START_OPTION : 'start-option',
  35. //启动FCPHelper
  36. OPT_START_FCP : 'opt-item-fcp',
  37. //启动栅格检测
  38. OPT_START_GRID : 'opt-item-grid',
  39. //计算网页加载时间
  40. CALC_PAGE_LOAD_TIME : "calc-page-load-time",
  41. //页面相关性能数据
  42. GET_PAGE_WPO_INFO : 'get_page_wpo_info',
  43. //查看加载时间
  44. SHOW_PAGE_LOAD_TIME : "show-page-load-time",
  45. //执行FCP Helper检测
  46. FCP_HELPER_DETECT : 'fcp-helper-detect',
  47. //执行栅格检测
  48. GRID_DETECT : 'grid-detect',
  49. //执行JS嗅探:Tracker,from 志龙(http://ucren.com)
  50. JS_TRACKER : 'js_tracker',
  51. ////////////////////如下是popup中的menu,value和filename相同///////////////////
  52. //进行FDP平台文件检索
  53. FDP_HELPER : 'fdp',
  54. //字符串编解码
  55. EN_DECODE : 'endecode',
  56. //json查看器
  57. JSON_FORMAT : 'jsonformat',
  58. //QR生成器
  59. QR_CODE : 'qrcode',
  60. //代码美化
  61. CODE_BEAUTIFY : 'codebeautify',
  62. // 时间转换
  63. TIME_STAMP : 'timestamp',
  64. //页面json代码自动格式化
  65. AUTO_FORMART_PAGE_JSON : "opt_item_autojson"
  66. };
  67. /**
  68. * 文件类型
  69. */
  70. const FILE = {
  71. //css的<style>标签
  72. STYLE : "style",
  73. //css的<link>标签
  74. LINK : "link",
  75. //js:通过script定义的内联js
  76. SCRIPT : "script-block"
  77. };
  78. //首先配一个DTD中的白名单
  79. const PUBLIC_ID_WHITE_LIST = {
  80. '': {
  81. systemIds: {
  82. '': true
  83. }
  84. },
  85. '-//W3C//DTD HTML 3.2 Final//EN': {
  86. systemIds: {
  87. '': true
  88. }
  89. },
  90. '-//W3C//DTD HTML 4.0//EN': {
  91. systemIds: {
  92. '': true,
  93. 'http://www.w3.org/TR/html4/strict.dtd': true
  94. }
  95. },
  96. '-//W3C//DTD HTML 4.01//EN': {
  97. systemIds: {
  98. '': true,
  99. 'http://www.w3.org/TR/html4/strict.dtd': true
  100. }
  101. },
  102. '-//W3C//DTD HTML 4.0 Transitional//EN': {
  103. systemIds: {
  104. '': true,
  105. 'http://www.w3.org/TR/html4/loose.dtd': true
  106. }
  107. },
  108. '-//W3C//DTD HTML 4.01 Transitional//EN': {
  109. systemIds: {
  110. '': true,
  111. 'http://www.w3.org/TR/html4/loose.dtd': true,
  112. 'http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd': true
  113. }
  114. },
  115. '-//W3C//DTD XHTML 1.1//EN': {
  116. systemIds: {
  117. 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd': true
  118. }
  119. },
  120. '-//W3C//DTD XHTML Basic 1.0//EN': {
  121. systemIds: {
  122. 'http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd': true
  123. }
  124. },
  125. '-//W3C//DTD XHTML 1.0 Strict//EN': {
  126. systemIds: {
  127. 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd': true
  128. }
  129. },
  130. '-//W3C//DTD XHTML 1.0 Transitional//EN': {
  131. systemIds: {
  132. 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd': true
  133. }
  134. },
  135. 'ISO/IEC 15445:1999//DTD HyperText Markup Language//EN': {
  136. systemIds: {
  137. '': true
  138. }
  139. },
  140. 'ISO/IEC 15445:2000//DTD HTML//EN': {
  141. systemIds: {
  142. '': true
  143. }
  144. },
  145. 'ISO/IEC 15445:1999//DTD HTML//EN': {
  146. systemIds: {
  147. '': true
  148. }
  149. }
  150. };
  151. /**
  152. * IE和Webkit对Doctype的解析差异
  153. */
  154. const COMPAT_MODE_DIFF_PUBLIC_ID_MAP = {
  155. '-//W3C//DTD HTML 4.0 Transitional//EN': {
  156. systemIds: {
  157. 'http://www.w3.org/TR/html4/loose.dtd': {
  158. IE: 'S',
  159. WebKit: 'Q'
  160. }
  161. }
  162. },
  163. 'ISO/IEC 15445:2000//DTD HTML//EN': {
  164. systemIds: {
  165. '': {
  166. IE: 'Q',
  167. WebKit: 'S'
  168. }
  169. }
  170. },
  171. 'ISO/IEC 15445:1999//DTD HTML//EN': {
  172. systemIds: {
  173. '': {
  174. IE: 'Q',
  175. WebKit: 'S'
  176. }
  177. }
  178. }
  179. };
  180. /**
  181. * 过时的HTML标签,HTML5已经不再支持
  182. */
  183. const HTML_DEPRECATED_TAGS = {
  184. acronym: "定义首字母缩写",
  185. applet: "定义Java Applet",
  186. basefont: "定义Font定义",
  187. big: "定义大号文本",
  188. center: "定义居中的文本",
  189. dir: "定义目录列表",
  190. font: "定义文字相关",
  191. frame: "定义框架",
  192. frameset: "定义框架集",
  193. isindex: "定义单行的输入域",
  194. noframes: "定义noframe 部分",
  195. s: "定义加删除线的文本",
  196. strike: "定义加删除线的文本",
  197. tt: "定义打字机文本",
  198. u: "定义下划线文本",
  199. xmp: "定义预格式文本",
  200. layer: "定义层"
  201. }
  202. /**
  203. * 过时的HTML属性,HTML5已经不再支持
  204. */
  205. const HTML_DEPRECATED_ATTRIBUTES = {
  206. align: {
  207. iframe: true,
  208. img: true,
  209. object: true,
  210. table: true
  211. },
  212. color: {
  213. font: true
  214. },
  215. height: {
  216. td: true,
  217. th: true
  218. },
  219. language: {
  220. script: true
  221. },
  222. noshade: {
  223. hr: true
  224. },
  225. nowrap: {
  226. td: true,
  227. th: true
  228. },
  229. size: {
  230. hr: true,
  231. font: true,
  232. basefont: true
  233. }
  234. };
  235. /**
  236. * 块级元素
  237. */
  238. const BLOCK_HTML_ELEMENT = [
  239. 'address','blockquote','center','dir',
  240. 'div','dl','fieldset','form','h1','h2',
  241. 'h3','h4','h5','h6','hr','isindex','menu',
  242. 'noframes','noscript','ol','p','pre','table','ul'
  243. ];
  244. /**
  245. * 内联元素
  246. */
  247. const INLINE_HTML_ELEMENT = [
  248. 'a','acronym','b','bdo','big','br','cite','code',
  249. 'dfn','em','font','i','img','input','kbd','label',
  250. 'q','s','samp','select','small','span','strike','strong',
  251. 'sub','sup','textarea','tt','u','var'
  252. ];
  253. /**
  254. * 可变元素:为根据上下文语境决定该元素为块元素或者内联元素。
  255. */
  256. const CHANGE_ABLE_HTML_ELEMENT = [
  257. 'applet','button','del','iframe',
  258. 'ins','map','object','script'
  259. ];
  260. //关于IE的条件注释,可以参考这里:http://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx
  261. //条件注释的正则匹配规则
  262. const CONDITIONAL_COMMENT_REGEXP = /\[\s*if\s+[^\]][\s\w]*\]/i;
  263. // 非IE条件注释开始:<![if !IE]> or <![if false]>
  264. const NOT_IE_REVEALED_OPENING_CONDITIONAL_COMMENT_REGEXP = /^\[if\s+(!IE|false)\]$/i;
  265. // IE条件注释结束:<![endif]>
  266. const REVEALED_CLOSING_CONDITIONAL_COMMENT_REGEXP = /^\[endif\s*\]$/i;
  267. // 非IE的条件注释整体: <!--[if !IE]> HTML <![endif]--> or <!--[if false]> HTML <![endif]-->
  268. const NOT_IE_HIDDEN_CONDITIONAL_COMMENT_REGEXP = /^\[if\s+(!IE|false)\]>.*<!\[endif\]$/i;
  269. /* 正则 */
  270. const REG = {
  271. //script标签
  272. SCRIPT: /<script[^>]*>[\s\S]*?<\/[^>]*script>/gi,
  273. //注释
  274. COMMENT: /<!--[\s\S]*?--\>/g,
  275. //cssExpression
  276. CSS_EXPRESSION: /expression[\s\r\n ]?\(/gi,
  277. //textarea
  278. TEXTAREA:/<textarea[^>]*>[\s\S]*?<\/[^>]*textarea>/gi,
  279. //不合法的标签
  280. INVALID_TAG:/<\W+>/gi
  281. };
  282. /**
  283. * 能够自动闭合的标签,就算不闭合也不影响兄弟节点的布局
  284. */
  285. const SELF_CLOSING_TAGS = [
  286. 'meta','link','area','base',
  287. 'col','input','img','br',
  288. 'hr','param','embed'
  289. ];
  290. /**
  291. * 限定HTML嵌套的最大深度为30
  292. * @type Number
  293. */
  294. const HTML_DOM_MAX_DEPTH = 30;
  295. /**
  296. * 统计项
  297. */
  298. const LOG = {
  299. //选项页面:【打开】
  300. options_page_opened : "m_20111124_options_page_opened",
  301. //选项页面:【保存】
  302. options_page_btnsave : "m_20111124_options_page_btnsave",
  303. //选项页面:【关闭】
  304. options_page_btnclose : "m_20111124_options_page_btnclose",
  305. //popup页面:【显示】
  306. popup_page_show : "m_20111124_popup_page_show",
  307. //popup页面:【编码规范检测】
  308. popup_page_fcp : "m_20111124_popup_page_fcp",
  309. //popup页面:【栅格规范检测】
  310. popup_page_grid : "m_20111124_popup_page_grid",
  311. //popup页面:【FE文档检索】
  312. popup_page_fdp : "m_20111124_popup_page_fdp",
  313. //popup页面:【字符串编解码】
  314. popup_page_endecode : "m_20111124_popup_page_endecode",
  315. //popup页面:【网页加载耗时】
  316. popup_page_loadtime : "m_20111124_popup_page_loadtime",
  317. //编解码工具:【打开】
  318. endecode_page_opened : "m_20111124_endecode_page_opened",
  319. //编解码工具:【Unicode编码】
  320. endecode_page_uniEncode : "m_20111124_endecode_page_uniEncode",
  321. //编解码工具:【Unicode解码】
  322. endecode_page_uniDecode : "m_20111124_endecode_page_uniDecode",
  323. //编解码工具:【UTF-8编码】
  324. endecode_page_utf8Encode : "m_20111124_endecode_page_utf8Encode",
  325. //编解码工具:【UTF-8解码】
  326. endecode_page_utf8Decode : "m_20111124_endecode_page_utf8Decode",
  327. //编解码工具:【Base64编码】
  328. endecode_page_base64Encode : "m_20111124_endecode_page_base64Encode",
  329. //编解码工具:【base64解码】
  330. endecode_page_base64Decode : "m_20111124_endecode_page_base64Decode",
  331. //编解码工具:【转换】
  332. endecode_page_btnchange : "m_20111124_endecode_page_btnchange",
  333. //编解码工具:【清空】
  334. endecode_page_btnclear : "m_20111124_endecode_page_btnclear",
  335. //文档检索:【打开】
  336. fdp_page_opened : "m_20111124_fdp_page_opened",
  337. //文档检索:【空间FE文档】
  338. fdp_page_spacedoc : "m_20111124_fdp_page_spacedoc",
  339. //文档检索:【大FE文档】
  340. fdp_page_fedoc : "m_20111124_fdp_page_fedoc",
  341. //文档检索:【检索】
  342. fdp_page_btnsearch : "m_20111124_fdp_page_btnsearch",
  343. //编码规范检测:【显示层】
  344. fcp_detect_show : "m_20111124_fcp_detect_show",
  345. //编码规范检测:【关闭检测结果】
  346. fcp_detect_close : "m_20111124_fcp_detect_close",
  347. //编码规范检测:【最小化检测结果】
  348. fcp_detect_min : "m_20111124_fcp_detect_min",
  349. //编码规范检测:【最大化检测结果】
  350. fcp_detect_max : "m_20111124_fcp_detect_max",
  351. //编码规范检测:【更多HTML规范】
  352. fcp_detect_morehtml : "m_20111124_fcp_detect_morehtml",
  353. //编码规范检测:【更多css规范】
  354. fcp_detect_morecss : "m_20111124_fcp_detect_morecss",
  355. //编码规范检测:【更多js规范】
  356. fcp_detect_morejs : "m_20111124_fcp_detect_morejs",
  357. //栅格检测:【显示层】
  358. grid_detect_show : "m_20111124_grid_detect_show",
  359. //栅格检测:【ESC】
  360. grid_detect_esc : "m_20111124_grid_detect_esc",
  361. //栅格检测:【关闭栅格】
  362. grid_detect_btnclose : "m_20111124_grid_detect_btnclose",
  363. //每天使用人数【粗略统计】
  364. fehelper_user_count : "m_20111124_fehelper_user_count"
  365. };