fork download
  1. /* release date : 2015-08-05 */
  2. (function(a) {
  3. var b = document.getElementsByTagName("script"),
  4. c = b[b.length - 1];
  5. c && /[\?&]jindo=([^&]+)/.test(c.src) && (a = RegExp.$1);
  6. var d = window[a];
  7. d.Timer = d.$Class({
  8. $init: function() {
  9. this._nTimer = null, this._nLatest = null, this._nRemained = 0, this._nDelay = null, this._fRun = null, this._bIsRunning = !1
  10. },
  11. start: function(a, b) {
  12. return this.abort(), this._nRemained = 0, this._nDelay = b, this._fRun = a, this._bIsRunning = !0, this._nLatest = this._getTime(), this.fireEvent("wait"), this._excute(this._nDelay, !1), !0
  13. },
  14. isRunning: function() {
  15. return this._bIsRunning
  16. },
  17. _getTime: function() {
  18. return (new Date).getTime()
  19. },
  20. _clearTimer: function() {
  21. var a = !1;
  22. return this._nTimer && (clearTimeout(this._nTimer), this._bIsRunning = !1, a = !0), this._nTimer = null, a
  23. },
  24. abort: function() {
  25. return this._clearTimer(), this._fRun ? (this.fireEvent("abort"), this._fRun = null, !0) : !1
  26. },
  27. pause: function() {
  28. var a = this._getTime() - this._nLatest;
  29. return this._nRemained = Math.max(this._nDelay - a, 0), this._clearTimer()
  30. },
  31. _excute: function(a, b) {
  32. var c = this;
  33. this._clearTimer(), this._bIsRunning = !0;
  34. var d = function(a) {
  35. if (!c._fRun) return;
  36. if (c._nTimer || a) {
  37. c.fireEvent("run");
  38. var b = c._fRun();
  39. c._nLatest = c._getTime();
  40. if (!b) {
  41. a || clearTimeout(c._nTimer), c._nTimer = null, c._bIsRunning = !1, c.fireEvent("end");
  42. return
  43. }
  44. c.fireEvent("wait"), c._excute(c._nDelay, !1)
  45. }
  46. };
  47. a > -1 ? this._nTimer = setTimeout(d, a) : d(!0)
  48. },
  49. resume: function() {
  50. return !this._fRun || this.isRunning() ? !1 : (this._bIsRunning = !0, this.fireEvent("wait"), this._excute(this._nRemained, !0), this._nRemained = 0, !0)
  51. }
  52. }).extend(d.Component), d.LayerManager = d.$Class({
  53. _bIsActivating: !1,
  54. _bIsHiding: !1,
  55. _bIsShowing: !1,
  56. _aLink: null,
  57. $init: function(a, b) {
  58. this.option({
  59. sCheckEvent: "click",
  60. nCheckDelay: 100,
  61. nShowDelay: 0,
  62. nHideDelay: 100
  63. }), this.option(b || {}), this.setLayer(a), this._aLink = [], this._oShowTimer = new d.Timer, this._oHideTimer = new d.Timer, this._oEventTimer = new d.Timer, this._wfOnEvent = d.$Fn(this._onEvent, this), this.getVisible(), this.activate()
  64. },
  65. _onActivate: function() {
  66. this._wfOnEvent.attach(document, this.option("sCheckEvent"))
  67. },
  68. _onDeactivate: function() {
  69. this._wfOnEvent.detach(document, this.option("sCheckEvent"))
  70. },
  71. getVisible: function() {
  72. return this._wel.visible()
  73. },
  74. _check: function(a) {
  75. var b = d.$Element(a);
  76. for (var c = 0, e, f; e = this._aLink[c]; c++) {
  77. f = d.$Element(e);
  78. if (f) {
  79. e = f.$value();
  80. if (e && (a == e || b.isChildOf(e))) return !0
  81. }
  82. }
  83. return !1
  84. },
  85. _find: function(a) {
  86. for (var b = 0, c; c = this._aLink[b]; b++)
  87. if (c == a) return b;
  88. return -1
  89. },
  90. getLayer: function() {
  91. return this._el
  92. },
  93. setLayer: function(a) {
  94. return this._el = d.$(a), this._wel = d.$Element(a), this
  95. },
  96. getLinks: function() {
  97. return this._aLink
  98. },
  99. setLinks: function(a) {
  100. return this._aLink = d.$A(a).unique().$value(), this
  101. },
  102. link: function(a) {
  103. if (arguments.length > 1) {
  104. for (var b = 0, c = arguments.length; b < c; b++) this.link(arguments[b]);
  105. return this
  106. }
  107. return this._find(a) != -1 ? this : (this._aLink.push(a), this)
  108. },
  109. unlink: function(a) {
  110. if (arguments.length > 1) {
  111. for (var b = 0, c = arguments.length; b < c; b++) this.unlink(arguments[b]);
  112. return this
  113. }
  114. var d = this._find(a);
  115. return d > -1 && this._aLink.splice(d, 1), this
  116. },
  117. _fireEventBeforeShow: function() {
  118. return this.fireEvent("beforeShow", {
  119. elLayer: this.getLayer(),
  120. aLinkedElement: this.getLinks()
  121. })
  122. },
  123. _fireEventShow: function() {
  124. this._bIsShowing = !1, this.fireEvent("show", {
  125. elLayer: this.getLayer(),
  126. aLinkedElement: this.getLinks()
  127. })
  128. },
  129. _fireEventBeforeHide: function() {
  130. var a = this.fireEvent("beforeHide", {
  131. elLayer: this.getLayer(),
  132. aLinkedElement: this.getLinks()
  133. });
  134. return a || (this._bIsHiding = !1), a
  135. },
  136. _fireEventHide: function() {
  137. this._bIsHiding = !1, this.fireEvent("hide", {
  138. elLayer: this.getLayer(),
  139. aLinkedElement: this.getLinks()
  140. })
  141. },
  142. _show: function(a, b) {
  143. var c = this;
  144. this._oEventTimer.abort(), this._bIsShowing = !0, this._bIsHiding = !1, b <= 0 && c._oHideTimer.abort(), this._oShowTimer.start(function() {
  145. a()
  146. }, b)
  147. },
  148. _hide: function(a, b) {
  149. var c = this;
  150. this._bIsShowing = !1, this._bIsHiding = !0, b <= 0 && c._oShowTimer.abort(), this._oHideTimer.start(function() {
  151. a()
  152. }, b)
  153. },
  154. show: function(a) {
  155. typeof a == "undefined" && (a = this.option("nShowDelay"));
  156. var b = this;
  157. return this._show(function() {
  158. b.getVisible() || b._fireEventBeforeShow() && (b._wel.show(), b._fireEventShow())
  159. }, a), this
  160. },
  161. hide: function(a) {
  162. typeof a == "undefined" && (a = this.option("nHideDelay"));
  163. var b = this;
  164. return this._hide(function() {
  165. b.getVisible() && b._fireEventBeforeHide() && (b._wel.hide(), b._fireEventHide())
  166. }, a), this
  167. },
  168. toggle: function(a) {
  169. return !this.getVisible() || this._bIsHiding ? this.show(a || this.option("nShowDelay")) : this.hide(a || this.option("nHideDelay")), this
  170. },
  171. _onEvent: function(a) {
  172. var b = a.element,
  173. c = this;
  174. this._oEventTimer.start(function() {
  175. !c._bIsHiding && c.getVisible() && (c._check(b) ? c._bIsShowing || (c.fireEvent("ignore", {
  176. sCheckEvent: c.option("sCheckEvent")
  177. }), c._oHideTimer.abort(), c._bIsHiding = !1) : typeof b.tagName != "undefined" && c.hide())
  178. }, this.option("nCheckDelay"))
  179. }
  180. }).extend(d.UIComponent)
  181. })("jindo"), typeof nhn == "undefined" && (nhn = {}), nhn.search = nhn.search || {}, nhn.search.spellingCheck = nhn.search.spellingcheck || {}, nhn.search.spellingCheck.SpellingCheck = jindo.$Class({
  182. $init: function(a) {
  183. a && this.initalize(a)
  184. },
  185. initalize: function(a) {
  186. this.option({
  187. containerID: "_content",
  188. selecter: {
  189. original: "div.check_area > textarea",
  190. result: "div.check_area > p",
  191. btnCheck: "div.check_area > div.btn_section > a.check",
  192. btnReset: "div.check_area > div.btn_section > a.delete",
  193. cntOriginal: "div.txt_area > span.txt_info > em",
  194. btnShare: "div.txt_area > input:nth-child(2)",
  195. layerShare: "spi_layer_spellingcheck"
  196. }
  197. }), this.option(a || {}), this._assignElement(), this._configure(), this._attachEvent()
  198. },
  199. _assignElement: function() {
  200. var a = this.option("selecter");
  201. this._elCtn = jindo.$(this.option("containerID")), this._htElement = {}, this._htElement.original = jindo.$$.getSingle(a.original, this._elCtn), this._htElement.wResult = jindo.$Element(jindo.$$.getSingle(a.result, this._elCtn)), this._htElement.btnCheck = jindo.$$.getSingle(a.btnCheck, this._elCtn), this._htElement.btnReset = jindo.$$.getSingle(a.btnReset, this._elCtn), this._htElement.wCntOriginal = jindo.$Element(jindo.$$.getSingle(a.cntOriginal, this._elCtn)), this._htElement.btnShare = jindo.$$.getSingle(a.btnShare, this._elCtn)
  202. },
  203. _configure: function() {
  204. var a = this.option("selecter");
  205. this._msg = {
  206. placeholder: "맞춤법 검사를 원하는 단어나 문장을 직접 입력 또는 붙여 넣기 해주세요.",
  207. ready: "<span class='check_none2'>맞춤법 검사가 실행중입니다. 잠시만 기다려주세요</span>",
  208. same: "<span class='check_none'>※ 교정된 내용이 없습니다.</span>",
  209. timeout: "<span class='check_none2'>검사를 수행할 수 없습니다. 입력하신 문장의 길이를 줄이거나, 단어와 단어 사이에 스페이스를 추가하여 다시 시도해주세요.</span>",
  210. fail: "<span class='check_none2'>검사를 수행할 수 없습니다. 입력하신 문장의 길이를 줄이거나, 단어와 단어 사이에 스페이스를 추가하여 다시 시도해주세요.</span>"
  211. }, this._sOriginal = "", this._sResult = "", this._nMaxlength = 500, jindo.$Element(this._htElement.original).addClass("txt_gray")
  212. },
  213. _attachEvent: function() {
  214. var a = jindo.$Fn(this._onInputOriginalHandler, this);
  215. a.attach(this._htElement.original, "keydown");
  216. var b = jindo.$Fn(this._onInputOriginalHandler, this);
  217. b.attach(this._htElement.original, "input");
  218. var c = jindo.$Fn(this._onFocusOriginalHandler, this);
  219. c.attach(this._htElement.original, "focus");
  220. var d = jindo.$Fn(this._onFocusOriginalHandler, this);
  221. d.attach(this._htElement.original, "blur");
  222. var e = jindo.$Fn(this._onClickBtnCheckHandler, this);
  223. e.attach(this._htElement.btnCheck, "click");
  224. var f = jindo.$Fn(this._onClickBtnResetHandler, this);
  225. f.attach(this._htElement.btnReset, "click")
  226. },
  227. _onFocusOriginalHandler: function(a) {
  228. var b = jindo.$Element(this._htElement.original);
  229. a.type == "focus" ? b.text() == this._msg.placeholder && (b.text(""), b.removeClass("txt_gray")) : a.type == "blur" && b.text() == "" && (b.text(this._msg.placeholder), this._countInput(), b.addClass("txt_gray"))
  230. },
  231. _onInputOriginalHandler: function(a) {
  232. this._countInput()
  233. },
  234. _onClickBtnCheckHandler: function(a) {
  235. this._countInput();
  236. var b = jindo.$Element(this._htElement.btnCheck);
  237. if (!b.hasClass("dimd")) {
  238. var c = jindo.$Element(this._htElement.original),
  239. d = c.text();
  240. if (d != this._msg.placeholder)
  241. if (d == "") c.text(this._msg.placeholder);
  242. else {
  243. this._htElement.wResult.html(this._msg.ready), this._sOriginal = d, this._sResult = "";
  244. var e = {
  245. q: this._sOriginal
  246. };
  247. this._requestData(this.option("API").checker, e, this._onLoadResult, this._onTimeOut), b.addClass("dimd")
  248. }
  249. }
  250. },
  251. _onClickBtnResetHandler: function(a) {
  252. var b = jindo.$Element(this._htElement.original),
  253. c = jindo.$Element(this._htElement.btnCheck);
  254. b.text(this._msg.placeholder), this._countInput(), this._htElement.wResult.text(""), b.addClass("txt_gray"), c.hasClass("dimd") && c.removeClass("dimd")
  255. },
  256. _countInput: function() {
  257. var a = jindo.$Element(this._htElement.original),
  258. b = a.text(),
  259. c = b == this._msg.placeholder ? 0 : b.length;
  260. c > this._nMaxlength && (a.text(b.substring(0, this._nMaxlength)), c = this._nMaxlength), this._htElement.wCntOriginal.text(c)
  261. },
  262. _requestData: function(a, b, c, d) {
  263. jindo.$Ajax(a, {
  264. type: "jsonp",
  265. method: "get",
  266. callbackid: "spellingCheck",
  267. timeout: 3,
  268. onload: jindo.$Fn(c, this).bind(),
  269. ontimeout: jindo.$Fn(d, this).bind()
  270. }).request(b)
  271. },
  272. _onLoadResult: function(a) {
  273. var b, c = a.json();
  274. jindo.$Element(this._htElement.btnCheck).removeClass("dimd");
  275. try {
  276. b = c.message.result.html, b == "" ? b = this._msg.fail : c.message.result.errata_count === 0 && (b += this._msg.same)
  277. } catch (d) {
  278. b = this._msg.fail
  279. }
  280. this._htElement.wResult.html(b)
  281. },
  282. _onTimeOut: function() {
  283. jindo.$Element(this._htElement.btnCheck).removeClass("dimd"), this._htElement.wResult.html(this._msg.timeout)
  284. }
  285. }).extend(jindo.Component)
Runtime error #stdin #stdout #stderr 0.02s 30320KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog.js:3:0 ReferenceError: document is not defined