我的LT阅读器一键高亮补丁

自己看书使用

  1. // ==UserScript==
  2. // @name 我的LT阅读器一键高亮补丁
  3. // @namespace https://www.ellibrototal.com/
  4. // @version 2025-03-16.6.final
  5. // @license MIT
  6. // @description 自己看书使用
  7. // @author You
  8. // @match https://www.ellibrototal.com/ltotal/*
  9. // @icon none
  10. // @grant GM_addStyle
  11. // @grant GM_setValue
  12. // @grant GM_getValue
  13. // ==/UserScript==
  14. ;(function () {
  15. "strict mode"
  16. //////// 更新日志
  17. //
  18. // 2025-03-15【从03-16回滚】
  19. // 实现:笔记查询界面 点击 contentHtmlDiv 后,自动关闭窗口
  20. // 实现:防止登录(不可用)界面 contentHtmlDiv 受影响
  21. // 实现:兼容手机 isTouch ? "selectionchange" : "mouseup"
  22. // 实现:笔记正文时间戳
  23. //
  24. // 2025-03-14
  25. // 实现:手机界面不弹出键盘,优化删除键,尝试隐藏编辑窗口
  26. // 实现:通过 GM_setValue 实现 nota_title 自动填充高亮选择文字
  27. //
  28. // 2025-03-12
  29. // 实现:基本功能
  30. //////// 隐藏 div_nota_visor (CSS)
  31. GM_addStyle("#div_nota_visor { display: none !important; }")
  32. //////// 暴力猴子补丁 "/estaticosED/files/js/panelSocial-1.0.4.js" this.editNote
  33. function PanelSOCIAL(opts) {
  34. var playerMusic,
  35. panelMusic,
  36. musicaElement,
  37. that = this,
  38. boxFrame1,
  39. bodyDiv = document.body,
  40. settings = $.extend({}, opts)
  41. that.settings = settings
  42. that.nativeCapabilitiesTxt = ""
  43. that.textZoomVal = 1
  44. that.textColor = "clear"
  45. that.tipoLetra = 1
  46. that.mosaicSize = 0
  47. var floatTextViewer = null
  48. var diccTotal = null
  49. var contextualMenu = null
  50. var mosaico = null
  51. var clipboard
  52. var elementoAudio = document.createElement("AUDIO")
  53. var visorImagenes = null,
  54. visorImagenesIDs = null
  55. var isSmartPhone, isTablet, isTouch
  56. var executeNative = ltotalUtils.executeNative("TEST")
  57. var executeNativePlatform = ltotalUtils.executeNative("PLATFORM")
  58. var executeNativeCredentials = executeNative
  59. var orientationNative = ""
  60. var SycCredentials = null,
  61. loginReady = false,
  62. idCliente = 1
  63. var shareGiftAdmObject = null
  64. setTabletVars()
  65. var modoEstaticos = "produccion"
  66. function getContextoEstaticos() {
  67. var r = ""
  68. if (modoEstaticos == "desarrollo") {
  69. r = "estaticosED"
  70. }
  71. if (modoEstaticos == "produccion") {
  72. r = "/estaticosED/files"
  73. }
  74. return r
  75. }
  76. this.getContextoEstaticos = function () {
  77. return getContextoEstaticos()
  78. }
  79. function setTabletVars() {
  80. isSmartPhone = ltotalOS.isSmartPhone
  81. isTablet = ltotalOS.isTablet
  82. isTouch = isSmartPhone || isTablet
  83. }
  84. this.setTabletVars = function () {
  85. setTabletVars()
  86. }
  87. this.fullScreen = function () {
  88. if (
  89. (document.fullScreenElement && document.fullScreenElement !== null) || // metodo alternativo
  90. (!document.mozFullScreen && !document.webkitIsFullScreen)
  91. ) {
  92. // metodos actuales
  93. if (document.documentElement.requestFullScreen) {
  94. document.documentElement.requestFullScreen()
  95. } else if (document.documentElement.mozRequestFullScreen) {
  96. document.documentElement.mozRequestFullScreen()
  97. } else if (document.documentElement.webkitRequestFullScreen) {
  98. document.documentElement.webkitRequestFullScreen(
  99. Element.ALLOW_KEYBOARD_INPUT,
  100. )
  101. }
  102. }
  103. }
  104. this.cancelFullscreen = function () {
  105. if (document.cancelFullScreen) {
  106. document.cancelFullScreen()
  107. } else if (document.mozCancelFullScreen) {
  108. document.mozCancelFullScreen()
  109. } else if (document.webkitCancelFullScreen) {
  110. document.webkitCancelFullScreen()
  111. }
  112. }
  113. this.createIFRAME = function (opts) {
  114. if (boxFrame1) {
  115. $(boxFrame1).remove()
  116. boxFrame1 = null
  117. }
  118. var frameEpic,
  119. closeFrame1,
  120. settings = $.extend({}, opts)
  121. boxFrame1 = document.createElement("div")
  122. boxFrame1.setAttribute("class", "boxFrame1")
  123. boxFrame1.id = settings.id
  124. $(settings.hostDiv).append(boxFrame1)
  125. frameEpic = document.createElement("iframe")
  126. frameEpic.setAttribute("class", "frameEpic")
  127. frameEpic.setAttribute("src", settings.url)
  128. $(boxFrame1).append(frameEpic)
  129. closeFrame1 = document.createElement("div")
  130. closeFrame1.setAttribute("class", "closeFrame1")
  131. $(boxFrame1).append(closeFrame1)
  132. closeFrame1.onclick = function () {
  133. $(boxFrame1).remove()
  134. boxFrame1 = null
  135. if (typeof settings.close == "function") {
  136. settings.close()
  137. }
  138. panelSocial.setNativeMainViewBGColor(11, 28, 43)
  139. }
  140. boxFrame1.closeFrame = closeFrame1
  141. var doFull = true
  142. if (opts.avoidFullScreen) {
  143. doFull = false
  144. }
  145. if (doFull) {
  146. this.fullScreen()
  147. }
  148. }
  149. this.getBoxFrame = function () {
  150. return boxFrame1
  151. }
  152. this.openBook = function (_tipoLibro, _idLibro, _idTrad, extraParams) {
  153. that.closeMasInfoItem()
  154. var modoLibro = 1
  155. var searchWords = ""
  156. var txtsearch_exact = null
  157. var numePagina = null
  158. var numePaginaPercent = null
  159. var openVocabulary = null
  160. var numeSeccion = null
  161. var numePaginaSeccion = null
  162. var txtCoord = null
  163. var fechaVisto = null
  164. var dedicatoria = null
  165. var idRecRela = null
  166. var npagRecRela = null
  167. var idNotaRecRela = null
  168. var idNotaRela = null
  169. var npagNotaRela = null
  170. var idImagenRela = null
  171. var npagImagenRela = null
  172. var idLibroRela = null
  173. var idTradRela = null
  174. var npagLibroRela = null
  175. var idProyCitaRela = null
  176. var npagProyCitaRela = null
  177. var idCredCitaRela = null
  178. var idFotoPromo = null
  179. var idInstitutPromo = null
  180. var idRegalo = null
  181. var idLectorConcurso = null
  182. var fnAfterClose = null
  183. //Estadistica de apertura de libro en interfaz eDesk
  184. ltotalOS.statistics(
  185. 83,
  186. "tipoLibro:" + _tipoLibro + " idLibro:" + _idLibro,
  187. )
  188. if (extraParams) {
  189. if (extraParams.searchWords) {
  190. modoLibro = 3
  191. searchWords = extraParams.searchWords
  192. if (extraParams.txtsearch_exact) {
  193. txtsearch_exact = 1
  194. }
  195. }
  196. if (extraParams.numePagina) {
  197. numePagina = extraParams.numePagina
  198. }
  199. if (extraParams.numePaginaPercent) {
  200. numePaginaPercent = extraParams.numePaginaPercent
  201. }
  202. if (extraParams.openVocabulary) {
  203. openVocabulary = extraParams.openVocabulary
  204. }
  205. if (extraParams.numeSeccion) {
  206. numeSeccion = extraParams.numeSeccion
  207. }
  208. if (extraParams.numePaginaSeccion) {
  209. numePaginaSeccion = extraParams.numePaginaSeccion
  210. }
  211. if (extraParams.txtCoord) {
  212. txtCoord = extraParams.txtCoord
  213. }
  214. if (extraParams.fechaVisto) {
  215. fechaVisto = extraParams.fechaVisto
  216. }
  217. if (extraParams.dedicatoria) {
  218. dedicatoria = extraParams.dedicatoria
  219. }
  220. if (extraParams.idRecRela) {
  221. idRecRela = extraParams.idRecRela
  222. npagRecRela = extraParams.npagRecRela
  223. idNotaRecRela = extraParams.idNotaRecRela
  224. }
  225. if (extraParams.idNotaRela) {
  226. idNotaRela = extraParams.idNotaRela
  227. npagNotaRela = extraParams.npagNotaRela
  228. }
  229. if (extraParams.idImagenRela) {
  230. idImagenRela = extraParams.idImagenRela
  231. npagImagenRela = extraParams.npagImagenRela
  232. }
  233. if (extraParams.idLibroRela) {
  234. idLibroRela = extraParams.idLibroRela
  235. idTradRela = extraParams.idTradRela
  236. npagLibroRela = extraParams.npagLibroRela
  237. }
  238. if (_tipoLibro && extraParams.tematico) {
  239. modoLibro = 4
  240. numeSeccion = 1
  241. }
  242. if (extraParams.idProyCitaRela) {
  243. idProyCitaRela = extraParams.idProyCitaRela
  244. npagProyCitaRela = extraParams.npagProyCitaRela
  245. idCredCitaRela = extraParams.idCredCitaRela
  246. }
  247. if (extraParams.idFotoPromo) {
  248. idFotoPromo = extraParams.idFotoPromo
  249. }
  250. if (extraParams.idInstitutPromo) {
  251. idInstitutPromo = extraParams.idInstitutPromo
  252. }
  253. if (extraParams.idRegalo) {
  254. idRegalo = extraParams.idRegalo
  255. }
  256. if (extraParams.fnAfterClose) {
  257. fnAfterClose = extraParams.fnAfterClose
  258. }
  259. if (extraParams.openInIndex) {
  260. modoLibro = 0
  261. }
  262. if (typeof extraParams.idLectorConcurso != undefined) {
  263. idLectorConcurso = extraParams.idLectorConcurso
  264. }
  265. }
  266. //Libros de investigacion abren en el indice
  267. if (_tipoLibro == 27 && numeSeccion == null && searchWords.length == 0) {
  268. modoLibro = 0
  269. }
  270. //Libros artículos (tipo 27 modo 2)
  271. if (_tipoLibro == 17) {
  272. _tipoLibro = 27
  273. modoLibro = 2
  274. }
  275. var viewerText = new ViewerText({
  276. idViewerTxt: "viewer_book",
  277. sections: null,
  278. tipoLibro: _tipoLibro,
  279. idLibro: _idLibro,
  280. idTrad: _idTrad,
  281. modoLibro: modoLibro,
  282. searchWords: searchWords,
  283. txtsearch_exact: txtsearch_exact,
  284. numePagina: numePagina,
  285. numePaginaPercent: numePaginaPercent,
  286. openVocabulary: openVocabulary,
  287. numeSeccion: numeSeccion,
  288. numePaginaSeccion: numePaginaSeccion,
  289. txtCoord: txtCoord,
  290. fechaVisto: fechaVisto,
  291. dedicatoria: dedicatoria,
  292. idRecRela: idRecRela,
  293. npagRecRela: npagRecRela,
  294. idNotaRecRela: idNotaRecRela,
  295. idNotaRela: idNotaRela,
  296. npagNotaRela: npagNotaRela,
  297. idImagenRela: idImagenRela,
  298. npagImagenRela: npagImagenRela,
  299. idLibroRela: idLibroRela,
  300. idTradRela: idTradRela,
  301. npagLibroRela: npagLibroRela,
  302. idProyCitaRela: idProyCitaRela,
  303. npagProyCitaRela: npagProyCitaRela,
  304. idCredCitaRela: idCredCitaRela,
  305. idFotoPromo: idFotoPromo,
  306. idInstitutPromo: idInstitutPromo,
  307. idRegalo: idRegalo,
  308. idLectorConcurso: idLectorConcurso,
  309. pageLeft: "1",
  310. SycCredentials: SycCredentials,
  311. fnOpen: function (_settings) {
  312. var editorNoteMini =
  313. typeof llector !== "undefined" &&
  314. llector.theresEditor &&
  315. llector.editorNoteMini
  316. ? true
  317. : false
  318. if (isTouch && editorNoteMini) {
  319. $(
  320. ".box_tool_bar_edition",
  321. panelSocial.selectedBook.boxViewerTXT,
  322. ).prepend(llector.contMinimized)
  323. }
  324. },
  325. fnClose: function (_settings) {
  326. var corpus = _settings.that.corpus
  327. //Chequear que haya corpus en modo indice ndice de paginas, para lanzar el corpus nuevamente
  328. if (isTouch && corpus && corpus.isPagesIndexMode) {
  329. corpus.close()
  330. return null
  331. }
  332. //Remueve del DOM, el corpus cuando cierra el libro
  333. if (corpus) {
  334. $(corpus.cont).remove()
  335. }
  336. //Invitar al usuario a registrarse al cerrar un libro por primera vez, sin sesion
  337. inviteToRegister()
  338. //Resetea el libro seleccionado
  339. panelSocial.selectedBook = null
  340. if (_settings.hasChangedFavorite) {
  341. that.settings.doARepaint = true
  342. }
  343. mosaico.destroyTab(viewerText.idTab)
  344. panelSocial.setNativeMainViewBGColor(11, 28, 43)
  345. if (fnAfterClose) {
  346. fnAfterClose()
  347. }
  348. var editorNoteMini =
  349. typeof llector !== "undefined" &&
  350. llector.theresEditor &&
  351. llector.editorNoteMini
  352. ? true
  353. : false
  354. if (isTouch && editorNoteMini) {
  355. if (panelSocial.settings.appendMode == "prepend") {
  356. $(panelSocial.settings.contMusicHostDiv).prepend(
  357. llector.contMinimized,
  358. )
  359. } else {
  360. $(panelSocial.settings.contMusicHostDiv).append(
  361. llector.contMinimized,
  362. )
  363. }
  364. }
  365. panelSocial.mosaico.resetLabel("banners", "banners", {
  366. labelID: "banners_banners",
  367. })
  368. },
  369. fnBookInfoReady: function (_info) {
  370. mosaico.updateTab(viewerText.idTab, _info)
  371. },
  372. fnDiscountNovedad: function (_tipoLibro, _idLibro, _extraClass) {
  373. mosaico.discountNovedad(_tipoLibro, _idLibro, _extraClass)
  374. },
  375. fnOpenBookComparado: function (_idLibro, _idTrad, _extra) {
  376. that.openBookComparado(_idLibro, _idTrad, _extra)
  377. },
  378. fnReadingProgress: function (_pgFin, _idItemFin, _settings) {
  379. //Guarda el progreso de lectura al pasar pagina
  380. if (lectorLogueado && !_settings.isProhibido) {
  381. var idLib = _settings.idLibro
  382. var idTrad = _settings.idTrad
  383. //Libros artículos (tipo 27 modo 2)
  384. if (_tipoLibro == 27 && _settings.modoLibro == 2) {
  385. _tipoLibro = 17
  386. }
  387. var numePaginaPercent = _settings.numePaginaPercent
  388. mosaico.saveBitacora(
  389. _tipoLibro,
  390. idLib,
  391. idTrad,
  392. _pgFin,
  393. _idItemFin,
  394. "",
  395. numePaginaPercent,
  396. )
  397. }
  398. },
  399. })
  400. mosaico.openObjectInTab(viewerText, "")
  401. }
  402. this.openBookComparado = function (_idLibro, _idTrad, _extraParams) {
  403. ltotalUtils.loadScript(
  404. getContextoEstaticos() + "/js/ltotal/viewerTxtComparado-1.0.0.js",
  405. )
  406. var versionsData = []
  407. var pg = 1
  408. if (_extraParams) {
  409. var versionsD = _extraParams.versionsData
  410. if (versionsD.length > 0) {
  411. versionsData = versionsD
  412. }
  413. if (_extraParams.pg) {
  414. pg = _extraParams.pg
  415. }
  416. }
  417. var viewerTextComparado = new ViewerTxtComparado({
  418. idLibro: _idLibro,
  419. idTrad: _idTrad,
  420. versionsData: versionsData,
  421. pg: pg,
  422. SycCredentials: SycCredentials,
  423. fnClose: function (_pgFin) {
  424. mosaico.destroyTab(viewerTextComparado.idTab)
  425. },
  426. })
  427. mosaico.openObjectInTab(viewerTextComparado, "Lectura comparada")
  428. }
  429. this.openDiccTotal = function (_word, _idDicc, _extraParams) {
  430. llector.loadColors()
  431. //NOTA!!
  432. //dicc_total opera de modo global con la variable diccTotal (una instancia)
  433. //y en pestanas (multiples instancias)
  434. if (diccTotal) {
  435. if (_word) {
  436. diccTotal.define(_word, diccTotal.seleccDic)
  437. }
  438. return null
  439. }
  440. var idWord = null
  441. var casoRela = null
  442. var relaInfo = null
  443. var signiSearch = null
  444. var openInTab = false
  445. var fnClose = function () {
  446. diccTotal = null
  447. }
  448. var fnAfterShowWord = null
  449. var diccAlfabetico = false
  450. if (_extraParams) {
  451. if (_extraParams.signiSearch) {
  452. signiSearch = _extraParams.signiSearch
  453. }
  454. if (_extraParams.openInTab) {
  455. openInTab = true
  456. fnClose = function () {
  457. mosaico.destroyTab(dicc.idTab)
  458. if ($(".boxMosaicFull").children().length == 0) {
  459. panelSocial.setNativeMainViewBGColor(11, 28, 43)
  460. }
  461. if (_extraParams && _extraParams.fromOffLineApp) {
  462. var cmdObj = { Module: "OfflineApp", Action: "PopWindow" }
  463. that.executeNative(cmdObj)
  464. }
  465. }
  466. fnAfterShowWord = function (_wd) {
  467. mosaico.updateTab(dicc.idTab, _wd)
  468. if (lectorLogueado) {
  469. mosaico.saveBitacora(16, -1, -1, -1, -1, _wd.toUpperCase(), null)
  470. }
  471. }
  472. }
  473. if (_extraParams.idWord) {
  474. idWord = _extraParams.idWord
  475. }
  476. if (_extraParams.casoRela) {
  477. casoRela = _extraParams.casoRela
  478. }
  479. if (_extraParams.relaInfo) {
  480. relaInfo = _extraParams.relaInfo
  481. }
  482. if (_extraParams.diccAlfabetico) {
  483. diccAlfabetico = true
  484. }
  485. }
  486. var settings = {
  487. settings: {
  488. containerTop: isSmartPhone ? 0 : 10,
  489. fnClose: fnClose,
  490. fnAfterShowWord: fnAfterShowWord,
  491. },
  492. }
  493. var dicc = jQuery.extend(true, settings, dicc_total)
  494. dicc.idActStat = 80
  495. dicc.getParentCont = function () {
  496. return bodyDiv
  497. }
  498. var idDicc = -1
  499. if (_idDicc) {
  500. idDicc = _idDicc
  501. dicc.seleccDic = _idDicc
  502. }
  503. if (diccAlfabetico) {
  504. dicc.diccAlfabetico = 1
  505. }
  506. if (idWord) {
  507. dicc.openContainerIDWord(idWord, casoRela, relaInfo)
  508. } else if (signiSearch) {
  509. dicc.openContainerIndexSigniSearch(idDicc, signiSearch)
  510. } else {
  511. if (_word) {
  512. dicc.openContainer(_word, idDicc)
  513. } else {
  514. if (diccAlfabetico) {
  515. var canOpenAlfabetico =
  516. _extraParams.publicDomain ||
  517. ltotalUtils.checkPermiso("anotador,anotador_palabras") ||
  518. (_extraParams.diccSYC &&
  519. ltotalUtils.checkPermiso("anotador_palabras_syc"))
  520. if (canOpenAlfabetico) {
  521. dicc.openContainer("", idDicc)
  522. } else {
  523. dicc.openContainerIntro()
  524. }
  525. } else {
  526. dicc.openContainerIntro()
  527. }
  528. }
  529. }
  530. if (openInTab) {
  531. mosaico.openObjectInTab(dicc, "Diccionario")
  532. } else {
  533. diccTotal = dicc
  534. }
  535. return dicc
  536. }
  537. this.openVideo = function (_item, _extra) {
  538. ltotalUtils.checkConnection()
  539. if (typeof panelVideo == "undefined") {
  540. ltotalUtils.loadScript("/estaticosED/files/js/ltotal/panelVideo.js")
  541. ltotalUtils.loadScript("/estaticosED/files/css/ltotal/panelVideo.css")
  542. }
  543. panelVideo.openVideo(_item, _extra)
  544. }
  545. this.openVideoVocabulary = function (item) {
  546. panelSocial.openVideo(item, { loadMode: "vocabulary" })
  547. var vc = panelVideo.corpus
  548. if (!vc) {
  549. vc = jQuery.extend(true, {}, corpus)
  550. panelVideo.corpus = vc
  551. }
  552. vc.showVideoVocabulary(item)
  553. }
  554. this.createBottomMenu = function (_parent) {
  555. return createBottomMenu(_parent)
  556. }
  557. function createBottomMenu(_parent) {
  558. var boxBottomMenu = $(".boxBottomMenu", _parent)[0]
  559. if (!boxBottomMenu) {
  560. boxBottomMenu = document.createElement("div")
  561. boxBottomMenu.setAttribute("class", "boxBottomMenu")
  562. $(_parent).append(boxBottomMenu)
  563. }
  564. return boxBottomMenu
  565. }
  566. this.showBottomMenu = function (_html, _closeTmr, _parent, _extra) {
  567. showBottomMenu(_html, _closeTmr, _parent, _extra)
  568. }
  569. function showBottomMenu(_html, _closeTmr, _parent, _extra) {
  570. var box = $(".boxBottomMenu", _parent)
  571. var boxBottomMenu = box[0]
  572. if (!boxBottomMenu.inited) {
  573. box.append('<div class="contentBox"></div>')
  574. boxBottomMenu.inited = true
  575. }
  576. $(".contentBox", box).html(_html)
  577. if (_extra && _extra.removeTools) {
  578. $(_extra.removeTools, boxBottomMenu).remove()
  579. }
  580. clearTimeout(boxBottomMenu.timerClose)
  581. if (!box.is(":visible")) {
  582. box.css({ display: "block", visibility: "hidden" })
  583. if (_extra && _extra.extraH && !boxBottomMenu.extraH) {
  584. var coh = boxBottomMenu.offsetHeight + _extra.extraH
  585. $(boxBottomMenu).css({ height: coh })
  586. boxBottomMenu.extraH = _extra.extraH
  587. }
  588. var oh = boxBottomMenu.offsetHeight + 10
  589. box.css({ bottom: "-" + oh + "px", visibility: "" })
  590. box.animate({ bottom: "+=" + oh })
  591. if (_closeTmr) {
  592. boxBottomMenu.timerClose = setTimeout(function () {
  593. closeBottomMenu(_parent)
  594. }, _closeTmr)
  595. }
  596. }
  597. }
  598. this.closeBottomMenu = function (_parent) {
  599. closeBottomMenu(_parent)
  600. }
  601. function closeBottomMenu(_parent) {
  602. var box = $(".boxBottomMenu", _parent)
  603. if (box.is(":visible")) {
  604. var oh = box[0].offsetHeight + 10
  605. box.animate({ bottom: "-=" + oh }, function () {
  606. box.css({ display: "" })
  607. })
  608. }
  609. }
  610. this.showConfig = function () {
  611. var html =
  612. '\
  613. <div class="mosa_config_cont">\
  614. <div class="close_btn"></div>\
  615. <div class="config_label">Tamaño de la interfaz</div>\
  616. <div class="size_btns_cont">\
  617. <div class="size_btn size_estandar_btn"><div class="checker"></div></div>\
  618. <div class="size_btn size_aumented_btn"><div class="checker"></div></div>\
  619. </div>\
  620. </div>'
  621. var config_cont = $(html)
  622. $(panelSocial.bodyDiv).append(config_cont)
  623. config_cont.fadeIn()
  624. $(".close_btn", config_cont)[0].onclick = function () {
  625. config_cont.fadeOut(function () {
  626. config_cont.remove()
  627. })
  628. }
  629. var btn_estandar = $(".size_estandar_btn", config_cont)
  630. var btn_aumented = $(".size_aumented_btn", config_cont)
  631. btn_estandar[0].onclick = function () {
  632. $(".size_btn", config_cont).removeClass("checked")
  633. $(this).addClass("checked")
  634. that.mosaico.aumentarSizeMosaico(0)
  635. }
  636. btn_aumented[0].onclick = function () {
  637. $(".size_btn", config_cont).removeClass("checked")
  638. $(this).addClass("checked")
  639. that.mosaico.aumentarSizeMosaico(1)
  640. }
  641. if (panelSocial.mosaicSize == 1) {
  642. btn_aumented.addClass("checked")
  643. } else {
  644. btn_estandar.addClass("checked")
  645. }
  646. }
  647. this.showTextLookTools = function (_obj, _extra) {
  648. var html
  649. var modeBottom = _extra && _extra.modeBottom
  650. if (isTouch || modeBottom) {
  651. var boxBottomMenu = $(".boxBottomMenu", _obj.boxViewerTXT)[0]
  652. if (
  653. $(boxBottomMenu).is(":visible") &&
  654. $(".box_txt_look", boxBottomMenu)[0]
  655. ) {
  656. return closeBottomMenu(_obj.boxViewerTXT)
  657. }
  658. html =
  659. '\
  660. <div class="box_txt_look tools_font_size">\
  661. <div class="txt_size_minus tool_txt_look" style="font-size:14px;"></div>\
  662. <div class="txt_size_plus tool_txt_look" style="font-size:24px;"></div></div>\
  663. <div class="box_txt_look tools_text_color">\
  664. <div class="txt_color_clear tool_txt_look text_color"></div>\
  665. <div class="txt_color_cream tool_txt_look text_color"></div>\
  666. <div class="txt_color_dark tool_txt_look text_color"></div>\
  667. </div>\
  668. <div class="box_txt_look tools_font_type">\
  669. <div class="tipoLetra1 tool_txt_look tool_font">Times</div>\
  670. <div class="tipoLetra2 tool_txt_look tool_font">DM Sans</div>\
  671. <div class="tipoLetra3 tool_txt_look tool_font">Literata</div>\
  672. <div class="tipoLetra4 tool_txt_look tool_font">Roboto</div>\
  673. </div>\
  674. '
  675. showBottomMenu(html, null, _obj.boxViewerTXT, _extra)
  676. if ($(".tools_font_size", _obj.boxViewerTXT)[0]) {
  677. var minus = $(".txt_size_minus", boxBottomMenu)
  678. var plus = $(".txt_size_plus", boxBottomMenu)
  679. panelSocial.configZoomTextBtns(minus, plus, _obj)
  680. mosaico.makeRoundButton(minus[0])
  681. mosaico.makeRoundButton(plus[0])
  682. $(".squared", $([minus[0], plus[0]])).html("A")
  683. }
  684. if ($(".tools_text_color", _obj.boxViewerTXT)[0]) {
  685. var clear = $(".txt_color_clear", boxBottomMenu)
  686. var cream = $(".txt_color_cream", boxBottomMenu)
  687. var dark = $(".txt_color_dark", boxBottomMenu)
  688. panelSocial.configColorTextBtns(
  689. clear[0],
  690. cream[0],
  691. dark[0],
  692. _obj,
  693. clear.parent(),
  694. )
  695. mosaico.makeRoundButton(clear[0])
  696. mosaico.makeRoundButton(cream[0])
  697. mosaico.makeRoundButton(dark[0])
  698. $(".squared", $([clear[0], cream[0], dark[0]])).html(
  699. '<div class="checker"></div>',
  700. )
  701. }
  702. if ($(".tools_font_type", _obj.boxViewerTXT)[0]) {
  703. panelSocial.configFontTextBtns(boxBottomMenu, _obj, _extra)
  704. }
  705. } else {
  706. var extraH = 0
  707. html =
  708. '\
  709. <div style="width:100%; height:10px; background-color:rgba(0, 0, 0, 0.1);"></div>\
  710. <div style="width:100%; height:10px; margin-top:5px; color:#99782C; text-align:center; font-size:15px;">Tamaño de letra</div>\
  711. <div class="text_look_tools" style="position:relative; width:60%; left:20%; height:40px; margin:20px 0 20px 0;">\
  712. <div class="text_size minus">A</div>\
  713. <div class="text_size plus">A</div>\
  714. </div>\
  715. '
  716. var toolsColorTema = _extra && _extra.toolsColorTema
  717. if (toolsColorTema) {
  718. html +=
  719. '<div class="box_theme_color">\
  720. <div style="width:100%; height:10px; background-color:rgba(0, 0, 0, 0.1);"></div>\
  721. <div style="width:100%; height:10px; margin-top:10px; margin-bottom:15px; color:#99782C; text-align:center; font-size:15px;">Tema del contenedor</div>\
  722. <div class="text_look_tools" style="position:relative; width:60%; left:20%; height:40px; margin:20px 0 20px 0;">\
  723. <div class="text_color clear"></div>\
  724. <div class="text_color cream"></div>\
  725. <div class="text_color dark"></div>\
  726. </div>\
  727. </div>\
  728. '
  729. extraH += 100
  730. }
  731. var toolsTipoLetra = _extra && _extra.toolsTipoLetra
  732. if (toolsTipoLetra) {
  733. html +=
  734. '<div class="box_txt_type">\
  735. <div style="width:100%; height:10px; background-color:rgba(0, 0, 0, 0.1);"></div>\
  736. <div style="width:100%; height:10px; margin-top:10px; margin-bottom:15px; color:#99782C; text-align:center; font-size:15px;">Tipo de letra</div>\
  737. <div class="tipoLetra1 tool_font">Times</div>\
  738. <div class="tipoLetra2 tool_font">DM Sans</div>\
  739. <div class="tipoLetra3 tool_font">Literata</div>\
  740. <div class="tipoLetra4 tool_font">Roboto</div>\
  741. </div>\
  742. '
  743. extraH += 100
  744. }
  745. var modalViewer = _obj.showFloatTextViewer(html, "center")
  746. if (modalViewer) {
  747. modalViewer.rePaintFunc = function () {}
  748. }
  749. var cont = _obj.getFloatTextViewer().getContain()
  750. $(cont).addClass("box_text_look_tools")
  751. $(cont).css({
  752. width: "20%",
  753. left: "40%",
  754. height: "160px",
  755. "border-radius": "7px",
  756. })
  757. $(".contentHtml", cont).css({ width: "100%", "margin-left": "0" })
  758. $(".boxScroll", cont).remove()
  759. var minus = $(".minus", cont)
  760. var plus = $(".plus", cont)
  761. panelSocial.configZoomTextBtns(minus, plus, _obj)
  762. if (toolsColorTema) {
  763. var clear = $(".clear", cont)
  764. var cream = $(".cream", cont)
  765. var dark = $(".dark", cont)
  766. panelSocial.configColorTextBtns(
  767. clear[0],
  768. cream[0],
  769. dark[0],
  770. _obj,
  771. cont,
  772. )
  773. }
  774. if (toolsTipoLetra) {
  775. panelSocial.configFontTextBtns(cont, _obj, _extra)
  776. }
  777. if (extraH > 0) {
  778. var lec = (_obj.boxViewerTXT.offsetWidth - 380) / 2
  779. var hh = 160 + extraH
  780. $(cont).css({ width: "380px", height: hh + "px", left: lec + "px" })
  781. }
  782. var colorCont = _extra && _extra.colorCont
  783. if (colorCont) {
  784. $(cont).css({ "background-color": colorCont })
  785. }
  786. }
  787. }
  788. this.configColorTextBtns = function (_clear, _cream, _dark, _obj, _cont) {
  789. var text_color = $(".text_color", _cont)
  790. if (_clear) {
  791. _clear = $(_clear)
  792. _clear[0].onclick = function () {
  793. text_color.removeClass("checkmode")
  794. panelSocial.colorText("clear", _obj)
  795. _clear.addClass("checkmode")
  796. }
  797. if (panelSocial.textColor == "clear") {
  798. _clear.addClass("checkmode")
  799. }
  800. }
  801. if (_cream) {
  802. _cream = $(_cream)
  803. _cream[0].onclick = function () {
  804. text_color.removeClass("checkmode")
  805. panelSocial.colorText("cream", _obj)
  806. _cream.addClass("checkmode")
  807. }
  808. if (panelSocial.textColor == "cream") {
  809. _cream.addClass("checkmode")
  810. }
  811. }
  812. if (_dark) {
  813. _dark = $(_dark)
  814. _dark[0].onclick = function () {
  815. text_color.removeClass("checkmode")
  816. panelSocial.colorText("dark", _obj)
  817. _dark.addClass("checkmode")
  818. }
  819. if (panelSocial.textColor == "dark") {
  820. _dark.addClass("checkmode")
  821. }
  822. }
  823. }
  824. this.configZoomTextBtns = function (_minus, _plus, _obj) {
  825. _minus[0].onclick = function () {
  826. _plus.css({ color: "" })
  827. panelSocial.doTheZoomText(-0.1, true, _obj)
  828. if (panelSocial.textZoomVal <= 0.7) {
  829. _minus.css({ color: "rgba(153, 120, 44, 0.3)" })
  830. }
  831. }
  832. _plus[0].onclick = function () {
  833. _minus.css({ color: "" })
  834. panelSocial.doTheZoomText(0.1, true, _obj)
  835. if (panelSocial.textZoomVal >= 1.5) {
  836. _plus.css({ color: "rgba(153, 120, 44, 0.3)" })
  837. }
  838. }
  839. if (panelSocial.textZoomVal <= 0.7) {
  840. _minus.css({ color: "rgba(153, 120, 44, 0.3)" })
  841. }
  842. if (panelSocial.textZoomVal >= 1.5) {
  843. _plus.css({ color: "rgba(153, 120, 44, 0.3)" })
  844. }
  845. }
  846. this.configFontTextBtns = function (_boxMenu, _obj, _extra) {
  847. var toolFonts = $(".tool_font", _boxMenu)
  848. toolFonts.each(function () {
  849. $(this).append('<div class="checker"></div>')
  850. this.onclick = function () {
  851. toolFonts.removeClass("checkmode")
  852. $(this).addClass("checkmode")
  853. var font = parseInt(
  854. this.className.match(/tipoLetra\d+/)[0].match(/\d+/)[0],
  855. )
  856. panelSocial.changeFontText(font, _obj, _extra)
  857. }
  858. })
  859. $(".tipoLetra" + panelSocial.tipoLetra, _boxMenu).addClass("checkmode")
  860. }
  861. this.doTheZoomText = function (_inc, _savePref, _obj) {
  862. panelSocial.zoomText(_inc, _savePref)
  863. panelSocial.mosaico.zoomTextObjectsTabs()
  864. if (_obj.rePaint) {
  865. _obj.rePaint({ forcedRepaint: true })
  866. }
  867. }
  868. this.zoomText = function (_inc, _savePref) {
  869. var vTxtRules = []
  870. $.each(document.styleSheets, function () {
  871. if (this.href) {
  872. $.each(this.cssRules, function () {
  873. if (
  874. this.style &&
  875. this.selectorText &&
  876. (this.selectorText.indexOf(".boxViewerTXT") == 0 ||
  877. this.selectorText.indexOf("#dicc_total") == 0 ||
  878. this.selectorText.indexOf(".boxViewerTXTComparado") == 0 ||
  879. this.selectorText.indexOf(".modalViewerLT") > -1 ||
  880. this.selectorText.indexOf("#div_nota_visor") == 0 ||
  881. this.selectorText.indexOf(".paginaLibroOut") == 0)
  882. ) {
  883. vTxtRules.push(this)
  884. }
  885. })
  886. }
  887. })
  888. if (vTxtRules.length > 0 && _inc != 0) {
  889. var netxZoom = parseFloat((panelSocial.textZoomVal + _inc).toFixed(1))
  890. if (netxZoom > 1.5 || netxZoom < 0.7) {
  891. return null
  892. }
  893. panelSocial.textZoomVal = netxZoom
  894. $.each(vTxtRules, function () {
  895. //var st = this.selectorText;
  896. var fs = this.style["font-size"]
  897. if (fs && fs.length > 0 && fs.toUpperCase().indexOf("EM") > -1) {
  898. var em = parseFloat(fs) + _inc
  899. this.style["font-size"] = em + "em"
  900. if (isTouch) {
  901. this.style["line-height"] = "1.4em"
  902. }
  903. }
  904. })
  905. if (_savePref) {
  906. ltotalOS.setPreferenciaLector("textZoomVal", netxZoom)
  907. }
  908. }
  909. }
  910. this.colorText = function (_theme, _obj) {
  911. $(_obj.boxViewerTXT).removeClass("cream dark")
  912. var huboTema = false
  913. if (_theme == "cream") {
  914. $(_obj.boxViewerTXT).addClass("cream")
  915. panelSocial.setNativeMainViewBGColor(251, 246, 226)
  916. huboTema = true
  917. }
  918. if (_theme == "dark") {
  919. $(_obj.boxViewerTXT).addClass("dark")
  920. panelSocial.setNativeMainViewBGColor(0, 0, 0)
  921. huboTema = true
  922. }
  923. if (!huboTema) {
  924. //Este es el tema "clear"
  925. panelSocial.setNativeMainViewBGColor(255, 255, 255)
  926. }
  927. panelSocial.textColor = _theme
  928. ltotalOS.setPreferenciaLector("textColor", _theme)
  929. }
  930. this.changeFontText = function (_font, _obj, _extra) {
  931. $(_obj.boxViewerTXT).removeClass(
  932. "tipoLetra1 tipoLetra2 tipoLetra3 tipoLetra4",
  933. )
  934. $(_obj.boxViewerTXT).addClass("tipoLetra" + _font)
  935. panelSocial.tipoLetra = _font
  936. ltotalOS.setPreferenciaLector("tipoLetra", _font)
  937. if (_extra && typeof _extra.fnAfterFontType == "function") {
  938. _extra.fnAfterFontType()
  939. }
  940. }
  941. this.openBookVocabulary = function () {
  942. var book = panelSocial.selectedBook
  943. var c = book.corpus
  944. if (!c) {
  945. c = jQuery.extend(true, {}, corpus)
  946. book.corpus = c
  947. }
  948. c.showBookVocabulary(book)
  949. }
  950. this.editNote = function (tipo_nota, id_nota, _extra) {
  951. if (!_extra) {
  952. _extra = {}
  953. }
  954. if (isTablet || isSmartPhone) {
  955. _extra.position = 4
  956. }
  957. var config = {
  958. containerClass: "editor_notas_edesk",
  959. parentContainer: bodyDiv,
  960. position: _extra.position,
  961. subrayar: false,
  962. activarSeleccion: false,
  963. mostrarBarra: true,
  964. bindTouch: isTouch,
  965. tipoItemRela: _extra.tipoItemRela,
  966. idItemRela: _extra.idItemRela,
  967. idItem2Rela: _extra.idItem2Rela,
  968. npagItemRela: _extra.npagItemRela,
  969. idNotaRela: _extra.idNotaRela,
  970. txtRela: _extra.txtRela,
  971. correccionEdicion: _extra.correccionEdicion,
  972. nsecc: _extra.nsecc,
  973. afterSaveCallback: function (_data, _obj) {
  974. _obj.closeCont()
  975. var openMyNotas = true
  976. var sb = panelSocial.selectedBook
  977. if (sb) {
  978. var sets = sb.settings
  979. var ss = sb.settings
  980. if (_obj.tipoComp == ss.tipoLibro && _obj.idLibro == ss.idLibro) {
  981. sb.goToPageAndHighLightNote(_obj.npag, _obj.idNota).done(
  982. function () {
  983. panelSocial
  984. .getSeccionLibroByIDNota(27, 0, _obj.idNota)
  985. .then(function (_nsec) {
  986. var extra = { numeSeccion: _nsec }
  987. // panelSocial.openBook(27, 0, -1, extra);
  988. console.log("patched")
  989. })
  990. },
  991. )
  992. openMyNotas = false
  993. } else {
  994. if (ss.tipoLibro == 27) {
  995. var extra = {}
  996. if (ss.modoLibro == 2) {
  997. extra.modoLibro = 2
  998. }
  999. sb.bookGotoSection(_extra.nsecc, _extra.npagNote, extra)
  1000. openMyNotas = false
  1001. }
  1002. }
  1003. }
  1004. if (openMyNotas) {
  1005. var extra = { numeSeccion: 1 }
  1006. if (_extra.nsecc) {
  1007. extra.numeSeccion = _extra.nsecc
  1008. }
  1009. panelSocial.openBook(27, 0, -1, extra)
  1010. }
  1011. },
  1012. extraParams: SycCredentials,
  1013. }
  1014. //Notas de personaje
  1015. if (tipo_nota == 15) {
  1016. config.mostrarBarra = false
  1017. if (id_nota == 0) {
  1018. fisher.newNote(config)
  1019. }
  1020. if (id_nota > 0) {
  1021. fisher.editNote(id_nota, _extra.position, config)
  1022. }
  1023. }
  1024. //Notas de lector
  1025. if (tipo_nota == 17) {
  1026. if (id_nota == 0) {
  1027. llector.newNote(_extra.toBook, _extra.idProy, null, null, config)
  1028. }
  1029. if (id_nota > 0) {
  1030. if (!_extra.npagNote) {
  1031. _extra.npagNote = "0"
  1032. }
  1033. llector.editNote(id_nota, _extra.npagNote, null, config)
  1034. }
  1035. }
  1036. }
  1037. // this.deleteNote = function (tipo_nota, id_nota, _fncb) {
  1038. // DialogueLM({
  1039. // show: true,
  1040. // ModoBtn: true,
  1041. // btnClose: true,
  1042. // btnCancelar: "Cancelar",
  1043. // btnAceptar: "Aceptar",
  1044. // texto: "¿Está seguro de borrar esta nota?",
  1045. // fnAceptar: function () {
  1046. // var url = "/ltotal/lector/editNota.jsp"
  1047. // var params = { caso: 5, tipoNota: tipo_nota, idNota: id_nota }
  1048. // panelSocial.doPost(url, params).done(_fncb)
  1049. // },
  1050. // fnCancelar: function () {},
  1051. // })
  1052. // }
  1053. //////// 去除确认 DialogueLM
  1054. this.deleteNote = function (tipo_nota, id_nota, _fncb) {
  1055. var url = "/ltotal/lector/editNota.jsp"
  1056. var params = { caso: 5, tipoNota: tipo_nota, idNota: id_nota }
  1057. panelSocial.doPost(url, params).done(_fncb)
  1058. }
  1059. this.sendNote = function (id_nota) {
  1060. llector.grupos.dialogEnviarNota(id_nota)
  1061. }
  1062. this.discardNote = function (id_project, id_nota) {
  1063. llector.grupos.setNota(2, id_project, id_nota, 0, 0, 0)
  1064. }
  1065. this.doPost = function (url, params) {
  1066. var queryURL = ltotalOS.getPostURL(url)
  1067. params.ltotalurl = url
  1068. jQuery.extend(params, SycCredentials)
  1069. params = $.trim(decodeURIComponent($.param(params)))
  1070. return $.post(queryURL, params)
  1071. }
  1072. var buscaIDS = function (_lista, _tipo_item, _idsvec) {
  1073. var rex = new RegExp("\\b" + _tipo_item + "_", "gi")
  1074. $.each(_lista, function (i, e) {
  1075. if (hasClassRegex(rex, e)) {
  1076. var id = getCellID(e)
  1077. //El Concurso --> 31,123 --> 31_123
  1078. var ID = id[1].replace(",", "_")
  1079. _idsvec.push(ID)
  1080. }
  1081. })
  1082. }
  1083. //Abrir visor imagenes desde el mosaico
  1084. function openMosaicImage(imageItem) {
  1085. var idImg = getCellID(imageItem)[1]
  1086. //El Concurso --> 31,123 --> 31_123
  1087. idImg = idImg.replace(",", "_")
  1088. var label = imageItem.lbl
  1089. //NOTA!!
  1090. //El mosaico aguanta imagenes normales o de concurso por aparte,
  1091. //NO se pueden mezclar estos dos tipos de imagenes
  1092. var idsimgs = []
  1093. buscaIDS(label.items, "(6|31)", idsimgs)
  1094. //Asegura que solo coja imagenes e imagenes de concurso
  1095. idsimgs = idsimgs.filter(function (_id) {
  1096. return /^\d+$/.test(_id) || /^31_\d+$/.test(_id)
  1097. })
  1098. that.processIdsImages(idsimgs, idImg)
  1099. }
  1100. this.processIdsImages = function (idsimgs, idImg) {
  1101. if (!idsimgs) {
  1102. return null
  1103. }
  1104. //Orden de las imagenes
  1105. var cantImgs = idsimgs.length
  1106. var idsimgsOrder = []
  1107. $.each(idsimgs, function (i, e) {
  1108. idsimgsOrder[e] = i
  1109. })
  1110. var posImag = 1
  1111. if (idImg) {
  1112. posImag = idsimgsOrder[idImg] + 1
  1113. }
  1114. visorImagenesIDs = idsimgs
  1115. ltotalOS
  1116. .loadData("imagenes", "rutas", idsimgs, "")
  1117. .done(function (htmlData) {
  1118. that.openImage(cantImgs, posImag, htmlData, idsimgsOrder)
  1119. })
  1120. }
  1121. this.refreshVisorImagenes = function (idImg) {
  1122. var boxViewerImg = $(".boxViewerImg")
  1123. if (boxViewerImg[0]) {
  1124. $(".closeViewer", boxViewerImg).trigger("click")
  1125. that.processIdsImages(visorImagenesIDs, idImg)
  1126. } else if (idImg) {
  1127. that.processIdsImages([idImg], null)
  1128. }
  1129. }
  1130. this.openImage = function (cantImgs, posImag, rutasData, idsimgsOrder) {
  1131. that.closeMasInfoItem()
  1132. //Orden de las imagenes
  1133. var rutasOrder = []
  1134. $.each(rutasData.split(","), function (i, e) {
  1135. var idr = e
  1136. .match(/\d+\.(jp(e)?g||png)/i)[0]
  1137. .replace(/\.(jp(e)?g||png)/i, "")
  1138. //Las imagenes del concurso van con el prefijo 31_
  1139. if (e.indexOf("/concurso/") > -1) {
  1140. idr = "31_" + idr
  1141. }
  1142. rutasOrder[idsimgsOrder[idr]] = e
  1143. })
  1144. that.openImageGeneric(cantImgs, posImag, rutasOrder)
  1145. }
  1146. this.openImageGeneric = function (cantImgs, posImag, rutasOrder, extra) {
  1147. ltotalUtils.loadScript(
  1148. getContextoEstaticos() + "/js/ltotal/viewerImage-1.0.0.js",
  1149. )
  1150. //JSON con las rutas
  1151. var rutas = $.map(rutasOrder, function (rut, i) {
  1152. return ['{"url":"' + rut + '","marks": []}']
  1153. })
  1154. var listaImgs = "[" + rutas.join(",") + "]"
  1155. var modeImages = "ltotal_images"
  1156. var titlesIMGS = []
  1157. if (extra) {
  1158. if (extra.modeImages) {
  1159. modeImages = extra.modeImages
  1160. }
  1161. if (extra.titlesIMGS) {
  1162. titlesIMGS = extra.titlesIMGS
  1163. }
  1164. }
  1165. var mijson = JSON.parse(listaImgs)
  1166. visorImagenes = new ImgViewer({
  1167. Toolbox: true,
  1168. bottomTools: "85px",
  1169. imgLensHeight: "100%",
  1170. zoom: false,
  1171. girar: false,
  1172. paginador: false,
  1173. marcasdef: false,
  1174. guiadocumento: false,
  1175. imglado_b: false,
  1176. zoomInicial: 1.0,
  1177. loadedImg: function () {
  1178. if (modeImages == "ltotal_images") {
  1179. //Estadistica de imagenes en interfaz eDesk
  1180. ltotalOS.statistics(86, viewerImage.getImgID())
  1181. //Incluye ilustracion en lo visto recientemente (lector logueado)
  1182. if (lectorLogueado) {
  1183. mosaico.saveBitacora(
  1184. 6,
  1185. -1,
  1186. -1,
  1187. -1,
  1188. viewerImage.getImgID(),
  1189. "",
  1190. null,
  1191. )
  1192. }
  1193. ltotalOS.timeStats({ tipoEvento: "pags_libro" })
  1194. }
  1195. if (modeImages == "generic_images") {
  1196. //Quita botones
  1197. $(
  1198. ".share_img, .tag_favorite, .editImage, .eraseImage, .novedadImage, .infoImage",
  1199. viewerImage.getContain(),
  1200. ).remove()
  1201. }
  1202. },
  1203. })
  1204. visorImagenes.load(mijson, posImag - 1)
  1205. var viewerImage = new ViewerImage({
  1206. hostDiv: that.bodyDiv,
  1207. visorImagenes: visorImagenes,
  1208. content: visorImagenes.frameViewer,
  1209. txt: "",
  1210. cantTxt: "",
  1211. cantImgs: cantImgs,
  1212. rutasOrder: rutasOrder,
  1213. mosaico: mosaico,
  1214. modeImages: modeImages,
  1215. titlesIMGS: titlesIMGS,
  1216. })
  1217. }
  1218. this.getFloatTextViewer = function () {
  1219. return floatTextViewer
  1220. }
  1221. this.verMasInfoItem = function (tipoItem, id, item, _extra) {
  1222. var agrupador = $(item).attr("label_agrupador")
  1223. var extraParams = {
  1224. basic_info: true,
  1225. }
  1226. jQuery.extend(extraParams, SycCredentials)
  1227. if (_extra) {
  1228. jQuery.extend(extraParams, _extra)
  1229. }
  1230. return ltotalOS
  1231. .loadData(tipoItem, "mas_informacion", id, extraParams)
  1232. .done(function (htmlData) {
  1233. htmlData = htmlData.replace(/(<br>){2,}/g, "<br><br>")
  1234. var proc = $(document.createElement("div"))
  1235. $(proc).html(htmlData)
  1236. var ilust = $(".img_credits_in", proc).detach()[0]
  1237. $(".txt_desc_ilust", proc).replaceWith(function () {
  1238. return this.innerHTML
  1239. })
  1240. $(".paginaLibroOut", proc).replaceWith(function () {
  1241. return this.innerHTML
  1242. })
  1243. $(".music_title", proc).css({ "font-size": "" })
  1244. //Links a libros relacionados
  1245. $(".book_relation", proc).each(function () {
  1246. this.onclick = function () {
  1247. var extra = null
  1248. var cn = this.className
  1249. var tipoItemRela = cn.match(/tipo_item_\d+/)[0].match(/\d+/)[0]
  1250. var idItemRela = cn.match(/id_item_\d+/)[0].match(/\d+/)[0]
  1251. var idLibro = cn.match(/id_lib_\d+/)[0].split("_")[2]
  1252. var idTrad = cn.match(/id_trad_\d+/)[0].split("_")[2]
  1253. var nPag = cn.match(/n_pag_\d+/)
  1254. if (nPag) {
  1255. nPag = nPag[0].match(/\d+/)[0]
  1256. if (nPag > 0) {
  1257. if (tipoItemRela == 6) {
  1258. extra = {
  1259. idImagenRela: idItemRela,
  1260. npagImagenRela: nPag,
  1261. numePagina: nPag,
  1262. }
  1263. }
  1264. }
  1265. }
  1266. that.openBook(1, idLibro, idTrad, extra)
  1267. //Cerrar visor de imagenes
  1268. var bvi = $(".boxViewerImg")
  1269. if (bvi[0]) {
  1270. $(".closeViewer").trigger("click")
  1271. }
  1272. }
  1273. })
  1274. var relaAutor = $(".rela_author", proc)
  1275. if (relaAutor[0]) {
  1276. relaAutor.html("Relacionado a " + relaAutor.html())
  1277. }
  1278. var tipoLibro = 0
  1279. var idLibro = null
  1280. var idTrad = null
  1281. if (item) {
  1282. var cell = getCellID(item)
  1283. var dataItem = cell[1].split(",")
  1284. tipoLibro = cell[0]
  1285. }
  1286. //Editar libro
  1287. if (tipoLibro == 1 && $(".hdn_libro_editar", proc)[0]) {
  1288. proc.prepend(
  1289. $(
  1290. '<div class="tag_tool tool_edit" title="Editar libro ' +
  1291. id +
  1292. '" onclick="edicion.libros.showLoad(' +
  1293. id +
  1294. ')"></div>',
  1295. ),
  1296. )
  1297. }
  1298. //Borrar libro
  1299. if (tipoLibro == 1 && $(".hdn_libro_borrar", proc)[0]) {
  1300. proc.prepend(
  1301. $(
  1302. '<div class="tag_tool tool_borrar" title="Borrar libro ' +
  1303. id +
  1304. '" onclick="edicion.libros.borrarLibro(' +
  1305. id +
  1306. ')"></div>',
  1307. ),
  1308. )
  1309. }
  1310. //Eliminar remplazar tags de libro
  1311. edicion.libros.eliminarTags($(".tags", proc)[0], id)
  1312. //Editar traduccion
  1313. if (tipoLibro == 4 && $(".hdn_libro_editar", proc)[0]) {
  1314. proc.prepend(
  1315. $(
  1316. '<div class="tag_tool tool_edit" title="Editar traduccion ' +
  1317. dataItem[1] +
  1318. '" onclick="edicion.traducciones.editTrad(' +
  1319. dataItem[1] +
  1320. ')"></div>',
  1321. ),
  1322. )
  1323. }
  1324. //Editar autor
  1325. if ($(".hdn_autor_editar", proc)[0]) {
  1326. proc.prepend(
  1327. $(
  1328. '<div class="tag_tool tool_edit" title="Editar autor ' +
  1329. id +
  1330. '" onclick="edicion.autores.showLoad(' +
  1331. id +
  1332. ')"></div>',
  1333. ),
  1334. )
  1335. }
  1336. //Editar imagen
  1337. if ($(".hdn_img_editar", proc)[0]) {
  1338. proc.prepend(
  1339. $(
  1340. '<div class="tag_tool tool_edit" title="Editar imagen ' +
  1341. id +
  1342. '" onclick="edicion.imagenes.showLoad(' +
  1343. id +
  1344. ')"></div>',
  1345. ),
  1346. )
  1347. var hasEditor =
  1348. typeof llector !== "undefined" && llector.theresEditor
  1349. ? true
  1350. : false
  1351. if (hasEditor) {
  1352. var toolSend = $(
  1353. '<div class="tag_tool tool_send_img" title="Enviar imagen a Editor"></div>',
  1354. )
  1355. proc.prepend(toolSend)
  1356. toolSend[0].onclick = function () {
  1357. that.sendImgToNote(id, ilust)
  1358. that.closeMasInfoItem()
  1359. }
  1360. }
  1361. }
  1362. //Herramientas de la música
  1363. proc.prepend($(".ficha_pescar, .ficha_create_nota", proc))
  1364. if ($(".hdn_edit_music", proc)[0]) {
  1365. proc.prepend(
  1366. $(
  1367. '<div class="tag_tool tool_edit" title="Editar música ' +
  1368. id +
  1369. '" onclick="edicion.musica.showLoad(' +
  1370. id +
  1371. ')"></div>',
  1372. ),
  1373. )
  1374. }
  1375. if ($(".hdn_delete_music", proc)[0]) {
  1376. proc.prepend(
  1377. $(
  1378. '<div class="tag_tool tool_borrar" title="Borrar música ' +
  1379. id +
  1380. '" onclick="edicion.musica.borrar(' +
  1381. id +
  1382. ')"></div>',
  1383. ),
  1384. )
  1385. }
  1386. if ($(".hdn_public_ewall", proc)[0]) {
  1387. proc.prepend(
  1388. $(
  1389. '<div class="tag_tool tool_publish" title="Publicar música en eWall ' +
  1390. id +
  1391. '" onclick="edicion.musica.setEwall(1, ' +
  1392. id +
  1393. ')"></div>',
  1394. ),
  1395. )
  1396. }
  1397. if ($(".hdn_delete_ewall", proc)[0]) {
  1398. proc.prepend(
  1399. $(
  1400. '<div class="tag_tool tool_unpublish" title="Publicar música en eWall ' +
  1401. id +
  1402. '" onclick="edicion.musica.setEwall(0, ' +
  1403. id +
  1404. ')"></div>',
  1405. ),
  1406. )
  1407. }
  1408. //Editar proyecto
  1409. if ($(".hdn_proyecto_editar", proc)[0]) {
  1410. proc.prepend(
  1411. $(
  1412. '<div class="tag_tool tool_edit" title="Editar proyecto ' +
  1413. id +
  1414. '" onclick="edicion.proyectos.showLoad(' +
  1415. id +
  1416. ')"></div>',
  1417. ),
  1418. )
  1419. }
  1420. //Herramientas de video
  1421. if ($(".hdn_edit_video", proc)[0]) {
  1422. proc.prepend(
  1423. $(
  1424. '<div class="tag_tool tool_edit" title="Editar video ' +
  1425. id +
  1426. '" onclick="edicion.videos.showLoad(' +
  1427. id +
  1428. ')"></div>',
  1429. ),
  1430. )
  1431. }
  1432. if ($(".hdn_delete_video", proc)[0]) {
  1433. proc.prepend(
  1434. $(
  1435. '<div class="tag_tool tool_borrar" title="Borrar video ' +
  1436. id +
  1437. '" onclick="edicion.videos.borrarVideo(' +
  1438. id +
  1439. ')"></div>',
  1440. ),
  1441. )
  1442. }
  1443. //Ir al libro
  1444. if (
  1445. (tipoItem == "libros" && !agrupador) ||
  1446. tipoItem == "personajes" ||
  1447. tipoItem == "proyectos"
  1448. ) {
  1449. var lnkHTML = '<div class="go_to_book">(Ir al Libro)</div>'
  1450. if ($(".summary", proc)[0]) {
  1451. $(".summary", proc).before(lnkHTML)
  1452. } else {
  1453. proc.append(lnkHTML)
  1454. }
  1455. var goToBook = $(".go_to_book", proc)[0]
  1456. idLibro = dataItem[0]
  1457. idTrad = dataItem[1]
  1458. goToBook.onclick = function () {
  1459. if (!idTrad) {
  1460. idTrad = 0
  1461. }
  1462. if (tipoLibro == 4) {
  1463. tipoLibro = 1
  1464. }
  1465. that.openBook(tipoLibro, idLibro, idTrad)
  1466. }
  1467. }
  1468. that.generateShareGiftOptions(
  1469. tipoItem,
  1470. idLibro,
  1471. idTrad,
  1472. tipoLibro,
  1473. proc,
  1474. id,
  1475. "share_gift",
  1476. ilust,
  1477. )
  1478. //Ir a autor desde resena
  1479. $(".tag_autor_resena", proc).each(function () {
  1480. this.onclick = function () {
  1481. var idAutorResena = this.className.split(" ")[1]
  1482. var item = document.createElement("div")
  1483. item.className = "cell 3_" + idAutorResena + " cvLD"
  1484. item.style.display = "inline-block"
  1485. if (isSmartPhone) {
  1486. that.closeMasInfoItem()
  1487. }
  1488. panelSocial.clickSobreItem(item, "libros", panelSocial.mosaico)
  1489. }
  1490. })
  1491. if ($.trim(proc[0].innerHTML.length) > 0) {
  1492. var factor = 50
  1493. var screW = $(window).width()
  1494. var screH = $(window).height()
  1495. var leftV = 0
  1496. var topV = 100
  1497. var heightV = screH * 0.6
  1498. var widthV = screW * 0.26
  1499. if (widthV < 400) {
  1500. widthV = 400
  1501. }
  1502. var gridBx = $(".gridBox")
  1503. if (item && gridBx[0]) {
  1504. var elem = $(item)
  1505. var elemW = elem.parent().width()
  1506. var gBoxT = gridBx.offset().top
  1507. var gBoxH = gridBx.height()
  1508. var left = elem.offset().left
  1509. leftV = left + elemW + factor
  1510. topV = gBoxT + (gBoxH - heightV) / 2
  1511. var posVisor = leftV + widthV
  1512. if (posVisor > screW) {
  1513. leftV = left - widthV - factor
  1514. }
  1515. if (leftV <= 0) {
  1516. leftV = factor
  1517. }
  1518. } else {
  1519. if (tipoItem == "musica" || tipoItem == "imagenes") {
  1520. leftV = ""
  1521. }
  1522. }
  1523. var setts = {
  1524. bottomV: "60px",
  1525. rightV: "100px",
  1526. leftV: leftV,
  1527. topV: topV,
  1528. heightV: heightV,
  1529. widthV: widthV,
  1530. }
  1531. if (
  1532. extraParams.containMusicGoUp &&
  1533. that.isContainMusicInFloatTextViewer()
  1534. ) {
  1535. panelMusic.placeContainer()
  1536. panelMusic.shouldShowInfoMusic = false
  1537. }
  1538. if (tipoItem == "musica") {
  1539. setts.draggable = true
  1540. }
  1541. if (_extra) {
  1542. if (typeof _extra.showTheModal !== "undefined") {
  1543. setts.showTheModal = _extra.showTheModal
  1544. }
  1545. }
  1546. that.openModalTxtViewer(proc.children().detach(), setts)
  1547. }
  1548. })
  1549. }
  1550. function inviteToRegister() {
  1551. var remInitSesion = ltotalUtils.fromLocalStorage("rememberInitSesion")
  1552. if (!lectorLogueado && !remInitSesion) {
  1553. ltotalUtils.toLocalStorage("rememberInitSesion", true)
  1554. var ironCurtain = $(
  1555. '<div class="iron_curtain" style="position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: rgba(25, 32, 35, 0.6); box-sizing: border-box;"></div>',
  1556. )
  1557. $(bodyDiv).append(ironCurtain)
  1558. ironCurtain[0].onclick = function (_ev) {
  1559. floatTextViewer.destroy()
  1560. $(this).remove()
  1561. }
  1562. var modalHtml =
  1563. '\
  1564. <div class="rem_init_sesion">\
  1565. Para guardar el avance de sus lecturas, debe \
  1566. <span onclick="$(\'.iron_curtain\').trigger(\'click\'); panelSocial.mosaico.btnRegisterClick();" style="color: #0873F5; cursor: pointer;">crear una cuenta</span>\
  1567. gratis como lector. Si ya la tiene, por favor\
  1568. <span onclick="$(\'.iron_curtain\').trigger(\'click\'); panelSocial.mosaico.btnLoginClick();" style="color: #0873F5; cursor: pointer;">inicie sesión</span>\
  1569. </div>\
  1570. <div class="loginBtn showInitSesion">Iniciar sesión</div>\
  1571. <div class="loginBtn showCreateAccount">Crear cuenta</div>\
  1572. '
  1573. var setts = {
  1574. heightV: null,
  1575. widthV: null,
  1576. scrollSyc: false,
  1577. bgColor: "rgb(255, 255, 255)",
  1578. fnAfterClose: function () {
  1579. ironCurtain.remove()
  1580. },
  1581. }
  1582. that.openModalTxtViewer(modalHtml, setts)
  1583. var cont = $(floatTextViewer.getContain())
  1584. cont.addClass("boxLogin")
  1585. $(".contentHtml", cont).css({
  1586. width: "90%",
  1587. "margin-left": "5%",
  1588. "margin-top": "10%",
  1589. })
  1590. $(".showInitSesion", cont)[0].onclick = function () {
  1591. $(".iron_curtain").trigger("click")
  1592. panelSocial.mosaico.btnLoginClick()
  1593. }
  1594. $(".showCreateAccount", cont)[0].onclick = function () {
  1595. $(".iron_curtain").trigger("click")
  1596. panelSocial.mosaico.btnRegisterClick()
  1597. }
  1598. }
  1599. }
  1600. this.generateShareGiftOptions = function (
  1601. tipoItem,
  1602. idLibro,
  1603. idTrad,
  1604. tipoLibro,
  1605. content,
  1606. id,
  1607. btnClassName,
  1608. ilust,
  1609. ) {
  1610. generateShareGiftOptions(
  1611. tipoItem,
  1612. idLibro,
  1613. idTrad,
  1614. tipoLibro,
  1615. content,
  1616. id,
  1617. btnClassName,
  1618. ilust,
  1619. )
  1620. }
  1621. this.shareGift = function (_shareOptions) {
  1622. var bShareOptions = {
  1623. hostDiv: bodyDiv,
  1624. clickClose: function () {
  1625. panelSocial.destroyShareModal()
  1626. },
  1627. }
  1628. var shareGiftOptions = $.extend(bShareOptions, _shareOptions)
  1629. panelSocial.destroyShareModal()
  1630. if (isTouch) {
  1631. that.closeMasInfoItem()
  1632. }
  1633. shareGiftAdmObject = new Share(shareGiftOptions)
  1634. shareGiftAdmObject.shareGiftOptions = shareGiftOptions
  1635. }
  1636. this.rePaintShareModal = function () {
  1637. if (shareGiftAdmObject && shareGiftAdmObject.getModalViewer()) {
  1638. this.shareGift(shareGiftAdmObject.shareGiftOptions)
  1639. }
  1640. }
  1641. this.rePaintModalViewer = function () {
  1642. if (floatTextViewer && !isSmartPhone) {
  1643. floatTextViewer.rePaint()
  1644. }
  1645. }
  1646. this.sendImgToNote = function (id, ilust) {
  1647. llector.creditsIN = []
  1648. llector.creditsIN[0] = {
  1649. cargar: 0,
  1650. id: id,
  1651. idLibro: -1,
  1652. idTrad: -1,
  1653. metadatos: "--id_ilustracion:" + id,
  1654. npag: -1,
  1655. tipo: 6,
  1656. txt: "",
  1657. img: ilust,
  1658. }
  1659. llector.applyCredits(null, null)
  1660. }
  1661. //Textos escritos por...
  1662. this.getIntervention = function (_elem) {
  1663. var id_lec = _elem.className.match(/cred_lector_\d+/)[0].match(/\d+/)[0]
  1664. var url = "/ltotal/inicio/utils/ut_34.jsp"
  1665. var queryURL = ltotalOS.getPostURL(url)
  1666. var params = { id_lector: id_lec, ltotalurl: url }
  1667. params = $.trim(decodeURIComponent($.param(params)))
  1668. return $.post(queryURL, params).then(function (data) {
  1669. var p = $("#proceso").html(data)
  1670. var nomb = $(".nomb_lector", p).val()
  1671. return [nomb]
  1672. })
  1673. }
  1674. this.isContainMusicInFloatTextViewer = function () {
  1675. var r = false
  1676. if (floatTextViewer) {
  1677. var containMusic = $(
  1678. ".containMusic",
  1679. that.getFloatTextViewer().getContain(),
  1680. )
  1681. if (containMusic[0]) {
  1682. r = true
  1683. }
  1684. }
  1685. return r
  1686. }
  1687. this.closeMasInfoItem = function () {
  1688. if (floatTextViewer) {
  1689. //Minimiza contenedor de musica
  1690. var cm = $(".containMusic", floatTextViewer.getContain())[0]
  1691. if (cm) {
  1692. panelMusic.minimizeContainer()
  1693. }
  1694. floatTextViewer.destroy()
  1695. floatTextViewer = null
  1696. }
  1697. }
  1698. this.initLibroTotal = function (_mosaicViewer, _fncb, _extra) {
  1699. if (
  1700. executeNative &&
  1701. executeNativePlatform == "nativeAndroid" &&
  1702. panelSocial.nativeCapabilitiesTxt.indexOf("KeyChain") == -1
  1703. ) {
  1704. executeNativeCredentials = false
  1705. }
  1706. if (executeNativeCredentials) {
  1707. that.getNativeCredentials()
  1708. } else {
  1709. isLogged()
  1710. }
  1711. bodyDiv = _mosaicViewer.mainFrame
  1712. that.bodyDiv = bodyDiv
  1713. ltotalOS.bodyDiv = bodyDiv
  1714. $(bodyDiv).addClass("ltotal_viewer")
  1715. if (_extra) {
  1716. if (_extra.idCliente) {
  1717. idCliente = _extra.idCliente
  1718. }
  1719. }
  1720. if (diccTotal) {
  1721. diccTotal.cerrar()
  1722. }
  1723. mosaico = new MosaicBooks({
  1724. modePilars: true,
  1725. withLogin: settings.withLogin,
  1726. fnClose: function () {
  1727. _mosaicViewer.close()
  1728. },
  1729. })
  1730. $(mosaico.getContain()).css({ "background-color": "transparent" })
  1731. _mosaicViewer.setContent(mosaico.getContain())
  1732. that.mosaico = mosaico
  1733. var finalFunc = function () {
  1734. $(mosaico.getContain()).css({ "background-color": "" })
  1735. var btnCerrar = settings.btnCerrar
  1736. if (btnCerrar == "1") {
  1737. mosaico.activateBtnCerrar()
  1738. }
  1739. if (_fncb) {
  1740. _fncb()
  1741. }
  1742. }
  1743. postInitLibroTotal(finalFunc)
  1744. }
  1745. function postInitLibroTotal(_fncb) {
  1746. if (!loginReady) {
  1747. setTimeout(function () {
  1748. postInitLibroTotal(_fncb)
  1749. }, 300)
  1750. return null
  1751. }
  1752. if (lectorLogueado) {
  1753. mosaico.SycCredentials = SycCredentials
  1754. }
  1755. try {
  1756. mosaico.configHMarginItems()
  1757. mosaico.aumentarSizeMosaico(that.mosaicSize)
  1758. mosaico.clickSobrePilar("libros", _fncb)
  1759. mosaico.configBtnLogin()
  1760. mosaico.activateCategsMenuBtns()
  1761. } catch (e) {
  1762. setTimeout(function () {
  1763. postInitLibroTotal(_fncb)
  1764. }, 1500)
  1765. }
  1766. }
  1767. this.clickSobreItem = function (item, servicio, mosaico, _extraParams) {
  1768. //No ejecuta cuando hubo desplazamiento reciente del mosaico
  1769. if (mosaico.dy > 10) {
  1770. return null
  1771. }
  1772. //No ejecuta cuando el item acaba de aumentarse (zoom) en dispositivos tactiles
  1773. if ($(item).parent()[0] && $(item).parent()[0].justZoomed) {
  1774. $(item).parent()[0].justZoomed = false
  1775. return null
  1776. }
  1777. mosaico.destroyHoverLabel(item)
  1778. var cellid = getCellID(item),
  1779. _tipo_item = cellid[0],
  1780. _id_item = cellid[1],
  1781. tipo_item = _tipo_item,
  1782. music_single,
  1783. ruta,
  1784. extraParams = {
  1785. //filtros: 'no'
  1786. }
  1787. extraParams.expandRelas = 1
  1788. jQuery.extend(extraParams, SycCredentials)
  1789. var extraData = item.className.match(/x_\w+_\w+/g)
  1790. if (extraData != null) {
  1791. $.each(extraData, function () {
  1792. var xd = this.replace("x_", "").split("_")
  1793. extraParams[xd[0]] = xd[1]
  1794. })
  1795. }
  1796. if (_extraParams) {
  1797. jQuery.extend(extraParams, _extraParams)
  1798. }
  1799. var extraParamsForBook = {}
  1800. var idTradToOpenBanner = ""
  1801. //consola([_tipo_item, _id_item, servicio]);
  1802. //Validacion login de usuario, que permite ver mi biblioteca
  1803. if (
  1804. !lectorLogueado &&
  1805. _id_item == 0 &&
  1806. (_tipo_item == 18 || _tipo_item == 27 || _tipo_item == 44)
  1807. ) {
  1808. return that.showAlertMiBiblioteca(_tipo_item)
  1809. }
  1810. if (_tipo_item == "minibookhelp") {
  1811. var helpID = cellid[1] + "_" + cellid[2]
  1812. var help = {
  1813. "18_1":
  1814. "En este espacio aparecerán los Libros que haya consultado recientemente",
  1815. "18_6":
  1816. "En este espacio aparecerán las Imágenes que haya consultado recientemente",
  1817. "18_10":
  1818. "En este espacio aparecerá la Música que haya consultado recientemente",
  1819. "18_45":
  1820. "En este espacio aparecerán las Palabras de Diccionario que haya consultado recientemente",
  1821. "18_51":
  1822. "En este espacio aparecerán los Videos que haya consultado recientemente",
  1823. "44_1":
  1824. "Para agregar a Mis Favoritos, abra un libro y pique en el ícono de la estrella",
  1825. "44_3":
  1826. "Para agregar a Mis Favoritos, consulte un autor y pique en el ícono de la estrella",
  1827. "44_6":
  1828. "Para agregar a Mis Favoritos, consulte una imagen y en modo pantalla completa pique en el ícono de la estrella",
  1829. "44_10":
  1830. "Para agregar a Mis Favoritos, consulte una pieza musical y pique en el ícono de la estrella en la parte superior izquierda del reproductor",
  1831. "44_45":
  1832. "Para agregar a Mis Favoritos, haga clic sobre una palabra, seleccione la opción diccionario y pique en el ícono de la estrella",
  1833. }
  1834. if (helpID == "mydownld_1") {
  1835. var cmdObj = { Module: "OfflineApp", Action: "ShowDocuments" }
  1836. return panelSocial.executeNative(cmdObj)
  1837. } else {
  1838. return alertLM.show(bodyDiv, help[helpID])
  1839. }
  1840. }
  1841. if (_tipo_item == "startsesion") {
  1842. panelSocial.mosaico.btnLoginClick()
  1843. return null
  1844. }
  1845. if (_tipo_item.search(/instrumentos/) > -1) {
  1846. alertLM.show(
  1847. bodyDiv,
  1848. "Esta funcionalidad estará disponible próximamente",
  1849. )
  1850. return null
  1851. }
  1852. //Protector de pantalla
  1853. if (_tipo_item == "screensaver") {
  1854. if (_id_item == "contrainteligence") {
  1855. panelSocial.screenSaver({
  1856. withFrases: true,
  1857. withMusic: true,
  1858. combinedArt: true,
  1859. })
  1860. }
  1861. if (_id_item == "photo") {
  1862. panelSocial.screenSaver({ withFoto: true })
  1863. }
  1864. if (_id_item == "photomusic") {
  1865. panelSocial.screenSaver({ withFoto: true, withMusic: true })
  1866. }
  1867. if (_id_item == "art") {
  1868. panelSocial.screenSaver({ withArt: true })
  1869. }
  1870. if (_id_item == "artmusic") {
  1871. panelSocial.screenSaver({ withArt: true, withMusic: true })
  1872. }
  1873. return null
  1874. }
  1875. //Musica aleatoria ewall
  1876. if (_tipo_item == "randommusic") {
  1877. return panelSocial.ewallMusic("MosaicBooks")
  1878. }
  1879. if (_tipo_item == "faq" || (_tipo_item == 1 && _id_item == 1565)) {
  1880. return panelSocial.mosaico.showFrequentQuestions(extraParams)
  1881. }
  1882. if (_tipo_item == "appcalifica") {
  1883. var iframeURL = "/ltotal/editor/app_califica/app_califica.jsp"
  1884. return panelSocial.createIFRAME({
  1885. hostDiv: bodyDiv,
  1886. id: "iframeAppCalifica",
  1887. url: iframeURL,
  1888. avoidFullScreen: true,
  1889. })
  1890. }
  1891. if (_tipo_item == "expoart") {
  1892. return edicion.imagenes.expoArt.showLoad(_id_item, { item: item })
  1893. }
  1894. if (_tipo_item == "nuevos") {
  1895. tipo_item = "libro"
  1896. _id_item = "6100"
  1897. }
  1898. if (_tipo_item == "infantil") {
  1899. tipo_item = "libro"
  1900. //tipo_item = "autores";
  1901. _id_item = "83"
  1902. }
  1903. if (_tipo_item == "clasico") {
  1904. //tipo_item = 'libro';
  1905. tipo_item = "autores"
  1906. _id_item = "4944"
  1907. }
  1908. if (_tipo_item == "mydownld") {
  1909. if ($(item).hasClass("format_epub")) {
  1910. var cmdObj = {
  1911. Module: "OfflineApp",
  1912. Action: "OpenDownloadedBook",
  1913. Parameters: [_id_item],
  1914. }
  1915. return panelSocial.executeNative(cmdObj)
  1916. } else {
  1917. var docID = _id_item.replace("pdf", "")
  1918. var cmdObj = {
  1919. Module: "OfflineApp",
  1920. Action: "OpenDownloadedPDFDocumento",
  1921. Parameters: [docID],
  1922. }
  1923. return panelSocial.executeNative(cmdObj)
  1924. }
  1925. }
  1926. // Libros
  1927. if (_tipo_item == 1) {
  1928. tipo_item = "libro"
  1929. if ($(item.lbl).hasClass("confrontados_0")) {
  1930. return that.openBookComparado(_id_item, -1, null)
  1931. }
  1932. //NOTA!
  1933. //Es se usa para forzar la apertura de un libro cuando el mosaico
  1934. //esta en -- servicio -- de Musica y Arte
  1935. //Estos items pueden traer codificados parametors
  1936. //extra{} en className para configurar la apertura del libro
  1937. if ($(item).hasClass("forceopen")) {
  1938. var extra = {}
  1939. var icn = item.className
  1940. var idTrad = icn.match(/idTrad_\d+/)
  1941. ? icn.match(/idTrad_\d+/)[0].match(/\d+/)[0]
  1942. : -1
  1943. return that.openBook(1, _id_item, idTrad, extra)
  1944. }
  1945. }
  1946. // Autores
  1947. if (_tipo_item == 3) {
  1948. tipo_item = "autor"
  1949. }
  1950. //Traducciones
  1951. if (_tipo_item == 4) {
  1952. var bookData = _id_item.split(",")
  1953. var openBanner = true
  1954. if (item.lbl && $(item.lbl).hasClass("txtsearch")) {
  1955. extraParamsForBook.searchWords = mosaico.getSearchTXTWords()
  1956. //Marca de color para saber que libros ya se han abierto
  1957. $(".tag_counter", item).css({
  1958. border: "#9BDB0D",
  1959. background: "linear-gradient(to bottom, #D5F788, #B3F918)",
  1960. })
  1961. if ($(item.lbl).hasClass("txtsearch_exact")) {
  1962. extraParamsForBook.txtsearch_exact = 1
  1963. }
  1964. openBanner = false
  1965. }
  1966. //Libro regalo con foto
  1967. var icn = item.className
  1968. var foto_promo = icn.match(/foto_promo_libro_\d+/)
  1969. ? icn.match(/foto_promo_libro_\d+/)[0].match(/\d+/)[0]
  1970. : -1
  1971. if (foto_promo > 0) {
  1972. extraParamsForBook.idFotoPromo = foto_promo
  1973. extraParamsForBook.numePagina = 1
  1974. openBanner = false
  1975. }
  1976. //Envio de libro regalo con mensaje institucional
  1977. var institut_promo = icn.match(/institut_promo_libro_\d+/)
  1978. ? icn.match(/institut_promo_libro_\d+/)[0].match(/\d+/)[0]
  1979. : -1
  1980. if (institut_promo > 0) {
  1981. extraParamsForBook.idInstitutPromo = institut_promo
  1982. extraParamsForBook.numePagina = 1
  1983. openBanner = false
  1984. }
  1985. //Libro regalo
  1986. var regalo_libro = icn.match(/regalo_libro_\d+/)
  1987. ? icn.match(/regalo_libro_\d+/)[0].match(/\d+/)[0]
  1988. : -1
  1989. if (regalo_libro > 0) {
  1990. extraParamsForBook.idRegalo = regalo_libro
  1991. extraParamsForBook.numePagina = 1
  1992. openBanner = false
  1993. }
  1994. if ($(item).hasClass("openbook")) {
  1995. openBanner = false
  1996. }
  1997. if (item.lbl && $(item.lbl).is(".x_tradslibro_1 ")) {
  1998. openBanner = false
  1999. }
  2000. if (openBanner) {
  2001. _id_item = bookData[0]
  2002. idTradToOpenBanner = " idTradToOpenBanner_" + bookData[1]
  2003. _tipo_item = 1
  2004. tipo_item = "libro"
  2005. item = $(item).clone()[0]
  2006. item.className = "cell 1_" + _id_item + "_" + bookData[1] + " cvLD"
  2007. }
  2008. }
  2009. //Imagen
  2010. if (_tipo_item == 6) {
  2011. var doOpenImage = true
  2012. if (_extraParams && _extraParams.queryArt) {
  2013. doOpenImage = false
  2014. }
  2015. if (doOpenImage) {
  2016. return openMosaicImage(item)
  2017. }
  2018. }
  2019. //Musica
  2020. if (_tipo_item == 10) {
  2021. music_single = $(".music_single", item)[0]
  2022. if (music_single) {
  2023. openMusic(item)
  2024. return null
  2025. }
  2026. tipo_item = "album_musica"
  2027. }
  2028. //Genero literario
  2029. if (_tipo_item == 14) {
  2030. tipo_item = "genero"
  2031. }
  2032. //Diccionarios
  2033. if (_tipo_item == 16) {
  2034. var doDiccOpen = true
  2035. if (_extraParams && _extraParams.doDiccsQuery) {
  2036. doDiccOpen = false
  2037. }
  2038. if (doDiccOpen) {
  2039. var wordDic = null
  2040. if (mosaico.getPilarSelected() == "buscar") {
  2041. wordDic = mosaico.getSearchWords()
  2042. }
  2043. if (item.lbl && $(item.lbl).hasClass("txtsearch")) {
  2044. wordDic = mosaico.getSearchTXTWords()
  2045. //Marca de color para saber que libros ya se han abierto
  2046. $(".tag_counter", item).css({
  2047. border: "#9BDB0D",
  2048. background: "linear-gradient(to bottom, #D5F788, #C4F25D)",
  2049. })
  2050. }
  2051. var classCounter = item.className.match(/counter_\d+/)
  2052. if (classCounter) {
  2053. //Abre el diccionario en la busqueda de significados
  2054. return that.openDiccTotal(null, _id_item, {
  2055. signiSearch: wordDic,
  2056. openInTab: true,
  2057. })
  2058. } else {
  2059. //Abre el diccionario el mosaico y busqueda de palabras
  2060. var diccAlfabet = wordDic ? false : true
  2061. var pubDomain = $(item).hasClass("publicDomain")
  2062. return that.openDiccTotal(wordDic, _id_item, {
  2063. openInTab: true,
  2064. diccAlfabetico: diccAlfabet,
  2065. diccSYC: $(item).hasClass("diccSYC"),
  2066. publicDomain: pubDomain,
  2067. })
  2068. }
  2069. }
  2070. }
  2071. //Filtro Autores
  2072. if (_tipo_item == 19) {
  2073. tipo_item = "autores"
  2074. }
  2075. //Filtro musica
  2076. if (_tipo_item == 20) {
  2077. tipo_item = "musica"
  2078. }
  2079. //Filtro generos
  2080. if (_tipo_item == 21) {
  2081. tipo_item = "generos"
  2082. }
  2083. //Filtro imagenes
  2084. if (_tipo_item == 22) {
  2085. tipo_item = "imagenes"
  2086. }
  2087. //Filtro audiolibros
  2088. if (_tipo_item == 23) {
  2089. tipo_item = "audiolibros"
  2090. }
  2091. //Investigaciones
  2092. if (_tipo_item == 25) {
  2093. tipo_item = "investigaciones"
  2094. }
  2095. //Filtro libros relacionados
  2096. if (_tipo_item == 26) {
  2097. tipo_item = "relacionados"
  2098. }
  2099. //Libros de investigacion
  2100. if (_tipo_item == 27) {
  2101. if ($(item).hasClass("tematico")) {
  2102. return panelSocial.openBook(27, _id_item, -1, { tematico: true })
  2103. }
  2104. if (_id_item == 0) {
  2105. return openBookNotas(27, _id_item)
  2106. }
  2107. if (item.lbl && $(item.lbl).hasClass("txtsearch")) {
  2108. //Marca de color para saber que libros ya se han abierto
  2109. $(".tag_counter", item).css({
  2110. border: "#9BDB0D",
  2111. background: "linear-gradient(to bottom, #D5F788, #C4F25D)",
  2112. })
  2113. return panelSocial.openBook(27, _id_item, -1, {
  2114. searchWords: mosaico.getSearchTXTWords(),
  2115. })
  2116. }
  2117. //Nota! Aumentar para lidiar con libros agrupadores por panel_data
  2118. }
  2119. //Items del concurso
  2120. if (_tipo_item == 31) {
  2121. var fn = concurso.clickSobreItem(_id_item)
  2122. if (fn) {
  2123. return fn()
  2124. }
  2125. //Imagen de concurso
  2126. if (/^31,\d+$/.test(_id_item)) {
  2127. return openMosaicImage(item)
  2128. }
  2129. }
  2130. //Personajes
  2131. if (_tipo_item == 32) {
  2132. if (item.lbl && $(item.lbl).hasClass("txtsearch")) {
  2133. //Marca de color para saber que libros ya se han abierto
  2134. $(".tag_counter", item).css({
  2135. border: "#9BDB0D",
  2136. background: "linear-gradient(to bottom, #D5F788, #C4F25D)",
  2137. })
  2138. return panelSocial.openBook(32, _id_item, -1, {
  2139. searchWords: mosaico.getSearchTXTWords(),
  2140. })
  2141. }
  2142. //Noticias. Editorial
  2143. //NOTA!! Este id está quemado.
  2144. //NOTA!! Generalizar por tipo_personaje -> Dato que llega al consultar la caratula en load_image.jsp
  2145. //if ( _id_item == 12 ) {
  2146. // return panelSocial.openBook(32, 12, -1, {openInIndex:true});
  2147. //}
  2148. }
  2149. //Filtro compositores musicales
  2150. if (_tipo_item == 35) {
  2151. tipo_item = "compositores"
  2152. }
  2153. //Filtro intrepretes musicales relacionados
  2154. if (_tipo_item == 36) {
  2155. tipo_item = "interpretes"
  2156. }
  2157. //Filtro generos musicales
  2158. if (_tipo_item == 37) {
  2159. tipo_item = "generos_musicales"
  2160. }
  2161. //Tecnica artistica
  2162. if (_tipo_item == 42) {
  2163. tipo_item = "generos_artisticos"
  2164. }
  2165. //Palabra diccionario
  2166. if (_tipo_item == 45) {
  2167. if (_id_item > 0) {
  2168. that.openDiccTotal(null, null, {
  2169. openInTab: true,
  2170. idWord: _id_item,
  2171. casoRela: 1,
  2172. })
  2173. } else {
  2174. var cellCoverText = $(".word_cover_text", item)
  2175. var cellWord = $.trim(cellCoverText[0].innerHTML.replace(/\s+/, " "))
  2176. that.openDiccTotal(cellWord, null, { openInTab: true, casoRela: 1 })
  2177. }
  2178. return null
  2179. }
  2180. if (_tipo_item == 51) {
  2181. if (item.lbl && $(item.lbl).hasClass("txtsearch")) {
  2182. //Marca de color para saber que los videos ya se han abierto
  2183. $(".tag_counter", item).css({
  2184. border: "#9BDB0D",
  2185. background: "linear-gradient(to bottom, #D5F788, #C4F25D)",
  2186. })
  2187. return panelSocial.openVideo(item, {
  2188. searchWords: mosaico.getSearchTXTWords(),
  2189. loadMode: "search",
  2190. })
  2191. }
  2192. }
  2193. if (_tipo_item == "misdescargas") {
  2194. return panelSocial.mosaico.downloadsMosaic()
  2195. }
  2196. var backNavig = true
  2197. if (_extraParams && _extraParams.backNavig == false) {
  2198. backNavig = false
  2199. }
  2200. var doCache = true
  2201. if (_extraParams && _extraParams.doCache == false) {
  2202. doCache = false
  2203. }
  2204. var processData = function (htmlData, mosaicTop) {
  2205. var proc = $("#proceso")
  2206. if (
  2207. typeof htmlData == "string" &&
  2208. htmlData.indexOf("txt_open_item") > -1
  2209. ) {
  2210. proc.html(htmlData)
  2211. $(".txt_open_item.txt_libro", proc).each(function () {
  2212. var bd = this.value.split(",")
  2213. var idLibro = bd[0]
  2214. var idTrad = bd[1]
  2215. var nPag = parseInt(bd[2])
  2216. var fecha = $.trim(bd[5])
  2217. var nPagPercent = parseFloat(bd[6])
  2218. if (nPag > 1) {
  2219. if (nPag == 2) {
  2220. nPag = 3
  2221. }
  2222. extraParams.numePagina = nPag
  2223. }
  2224. if (fecha.length > 0) {
  2225. extraParams.fechaVisto = fecha
  2226. }
  2227. if (nPagPercent > 0) {
  2228. extraParams.numePaginaPercent = nPagPercent
  2229. }
  2230. jQuery.extend(extraParams, extraParamsForBook)
  2231. that.openBook(1, idLibro, idTrad, extraParams)
  2232. })
  2233. $(".txt_open_item.txt_id_proyecto", proc).each(function () {
  2234. panelSocial.openBookNotas(27, _id_item)
  2235. })
  2236. } else {
  2237. var proc = $("#proceso").html(htmlData)
  2238. panelSocial.mosaico.LPWrapItems(proc[0].children)
  2239. var labels = $(".cell_label", proc)
  2240. labels.each(function () {
  2241. var lbl = this
  2242. var items = $(lbl).nextUntil(".cell_label")
  2243. items.each(function () {
  2244. this.lbl = lbl
  2245. })
  2246. lbl.items = items
  2247. items.detach()
  2248. if (items.length > 30) {
  2249. lbl.fullItems = items
  2250. lbl.items = items.slice(0, 30)
  2251. }
  2252. $(lbl).after(lbl.items)
  2253. })
  2254. mosaico.createMosaic2(proc[0].children, servicio, item, mosaicTop, {
  2255. backNav: backNavig,
  2256. saveCache: doCache,
  2257. })
  2258. ltotalOS.timeStats({ sumSegs: 3 })
  2259. }
  2260. }
  2261. var cache = mosaico.getMosaicCache(mosaico.getPilarSelected(), item)
  2262. if (cache) {
  2263. var html = cache[0]
  2264. var mosaicTop = 0
  2265. mosaico.createMosaic2(html, servicio, item, mosaicTop, {
  2266. backNav: backNavig,
  2267. saveCache: doCache,
  2268. })
  2269. } else {
  2270. //Consulta el servidor
  2271. //Previene multiples clicks consultando
  2272. try {
  2273. var xhr = ltotalOS.loadData(
  2274. servicio,
  2275. tipo_item,
  2276. _id_item,
  2277. extraParams,
  2278. )
  2279. if (xhr) {
  2280. that.createLoaderItem(item, xhr, null)
  2281. xhr.done(function (htmlData) {
  2282. if (
  2283. (_tipo_item == 1 && servicio == "libros") ||
  2284. _tipo_item == 3 ||
  2285. _tipo_item == 17 ||
  2286. _tipo_item == 27 ||
  2287. _tipo_item == 32 ||
  2288. _tipo_item == 51
  2289. ) {
  2290. var doBanner = true
  2291. if (_extraParams && _extraParams.noBanner) {
  2292. doBanner = false
  2293. }
  2294. var idBanner = _tipo_item + "_" + _id_item
  2295. var bannerExc = {
  2296. "3_0,1,0": 1,
  2297. "3_0,6,0": 1,
  2298. "3_0,10,0": 1,
  2299. "3_0,13,0": 1,
  2300. "51_0": 1,
  2301. "3_-1": 1,
  2302. }
  2303. if (bannerExc[idBanner]) {
  2304. doBanner = false
  2305. }
  2306. if (doBanner) {
  2307. htmlData =
  2308. '<div class="cell_label banner_label start_visible counter_1"><div class="tag_label">&nbsp;</div></div><div class="caratula_banner banner_ficha_item ' +
  2309. idBanner +
  2310. idTradToOpenBanner +
  2311. '"></div>' +
  2312. htmlData
  2313. }
  2314. }
  2315. processData(htmlData, 0)
  2316. })
  2317. }
  2318. return xhr
  2319. } catch (e) {}
  2320. }
  2321. }
  2322. this.createLoaderItem = function (_item, _xhr, _extra) {
  2323. //Cargando...
  2324. var loader = null
  2325. var timerLoader = setTimeout(function () {
  2326. loader = new PanelSOCIALLoaderItem()
  2327. $(_item).append(loader.getContain())
  2328. }, 500)
  2329. var removeLoader = function () {
  2330. if (loader) {
  2331. loader.destroy()
  2332. }
  2333. }
  2334. var timerRemoveLoader = setTimeout(function () {
  2335. removeLoader()
  2336. if (_extra && _extra.timeOutFN) {
  2337. _extra.timeOutFN()
  2338. }
  2339. }, 13000)
  2340. _xhr.done(function () {
  2341. clearTimeout(timerLoader)
  2342. clearTimeout(timerRemoveLoader)
  2343. removeLoader()
  2344. })
  2345. }
  2346. this.getRangeSelectionData = function () {
  2347. var sel = rangy.getSelection()
  2348. var selInfo = {
  2349. anchorNode: sel.anchorNode,
  2350. anchorOffset: sel.anchorOffset,
  2351. focusNode: sel.focusNode,
  2352. focusOffset: sel.focusOffset,
  2353. isBackwards: sel.isBackwards(),
  2354. }
  2355. return selInfo
  2356. }
  2357. this.getSelectionText = function () {
  2358. //Seleccion de texto
  2359. var text = ""
  2360. if (window.getSelection) {
  2361. text = window.getSelection().toString()
  2362. } else if (document.selection && document.selection.type != "Control") {
  2363. text = document.selection.createRange().text
  2364. }
  2365. return $.trim(text)
  2366. }
  2367. this.showContextualMenu = function (_ev, _container, _cnf) {
  2368. //Lanza herramientas: diccionario, crear notas, subrayar, subir datos relacionados con texto
  2369. //NOTA! _config podria traer lista de botones preconfigurados por el cliente
  2370. //con lista de {"buttonLabel", "buttonFunc"}
  2371. var emptyMenu = function () {
  2372. panelSocial.closeContextualMenu()
  2373. }
  2374. if (!contextualMenu) {
  2375. contextualMenu = document.createElement("div")
  2376. contextualMenu.className = "contextualMenu"
  2377. }
  2378. emptyMenu()
  2379. var text = that.getSelectionText()
  2380. var selData = that.getRangeSelectionData()
  2381. if (text.length > 0) {
  2382. $(_container).append(contextualMenu)
  2383. //Botones del menu
  2384. /*if (executeNative) {
  2385. //Copiar nativo
  2386. ltotalUtils.loadScript(getContextoEstaticos()+'/js/ltotal/clipboard.min.js');
  2387. var btnCopy = document.createElement('div');
  2388. btnCopy.className = 'menuBtn';
  2389. $(btnCopy).attr('data-clipboard-text', text);
  2390. $(btnCopy).text('Copiar');
  2391. btnCopy.onclick = function() {
  2392. if (!clipboard) {
  2393. clipboard = new Clipboard('.menuBtn');
  2394. clipboard.on('success', function(e) {
  2395. e.clearSelection();
  2396. });
  2397. clipboard.on('error', function(e) {});
  2398. }
  2399. emptyMenu();
  2400. };
  2401. $(contextualMenu).append(btnCopy);
  2402. }*/
  2403. //Diccionario
  2404. var btnDicc = document.createElement("div")
  2405. btnDicc.className = "menuBtn"
  2406. $(btnDicc).text("Diccionario")
  2407. btnDicc.onclick = function () {
  2408. var hayMosaico = $(_container).parents(
  2409. ".boxMosaic, .boxMosaicFull",
  2410. )[0]
  2411. ? true
  2412. : false
  2413. var idDicc = _cnf && _cnf.idDicc ? _cnf.idDicc : null
  2414. panelSocial.openDiccTotal(text, idDicc, {
  2415. openInTab: hayMosaico ? true : false,
  2416. })
  2417. emptyMenu()
  2418. }
  2419. $(contextualMenu).append(btnDicc)
  2420. if (_cnf) {
  2421. //Configuracion del item sobre el que sale el menu contextual
  2422. var ti = _cnf.tipoItem
  2423. var ii = _cnf.idItem
  2424. var ii2 = _cnf.idItem2
  2425. var npi = _cnf.npagItem
  2426. var ini = _cnf.idNotaItem
  2427. var mi = _cnf.modoItem
  2428. var isLectorAutorLibro = _cnf.isLectorAutorLibro
  2429. var modoLectura = mi == 1 || (ti == 27 && mi == 2)
  2430. var hayEditorLlector =
  2431. typeof llector !== "undefined" && llector.theresEditor
  2432. var hayEditorFisher =
  2433. typeof fisher !== "undefined" && fisher.theresEditor
  2434. if (_cnf.showInsertInNote && (hayEditorLlector || hayEditorFisher)) {
  2435. //Poner el boton de 'Insertar en nota'
  2436. var btnNota = document.createElement("div")
  2437. btnNota.className = "menuBtn"
  2438. $(btnNota).text("Insertar en nota")
  2439. btnNota.onclick = function () {
  2440. llector.applyCredits(null, null)
  2441. emptyMenu()
  2442. }
  2443. $(contextualMenu).append(btnNota)
  2444. }
  2445. if (modoLectura) {
  2446. var extra = {
  2447. position: 3,
  2448. tipoItemRela: ti,
  2449. idItemRela: ii,
  2450. idItem2Rela: ii2,
  2451. npagItemRela: npi,
  2452. idNotaRela: ini,
  2453. txtRela: text,
  2454. idProy: 0,
  2455. toBook: true,
  2456. }
  2457. if (isSmartPhone) {
  2458. extra.position = 4
  2459. }
  2460. var esLibroLectura = ii > 0 && ti == 1 && npi > -1
  2461. var esAnotador = ltotalUtils.checkPermiso("anotador")
  2462. var esPersonaje = ltotalUtils.checkPermiso(
  2463. "personaje,personaje_limitado",
  2464. )
  2465. var esAutorLibro = esLibroLectura && ltotalUtils.checkAutorLibro(ii)
  2466. var esPrivadoLibro =
  2467. esLibroLectura && ltotalUtils.checkPrivadoLibro(ii)
  2468. if (ti == 1 && mi == 1 && npi != 2) {
  2469. //Compartir frase
  2470. var btnShare = document.createElement("div")
  2471. btnShare.className = "menuBtn"
  2472. var btnShareTxt = npi == 1 ? "Compartir libro" : "Compartir cita"
  2473. $(btnShare).text(btnShareTxt)
  2474. btnShare.onclick = function () {
  2475. panelSocial.selectedBook.sharePageTxt(_cnf, selData)
  2476. emptyMenu()
  2477. }
  2478. $(contextualMenu).append(btnShare)
  2479. }
  2480. if (!hayEditorLlector && esLibroLectura) {
  2481. //Nota
  2482. var btnNota = document.createElement("div")
  2483. btnNota.className = "menuBtn"
  2484. // $(btnNota).text("Nota");
  2485. $(btnNota).text("🐵Patch")
  2486. btnNota.onclick = function () {
  2487. if (lectorLogueado) {
  2488. panelSocial.editNote(17, 0, extra)
  2489. } else {
  2490. panelSocial.showAlertMiBiblioteca(27)
  2491. }
  2492. emptyMenu()
  2493. }
  2494. $(contextualMenu).append(btnNota)
  2495. }
  2496. //NOTA!!
  2497. //Futuro: este boton podra ser usado por los grupos de edicion
  2498. if (
  2499. esLibroLectura &&
  2500. !hayEditorLlector &&
  2501. (esAnotador || esAutorLibro || esPrivadoLibro)
  2502. ) {
  2503. //Nota de edicion (correccion)
  2504. var btnNota = document.createElement("div")
  2505. btnNota.className = "menuBtn"
  2506. $(btnNota).text("Nota edición")
  2507. btnNota.onclick = function () {
  2508. extra.correccionEdicion = true
  2509. panelSocial.editNote(17, 0, extra)
  2510. emptyMenu()
  2511. }
  2512. $(contextualMenu).append(btnNota)
  2513. }
  2514. if (
  2515. !hayEditorFisher &&
  2516. esPersonaje &&
  2517. ii > 0 &&
  2518. (ti == 1 || ti == 27) &&
  2519. npi > -1
  2520. ) {
  2521. //Pescar
  2522. var btnPescar = document.createElement("div")
  2523. btnPescar.className = "menuBtn"
  2524. $(btnPescar).text("Pescar")
  2525. btnPescar.onclick = function () {
  2526. panelSocial.editNote(15, 0, extra)
  2527. emptyMenu()
  2528. }
  2529. $(contextualMenu).append(btnPescar)
  2530. }
  2531. if (
  2532. esAnotador &&
  2533. ii > 0 &&
  2534. (ti == 1 || ti == 27 || ti == 32) &&
  2535. npi > -1
  2536. ) {
  2537. //Imagen
  2538. var btnImagen = document.createElement("div")
  2539. btnImagen.className = "menuBtn"
  2540. $(btnImagen).text("Subir Imagen")
  2541. btnImagen.onclick = function () {
  2542. edicion.imagenes.showLoad(0)
  2543. emptyMenu()
  2544. }
  2545. $(contextualMenu).append(btnImagen)
  2546. }
  2547. if ((esAnotador || isLectorAutorLibro) && ti == 1 && ii > 0) {
  2548. //Comentario
  2549. var btnComentario = document.createElement("div")
  2550. btnComentario.className = "menuBtn"
  2551. $(btnComentario).text("Subir Comentario")
  2552. btnComentario.onclick = function () {
  2553. edicion.comentarios.showLoad(0)
  2554. emptyMenu()
  2555. }
  2556. $(contextualMenu).append(btnComentario)
  2557. }
  2558. /*
  2559. //NOTA!! Se desactivan temporalmente los "Proyectos Tematicos"
  2560. //Mientras se define su futuro
  2561. if (lectorLogueado && lectorLogueado.proyectosTematicos > 0 && ti == 1) {
  2562. //Proyectos de investigacion tematicos (Tipo 1)
  2563. var btnProysTemas = document.createElement("div");
  2564. btnProysTemas.className = "menuBtn";
  2565. $(btnProysTemas).text("Investigación temática");
  2566. btnProysTemas.onclick = function() {
  2567. llector.grupos.dialogProyectsTematicos();
  2568. emptyMenu();
  2569. }
  2570. $(contextualMenu).append(btnProysTemas);
  2571. }
  2572. */
  2573. }
  2574. _cnf.txtRela = text
  2575. }
  2576. //FIN. Botones del menu
  2577. that.placeContextualMenu(_container)
  2578. $(_container).trigger("panelSocial.showContextualMenu", _cnf)
  2579. }
  2580. }
  2581. this.closeContextualMenu = function () {
  2582. $(contextualMenu).css({ width: "auto" })
  2583. $(contextualMenu).detach()
  2584. $(contextualMenu).empty()
  2585. }
  2586. this.showAlertMiBiblioteca = function (_tipoItem) {
  2587. var st = {
  2588. 18: "Mi historial",
  2589. 27: "Mis notas",
  2590. 44: "Mis favoritos",
  2591. 48: "Mis marcadores",
  2592. }
  2593. $(".boxAlert", alertLM.getContain()).css({
  2594. left: "25%",
  2595. width: "50%",
  2596. top: "15%",
  2597. height: "70%",
  2598. "max-height": "inherit",
  2599. margin: "unset",
  2600. "border-radius": "15px",
  2601. padding: "unset",
  2602. })
  2603. $(".boxTxtAlert", alertLM.getContain()).css({ top: "10%", height: "80%" })
  2604. $(".boxButtons", alertLM.getContain()).css({
  2605. position: "absolute",
  2606. top: "15px",
  2607. left: "0%",
  2608. height: "24px",
  2609. "margin-top": "unset",
  2610. "border-top": "unset",
  2611. })
  2612. $(".btnCloseAlert", alertLM.getContain())
  2613. .css({
  2614. position: "absolute",
  2615. top: "0px",
  2616. width: "24px",
  2617. left: "unset",
  2618. height: "100%",
  2619. right: "10px",
  2620. margin: "unset",
  2621. bottom: "unset",
  2622. "background-image":
  2623. "url(/estaticosED/files/img/book_icons/black/close.png)",
  2624. "background-size": "80%",
  2625. "background-position": "center",
  2626. "background-repeat": "no-repeat",
  2627. })
  2628. .html("")
  2629. if (isTouch) {
  2630. $(".boxAlert", alertLM.getContain()).css({
  2631. top: "0%",
  2632. left: "0%",
  2633. width: "100%",
  2634. height: "100%",
  2635. "border-radius": "0px",
  2636. })
  2637. $(".boxTxtAlert", alertLM.getContain()).css({
  2638. top: "15%",
  2639. left: "5%",
  2640. width: "90%",
  2641. height: "85%",
  2642. margin: "unset ",
  2643. })
  2644. }
  2645. alertLM.show(
  2646. bodyDiv,
  2647. '<div class="boxAlrtMiBib">Para utilizar el servicio de <span style="color: #0873F5;">' +
  2648. st[_tipoItem] +
  2649. ",</span> debe crear una cuenta gratis como lector. Si ya la tiene, por favor inicie sesión.</div><div onclick=\"$('.btnCloseAlert', alertLM.getContain()).trigger('click'); panelSocial.mosaico.btnLoginClick();\" class=\"miBibliIniSesion\">Iniciar sesión</div> <div onclick=\"$('.btnCloseAlert', alertLM.getContain()).trigger('click'); panelSocial.mosaico.btnRegisterClick();\" class=\"miBibliRegister\">Crear cuenta</div>",
  2650. )
  2651. }
  2652. this.placeContextualMenu = function (_container) {
  2653. var s = rangy.getSelection()
  2654. var rectRange = s.getRangeAt(0).nativeRange.getBoundingClientRect()
  2655. var rectCont = _container.getBoundingClientRect()
  2656. var btnColors = [
  2657. "#5483CE",
  2658. "#D75F53",
  2659. "#38C06E",
  2660. "#BD8C50",
  2661. "#9873B8",
  2662. "#74CECB",
  2663. ]
  2664. var icol = 0
  2665. var ww = 0
  2666. $(contextualMenu)
  2667. .children()
  2668. .each(function () {
  2669. var nc = $(this).text().length
  2670. var px = nc < 8 ? 12 : 8
  2671. var wx = nc * px
  2672. $(this).css({ width: wx + "px" })
  2673. ww +=
  2674. wx +
  2675. parseInt($(this).css("margin-left")) +
  2676. parseInt($(this).css("padding-left")) * 2
  2677. var triangle = $('<div class="triangle_up"></div>')
  2678. $(this).append(triangle)
  2679. triangle.css({ "border-bottom": "5px solid " + btnColors[icol] })
  2680. $(this).css({ "background-color": btnColors[icol] })
  2681. icol++
  2682. if (icol == btnColors.length) {
  2683. icol = 0
  2684. }
  2685. })
  2686. ww += 10
  2687. $(contextualMenu).css({ width: ww + "px" })
  2688. var left = rectRange.left - rectCont.left - ww / 2 + rectRange.width / 2
  2689. var top = rectRange.top - rectCont.top + rectRange.height + 2
  2690. //Corrige salida por izquierda
  2691. if (left < 0) {
  2692. left = 0
  2693. }
  2694. //Corrige salida por derecha
  2695. var rPoint = left + ww
  2696. if (rPoint > rectCont.width) {
  2697. left = rectCont.width - ww - 10
  2698. }
  2699. $(contextualMenu).css({ left: left + "px", top: top + "px" })
  2700. if (ww > _container.offsetWidth) {
  2701. var btns = $(contextualMenu).children()
  2702. $(contextualMenu).css({ width: "100%", left: "0px" })
  2703. var btns_wrapper = $('<div class="btns_wrapper"></div>')
  2704. $(contextualMenu).append(btns_wrapper)
  2705. btns_wrapper.append(btns)
  2706. btns_wrapper.css({
  2707. position: "relative",
  2708. width: ww + "px",
  2709. height: "100%",
  2710. })
  2711. if (!contextualMenu.touchBinded) {
  2712. contextualMenu.touchBinded = true
  2713. var bindTouchHandleHorizontal = function (_objScroll) {
  2714. return {
  2715. move: function (dX, dY, ev) {
  2716. ev.stopPropagation()
  2717. _objScroll.scrollLeft += dX
  2718. },
  2719. }
  2720. }
  2721. bindTouch(contextualMenu, bindTouchHandleHorizontal(contextualMenu))
  2722. }
  2723. }
  2724. }
  2725. this.getContain = function () {
  2726. return this.mainFrame
  2727. }
  2728. //Abrir reproductor de music
  2729. function openMusic(musicItem, _extra) {
  2730. var dataMusic = null
  2731. var setRutas = false
  2732. if (typeof musicItem == "object") {
  2733. var label = musicItem.lbl
  2734. var idsMusic = []
  2735. buscaIDS(label.items, 10, idsMusic)
  2736. //Reproduce item de musica actual
  2737. var music_single = $(".music_single", musicItem)[0]
  2738. var ruta = $(music_single).attr("ruta")
  2739. //ReplaceList temporal app nativa para evitar error mientras carga dataMusic
  2740. var author = $(musicItem)
  2741. .attr("label_autor")
  2742. .replace(/("|'){1,}/g, "")
  2743. var title = $(".dvd_text", musicItem)
  2744. .text()
  2745. .replace(/("|'){1,}/g, "")
  2746. dataMusic = [{ Author: author, Title: title }]
  2747. setRutas = true
  2748. }
  2749. if (typeof musicItem == "string") {
  2750. var ruta = musicItem
  2751. var idMusica = ruta.match(/\d+\.mp3/)[0].match(/\d+/)[0]
  2752. var idsMusic = [idMusica]
  2753. musicItem = null
  2754. dataMusic = [{ Author: "...", Title: "..." }]
  2755. setRutas = true
  2756. }
  2757. initPanelMusic()
  2758. var rutaR = ruta.replace("|HLS", "")
  2759. if (rutaR == panelMusic.getRutaAudio()) {
  2760. if (panelMusic.isPlayingMusic()) {
  2761. panelMusic.stopAudio()
  2762. } else {
  2763. panelMusic.startAudio()
  2764. }
  2765. } else {
  2766. panelMusic.resetIdx()
  2767. panelMusic.idRecRelaSkip = null
  2768. if (_extra && _extra.idRecRelaSkip) {
  2769. panelMusic.idRecRelaSkip = _extra.idRecRelaSkip
  2770. }
  2771. panelMusic.shouldShowInfoMusic = true
  2772. panelMusic.playAudio(ruta, musicItem)
  2773. if (setRutas) {
  2774. //ReplaceList temporal app nativa para evitar error mientras carga dataMusic
  2775. panelMusic.setAudios([ruta], { dataMusic: dataMusic })
  2776. }
  2777. //Incluye musica en lo visto recientemente
  2778. if (lectorLogueado) {
  2779. var idMusic = panelMusic.getIdAudio(ruta)
  2780. mosaico.saveBitacora(10, -1, -1, -1, idMusic, "", null)
  2781. }
  2782. if (setRutas) {
  2783. that.setRutasMusic(ruta, idsMusic)
  2784. }
  2785. }
  2786. panelMusic.isPlayingEwallMusic = false
  2787. }
  2788. this.openMusic = function (musicItem, _extra) {
  2789. openMusic(musicItem, _extra)
  2790. }
  2791. this.setRutasMusic = function (ruta, idsMusic) {
  2792. idsMusic = $.trim(idsMusic)
  2793. if (idsMusic.length == 0) {
  2794. return null
  2795. }
  2796. //Consulta rutas de lista de ids de musica
  2797. ltotalOS
  2798. .loadData("musica", "rutas", idsMusic, { hls: true })
  2799. .done(function (htmlData) {
  2800. var p = $("#proceso").html(htmlData)
  2801. var rutas = $("#txt_rutas", p).val().split(",")
  2802. var dataMusic = JSON.parse($("#dataMusic", p).val())
  2803. var idx = 0
  2804. //Calcula numero de pista (idx)
  2805. for (var i = 0; i < rutas.length; i++) {
  2806. if (ruta == rutas[i]) {
  2807. idx = i
  2808. break
  2809. }
  2810. }
  2811. panelMusic.setAudios(rutas, { dataMusic: dataMusic })
  2812. panelMusic.setIdx(idx)
  2813. })
  2814. }
  2815. this.stopMusic = function () {
  2816. panelMusic.stopAudio()
  2817. }
  2818. this.openMusicByID = function (idMusic, _extra) {
  2819. ltotalOS
  2820. .loadData("musica", "rutas", idMusic, "")
  2821. .done(function (htmlData) {
  2822. var p = $("#proceso").html(htmlData)
  2823. var ruta = $("#txt_rutas", p).val().split(",")[0]
  2824. var isCollection = $("#isCollection", p).val() == "true"
  2825. if (isCollection) {
  2826. var item = document.createElement("div")
  2827. item.className = "cell 10_" + idMusic + " cvLD"
  2828. item.style.display = "inline-block"
  2829. var sb = panelSocial.selectedBook
  2830. if (sb) {
  2831. sb.cerrar()
  2832. }
  2833. panelSocial
  2834. .clickSobreItem(item, "musica", panelSocial.mosaico)
  2835. .done(function () {
  2836. setTimeout(function () {
  2837. $(".cell.cvLD").eq(0).trigger("click")
  2838. if (_extra && _extra.stopMusic) {
  2839. panelSocial.stopMusic()
  2840. }
  2841. }, 1000)
  2842. })
  2843. } else {
  2844. panelSocial.openMusic(ruta)
  2845. if (_extra && _extra.stopMusic) {
  2846. panelSocial.stopMusic()
  2847. }
  2848. }
  2849. })
  2850. }
  2851. this.decodeMosaicLink = function (link) {
  2852. var lObj = {
  2853. tipoItem: -1,
  2854. idItem: -1,
  2855. dataLink: [],
  2856. extraClass: "",
  2857. tipoPatron: 0,
  2858. }
  2859. var ptrnNN = link.match(/^\w+(_-?\w+)+$/)
  2860. if (ptrnNN) {
  2861. lObj.dataLink = link.split("_")
  2862. lObj.tipoItem = lObj.dataLink[0]
  2863. lObj.idItem = lObj.dataLink[1]
  2864. lObj.tipoPatron = 1
  2865. }
  2866. var ptrnComplex = link.split("__")
  2867. if (ptrnComplex.length > 1) {
  2868. lObj.extraClass = link.replace(/__/g, " ")
  2869. lObj.dataLink = lObj.extraClass.match(/^\d+_-?\d+/)[0].split("_")
  2870. lObj.tipoItem = lObj.dataLink[0]
  2871. lObj.idItem = lObj.dataLink[1]
  2872. lObj.extraClass =
  2873. $.trim(lObj.extraClass.replace(/^\d+_-?\d+/, "")) +
  2874. " x_extralabels_1 x_startvisible_1"
  2875. lObj.tipoPatron = 2
  2876. }
  2877. return lObj
  2878. }
  2879. this.openMosaicLink = function (link, _extra) {
  2880. var mosa = panelSocial.mosaico
  2881. if (_extra && _extra.mosaic) {
  2882. mosa = _extra.mosaic
  2883. }
  2884. var linkObj = panelSocial.decodeMosaicLink(link)
  2885. var tipoItem = linkObj.tipoItem
  2886. var idItem = linkObj.idItem
  2887. var extraClass = linkObj.extraClass
  2888. var dataLink = linkObj.dataLink
  2889. var tipoPatron = linkObj.tipoPatron
  2890. var extraParams = {}
  2891. if (tipoPatron == 2) {
  2892. extraParams.noBanner = true
  2893. }
  2894. if (_extra) {
  2895. if (_extra.noBanner) {
  2896. extraParams.noBanner = true
  2897. }
  2898. if (_extra.backNavig == false) {
  2899. extraParams.backNavig = false
  2900. }
  2901. if (_extra.doCache == false) {
  2902. extraParams.doCache = false
  2903. }
  2904. }
  2905. if (tipoItem == -1) {
  2906. consola("No se puede procesar la direccion: " + link)
  2907. return null
  2908. }
  2909. if (tipoItem == 1) {
  2910. var item = document.createElement("div")
  2911. item.className = "cell 1_" + idItem + " " + extraClass
  2912. if (tipoPatron == 1 && dataLink.length > 3) {
  2913. item.className = "cell 4_" + idItem + "," + dataLink[2] + " openbook"
  2914. extraParams.numePagina = dataLink[3]
  2915. }
  2916. panelSocial.clickSobreItem(item, "libros", mosa, extraParams)
  2917. }
  2918. if (tipoItem == 3) {
  2919. idItem = link.replace(/^3_/, "").replace(/_/g, ",")
  2920. if (extraClass.length == 0) {
  2921. extraClass = "x_extralabels_1"
  2922. }
  2923. var item = document.createElement("div")
  2924. item.className = "cell 3_" + idItem + " " + extraClass
  2925. panelSocial.clickSobreItem(item, "libros", mosa, extraParams)
  2926. }
  2927. if (tipoItem == 4) {
  2928. var coord1 = dataLink.slice(4, 7).join(",")
  2929. var coord2 = dataLink.slice(7, 10).join(",")
  2930. extraParams.numePagina = parseInt(dataLink[3])
  2931. extraParams.txtCoord = coord1 + "_" + coord2
  2932. panelSocial.openBook(1, idItem, dataLink[2], extraParams)
  2933. }
  2934. if (tipoItem == 6) {
  2935. panelSocial.processIdsImages([idItem], idItem)
  2936. }
  2937. if (tipoItem == 8) {
  2938. idItem = link.replace(/^8_/, "").replace("_", ",")
  2939. var item = document.createElement("div")
  2940. item.className = "cell 8_" + idItem + " " + extraClass
  2941. panelSocial.clickSobreItem(item, "libros", mosa, extraParams)
  2942. }
  2943. if (tipoItem == 10) {
  2944. panelSocial.openMusicByID(idItem)
  2945. }
  2946. if (tipoItem == 14) {
  2947. var item = document.createElement("div")
  2948. item.className = "cell 14_" + idItem + " " + extraClass
  2949. panelSocial.clickSobreItem(item, "libros", mosa, extraParams)
  2950. }
  2951. if (tipoItem == 15) {
  2952. panelSocial.openBookPersoByIDRec(idItem)
  2953. }
  2954. if (tipoItem == 16) {
  2955. if (idItem == 0) {
  2956. var item = document.createElement("div")
  2957. item.className = "cell diccionarios_0 x_extralabels_1"
  2958. panelSocial.clickSobreItem(item, "libros", mosa, extraParams)
  2959. }
  2960. if (idItem > 0) {
  2961. panelSocial.openDiccTotal(null, null, {
  2962. idWord: idItem,
  2963. casoRela: 1,
  2964. openInTab: true,
  2965. })
  2966. }
  2967. }
  2968. if (tipoItem == 23) {
  2969. var item = document.createElement("div")
  2970. item.className = "cell 23_" + idItem + " " + extraClass
  2971. panelSocial.clickSobreItem(item, "libros", mosa, extraParams)
  2972. }
  2973. if (tipoItem == 24) {
  2974. var item = document.createElement("div")
  2975. item.className = "cell 24_" + idItem + " " + extraClass
  2976. panelSocial.clickSobreItem(item, "libros", mosa, extraParams)
  2977. }
  2978. if (tipoItem == 32) {
  2979. panelSocial.openBookNotas(32, idItem)
  2980. }
  2981. if (tipoItem == 38) {
  2982. var item = document.createElement("div")
  2983. item.className = "cell 38_" + idItem + " " + extraClass
  2984. panelSocial.clickSobreItem(item, "libros", mosa, extraParams)
  2985. }
  2986. if (tipoItem == 47) {
  2987. idItem = link.replace(/^47_/, "").replace(/_/g, ",")
  2988. var item = document.createElement("div")
  2989. item.className = "cell 47_" + idItem + " " + extraClass
  2990. panelSocial.clickSobreItem(item, "libros", mosa, extraParams)
  2991. }
  2992. if (tipoItem == 50) {
  2993. var item = document.createElement("div")
  2994. item.className = "cell 50_" + idItem + " " + extraClass
  2995. panelSocial.clickSobreItem(item, "libros", mosa, extraParams)
  2996. }
  2997. if (tipoItem == 51) {
  2998. var item = document.createElement("div")
  2999. item.className = "cell 51_" + idItem + " " + extraClass
  3000. panelSocial.clickSobreItem(item, "libros", mosa, extraParams)
  3001. }
  3002. if (tipoItem == "scrns") {
  3003. panelSocial.screenSaverPrevStep(idItem)
  3004. }
  3005. /*
  3006. if (tipoItem == 'foto') {
  3007. var item = document.createElement('div');
  3008. item.className = 'cell 6_0,2 cvLD';
  3009. panelSocial.clickSobreItem(item, 'libros', mosa, {"extra_labels":1, "noBanner":true, "fotografia":1, "queryArt":1});
  3010. }
  3011. */
  3012. }
  3013. this.showBookRelatedContent = function (idLibro) {
  3014. var url = "/ltotal/inicio/utils/ut_50.jsp"
  3015. panelSocial.doPost(url, { idLibro: idLibro }).done(function (_d) {
  3016. var proc = $("#proceso").html(_d)
  3017. var relatedItems = proc.children()
  3018. var modal = that.openModalTxtViewer(relatedItems, {})
  3019. var toolsTop = $(".toolsTop", modal.getContain())
  3020. toolsTop
  3021. .prepend(
  3022. '</div><div class="title_container">Contenidos relacionados</div>',
  3023. )
  3024. .css({ "margin-top": "14px" })
  3025. var cont = modal.getContain()
  3026. var $cont = $(cont)
  3027. $cont.addClass("book_html_related_content")
  3028. $cont.css({ "background-color": "#0B1C2B" })
  3029. if (isTouch) {
  3030. $cont.css({ height: "100%", width: "100%", top: 0, left: 0 })
  3031. } else {
  3032. $cont.css({
  3033. width: "80%",
  3034. left: "10%",
  3035. height: "70%",
  3036. top: "15%",
  3037. "border-radius": "15px",
  3038. })
  3039. }
  3040. var floatContent = $(".contentHtml", cont)
  3041. floatContent.css({
  3042. width: "90%",
  3043. "margin-left": "5%",
  3044. "margin-top": "2px",
  3045. })
  3046. if (isTouch) {
  3047. floatContent.css({
  3048. width: "100%",
  3049. "margin-left": 0,
  3050. height: "94%",
  3051. "margin-top": "30px",
  3052. })
  3053. }
  3054. var floatClose = $(".closeModalViewer", cont)
  3055. floatClose.css({ right: "10px", "background-position": "-110px 0" })
  3056. $(".boxScroll", cont).remove()
  3057. relatedItems.each(function () {
  3058. this.onclick = function () {
  3059. var itemData = this.className.split(/\s+/)[1].split(/_/)
  3060. var item = document.createElement("div")
  3061. item.className =
  3062. "cell " +
  3063. itemData[1] +
  3064. "_" +
  3065. itemData[2] +
  3066. " cvLD x_" +
  3067. itemData[5] +
  3068. "_1"
  3069. var labels = { extra_labels: 1, noBanner: true, startvisible: 1 }
  3070. labels[itemData[5]] = 1
  3071. panelSocial.clickSobreItem(
  3072. item,
  3073. "libros",
  3074. panelSocial.mosaico,
  3075. labels,
  3076. )
  3077. modal.cerrar()
  3078. }
  3079. })
  3080. })
  3081. }
  3082. this.openModalTxtViewer = function (_html, _setts) {
  3083. var modalConfig = {
  3084. hostDiv: bodyDiv,
  3085. widthV: "30%",
  3086. heightV: "auto",
  3087. bgColor: "rgb(245, 239, 220)",
  3088. scrollSyc: true,
  3089. claseScroll: "scrollModalNotas",
  3090. clickClose: function () {
  3091. if (that.isContainMusicInFloatTextViewer()) {
  3092. if (panelMusic.inBigEwall) {
  3093. panelMusic.cerrarInBigEwall()
  3094. return null
  3095. }
  3096. panelMusic.resetearAudio()
  3097. }
  3098. floatTextViewer = null
  3099. if (_setts && _setts.fnAfterClose) {
  3100. _setts.fnAfterClose()
  3101. }
  3102. },
  3103. }
  3104. $.extend(modalConfig, _setts)
  3105. if (floatTextViewer) {
  3106. floatTextViewer.destroy()
  3107. }
  3108. floatTextViewer = new ModalViewerLT(modalConfig)
  3109. floatTextViewer.addContent(_html)
  3110. if (isSmartPhone) {
  3111. $(floatTextViewer.getContain()).css({
  3112. width: "100%",
  3113. left: "0",
  3114. top: "0",
  3115. right: "",
  3116. height: "100%",
  3117. "border-radius": "0",
  3118. border: "none",
  3119. })
  3120. }
  3121. return floatTextViewer
  3122. }
  3123. function initPanelMusic() {
  3124. if (!panelMusic) {
  3125. panelMusic = new PanelMusic({
  3126. hostDiv: panelSocial.bodyDiv,
  3127. appendMode: "append",
  3128. musicaElement: elementoAudio,
  3129. loadedMusic: function (_idMusic) {
  3130. //Estadistica de musica en interfaz eDesk
  3131. ltotalOS.statistics(87, _idMusic)
  3132. },
  3133. minimizarModalViewer: function () {
  3134. if (floatTextViewer) {
  3135. that.closeMasInfoItem()
  3136. }
  3137. },
  3138. })
  3139. }
  3140. }
  3141. this.getPanelMusic = function () {
  3142. initPanelMusic()
  3143. return panelMusic
  3144. }
  3145. this.openBookPersoByIDRec = function (_idRec) {
  3146. var url = "/ltotal/inicio/utils/ut_48.jsp"
  3147. var params = { caso: "2", id_nota: _idRec }
  3148. return panelSocial.doPost(url, params).done(function (_d) {
  3149. var proc = $("#proceso").html(_d)
  3150. var id_proy = parseInt($(".hdn_id_perso", proc).val())
  3151. panelSocial
  3152. .getSeccionLibroByIDNota(32, id_proy, _idRec)
  3153. .then(function (_nsec) {
  3154. panelSocial.openBook(32, id_proy, -1, { numeSeccion: _nsec })
  3155. })
  3156. })
  3157. }
  3158. function openBookNotas(_tipoLibro, _id_item) {
  3159. llector.loadColors()
  3160. if (lectorLogueado) {
  3161. var s = ""
  3162. if (_tipoLibro == 17) {
  3163. s = "notas"
  3164. }
  3165. if (_tipoLibro == 27) {
  3166. s = "proyectos"
  3167. }
  3168. if (_tipoLibro == 32) {
  3169. s = "personajes"
  3170. }
  3171. var extraParams = SycCredentials
  3172. ltotalOS
  3173. .loadData(s, "lec_bitac", _id_item, extraParams)
  3174. .done(function (_d) {
  3175. _d = $.trim(_d)
  3176. if (_d.length > 0) {
  3177. var proc = $("#proceso").html(_d)
  3178. _d = $(".lec_bitac", proc).val().split(",")
  3179. var idNote = _d[0]
  3180. var npag = _d[1]
  3181. var fecha = _d[2]
  3182. var numePagePercent = _d[3]
  3183. if (_tipoLibro == 17) {
  3184. var extra = {
  3185. numeSeccion: 1,
  3186. fechaVisto: fecha,
  3187. numePaginaSeccion: npag,
  3188. numePaginaPercent: numePagePercent,
  3189. }
  3190. that.openBook(17, _id_item, -1, extra)
  3191. } else {
  3192. that
  3193. .getSeccionLibroByIDNota(_tipoLibro, _id_item, idNote)
  3194. .then(function (_nsec) {
  3195. var extra = {
  3196. numeSeccion: _nsec,
  3197. fechaVisto: fecha,
  3198. }
  3199. if (_tipoLibro == 27 || _tipoLibro == 32) {
  3200. extra.numePaginaSeccion = npag
  3201. extra.numePaginaPercent = numePagePercent
  3202. }
  3203. that.openBook(_tipoLibro, _id_item, -1, extra)
  3204. })
  3205. }
  3206. } else {
  3207. that.openBook(_tipoLibro, _id_item, -1)
  3208. }
  3209. })
  3210. } else {
  3211. that.openBook(_tipoLibro, _id_item, -1)
  3212. }
  3213. }
  3214. this.openBookNotas = function (_tipoLibro, _id_item) {
  3215. openBookNotas(_tipoLibro, _id_item)
  3216. }
  3217. this.getSeccionLibroByIDNota = function (_tipoLibro, _idLibro, _idNote) {
  3218. var extraParams = {
  3219. tipoLibro: _tipoLibro,
  3220. modoLibro: 0,
  3221. }
  3222. jQuery.extend(extraParams, SycCredentials)
  3223. //Consulta del indice del libro
  3224. var classNote = ""
  3225. if (_tipoLibro == 27) {
  3226. classNote = ".id_nota_" + _idNote
  3227. }
  3228. if (_tipoLibro == 32) {
  3229. classNote = ".id_rec_" + _idNote
  3230. }
  3231. return ltotalOS
  3232. .loadData("libros", "paginas", _idLibro + "," + -1, extraParams)
  3233. .then(function (_d) {
  3234. //Obtiene el numero de seccion
  3235. var numSecc = -1
  3236. var items = $.parseHTML(_d)[0]
  3237. var item = $(classNote, items)[0]
  3238. if (item) {
  3239. numSecc = item.className.match(/nsec_\d+/)[0].split("_")[1]
  3240. }
  3241. return numSecc
  3242. })
  3243. }
  3244. this.init = function (opts) {}
  3245. this.setBackgroundColor = function (color) {}
  3246. this.stopAudio = function () {
  3247. if ($(playerMusic).hasClass("pauseBtn")) {
  3248. panelMusic.stopAudio()
  3249. } else {
  3250. panelMusic.startAudio()
  3251. }
  3252. }
  3253. this.ewallMusic = function (_callerID) {
  3254. initPanelMusic()
  3255. var goAndPlay = function () {
  3256. panelMusic.resetIdx()
  3257. panelMusic.shouldShowInfoMusic = false
  3258. panelMusic.playAudio(audiosEwall[0])
  3259. panelMusic.setAudios(audiosEwall, { dataMusic: dataMusicEwall })
  3260. panelMusic.isPlayingEwallMusic = true
  3261. }
  3262. var checkAndGo = function () {
  3263. if (!executeNative) {
  3264. //Activa el audio con un silencio (iOS)
  3265. elementoAudio.pause()
  3266. elementoAudio.src = "/testLtotal/recursos/silence1sg.mp3"
  3267. elementoAudio.play()
  3268. }
  3269. ltotalUtils.initEwallAudios().done(goAndPlay)
  3270. }
  3271. if (!panelMusic.getContain().parentNode) {
  3272. panelMusic.minimizedMode()
  3273. panelMusic.placeContainer()
  3274. }
  3275. if (_callerID == "MiniIconMusic" || _callerID == "MosaicBooks") {
  3276. if (panelMusic.isPlayingEwallMusic) {
  3277. if (panelMusic.isPlayingMusic()) {
  3278. panelMusic.stopAudio()
  3279. } else {
  3280. panelMusic.startAudio()
  3281. }
  3282. } else {
  3283. checkAndGo()
  3284. }
  3285. }
  3286. if (_callerID == "ScreenSaver") {
  3287. if (!panelMusic.isPlayingMusic()) {
  3288. checkAndGo()
  3289. }
  3290. }
  3291. }
  3292. this.screenSaver = function (_opts) {
  3293. var withMusic = false
  3294. var extraParams = ""
  3295. if (_opts) {
  3296. if (_opts.withMusic) {
  3297. withMusic = true
  3298. }
  3299. if (_opts.withFoto) {
  3300. extraParams += "&artMode=NatureArt"
  3301. }
  3302. if (_opts.withArt) {
  3303. extraParams += "&artMode=PureArt"
  3304. }
  3305. if (_opts.combinedArt) {
  3306. extraParams += "&artMode=CombinedArt"
  3307. }
  3308. if (_opts.withFrases) {
  3309. extraParams += "&withFrases=1"
  3310. }
  3311. if (_opts.autorArt) {
  3312. extraParams += "&artMode=AutorArt&idAutorArt=" + _opts.idAutorArt
  3313. }
  3314. if (_opts.bookArtText) {
  3315. extraParams +=
  3316. "&artMode=BookArtText&tipoBookArtText=" +
  3317. _opts.tipoBookArtText +
  3318. "&idBookArtText=" +
  3319. _opts.idBookArtText
  3320. }
  3321. if (_opts.arteAnotado) {
  3322. extraParams += "&artMode=ArteAnotado"
  3323. }
  3324. if (_opts.idListaExpo) {
  3325. extraParams += "&id_lista=" + _opts.idListaExpo
  3326. }
  3327. }
  3328. var iframeURL =
  3329. "/ltotal/big_ewall/index.html?p=1&calcAspectRatio=1" + extraParams
  3330. panelSocial.createIFRAME({
  3331. hostDiv: bodyDiv,
  3332. id: "iframeArte",
  3333. url: iframeURL,
  3334. close: function () {
  3335. panelSocial.cancelFullscreen()
  3336. if (withMusic && panelMusic) {
  3337. //Reversa los cambios hechos al contenedor de musica en el show big_ewall
  3338. var musCont = $(panelMusic.getContain())
  3339. musCont.css({ display: "" })
  3340. musCont.css({ "z-index": "" })
  3341. panelMusic.inBigEwall = false
  3342. panelMusic.cerrar()
  3343. }
  3344. },
  3345. })
  3346. if (withMusic) {
  3347. panelSocial.ewallMusic("ScreenSaver")
  3348. }
  3349. panelSocial.setNativeMainViewBGColor(0, 0, 0)
  3350. }
  3351. this.screenSaverPrevStep = function (_idItem) {
  3352. var html =
  3353. '\
  3354. <p style="margin-top:30px; text-align:center;">Contrainteligencia artificial</p>\
  3355. <p style="margin-top:30px;">El azar es el enemigo de la inteligencia artificial, ahora en la biblioteca del libro total ponemos a disposición de los lectores una nueva oferta de Contrainteligencia Artificial, una mezcla irrepetible de música, fotografía, arte y frases célebres.</p>\
  3356. <div class="btn_play" style="margin:30px auto 0 auto; width:100%; height:46px; border-radius:23px; text-align:center; line-height:46px; color:white; background-color:#0873F5;">Reproducir</div>\
  3357. '
  3358. var veil = document.createElement("div")
  3359. $(veil).css({
  3360. position: "absolute",
  3361. width: "100%",
  3362. height: "100%",
  3363. top: 0,
  3364. left: 0,
  3365. "background-color": "rgba(0, 0, 0, 0.7)",
  3366. })
  3367. $(bodyDiv).append(veil)
  3368. var sets = {
  3369. scrollSyc: false,
  3370. fnAfterClose: function () {
  3371. $(veil).remove()
  3372. },
  3373. }
  3374. var modal = panelSocial.openModalTxtViewer(html, sets)
  3375. var cont = modal.getContain()
  3376. var $cont = $(cont)
  3377. var $content = $(".contentHtml", cont)
  3378. $cont.css({ "background-color": "white" })
  3379. $content.css({ cursor: "pointer" })
  3380. if (!isSmartPhone) {
  3381. var lft = ($(window).width() - 400) / 2
  3382. var top = ($(window).height() - 500) / 2
  3383. $cont.css({
  3384. width: "400px",
  3385. height: "500px",
  3386. left: lft + "px",
  3387. top: top + "px",
  3388. })
  3389. }
  3390. $content[0].onclick = function () {
  3391. var item = document.createElement("div")
  3392. item.className = "cell screensaver_" + _idItem
  3393. panelSocial.clickSobreItem(item, "libros", panelSocial.mosaico, {})
  3394. modal.cerrar()
  3395. $(veil).remove()
  3396. }
  3397. }
  3398. this.show = function () {
  3399. mosaico.show()
  3400. }
  3401. this.hide = function () {
  3402. mosaico.hide()
  3403. }
  3404. this.getIDCliente = function () {
  3405. return idCliente
  3406. }
  3407. this.executeNative = function (_cmdObj) {
  3408. try {
  3409. return ltotalUtils.executeNative(_cmdObj)
  3410. } catch (e) {
  3411. return false
  3412. }
  3413. }
  3414. this.nativeMessage = function (_msg) {
  3415. //Aqui van los objetos que necesitan los mensajes nativos
  3416. if (panelMusic) {
  3417. panelMusic.nativeMessage(_msg)
  3418. }
  3419. if (typeof globito !== "undefined") {
  3420. globito.nativeMessage(_msg)
  3421. }
  3422. var modulo = _msg.Module
  3423. var action = _msg.Action
  3424. if (modulo == "KeyChain" && action == "Retrieve") {
  3425. var correo = _msg.UserName
  3426. var clave = _msg.Password
  3427. isLogged(correo, clave)
  3428. }
  3429. if (modulo == "App" && action == "Orientation") {
  3430. var rs = _msg.ResultString.toLowerCase()
  3431. if (
  3432. (rs.indexOf("portrait") > -1 || rs.indexOf("landscape") > -1) &&
  3433. rs != orientationNative
  3434. ) {
  3435. orientationNative = rs
  3436. setTimeout(panelSocial.mosaico.rePaint, 300)
  3437. }
  3438. }
  3439. if (modulo == "App" && action == "AndroidBack") {
  3440. if (!panelSocial.mosaico.getBackNavigation()) {
  3441. panelSocial.moveTaskToBackApp()
  3442. }
  3443. }
  3444. if (modulo == "Connectivity") {
  3445. if (action == "OnCurrentConnectivityChanged") {
  3446. ltotalOS.isConnected =
  3447. _msg.IsConnected.toLowerCase() == "true" ? true : false
  3448. }
  3449. }
  3450. if (modulo == "OfflineApp" && action == "RepaintFluid") {
  3451. panelSocial.mosaico.repaintFluid()
  3452. }
  3453. if (modulo == "Consola") {
  3454. consola(action)
  3455. }
  3456. }
  3457. this.capabilitiesCallback = function (_msg) {
  3458. this.nativeCapabilitiesTxt = _msg
  3459. }
  3460. this.shareCallback = function (_msg) {}
  3461. this.moveTaskToBackApp = function () {
  3462. if (executeNative) {
  3463. var cmdObj = { Module: "App", Action: "MoveTaskToBackApp" }
  3464. var cmdNat = that.executeNative(cmdObj)
  3465. }
  3466. }
  3467. this.showDownloads = function () {
  3468. //var cmdObj = { 'Module': 'OfflineApp', 'Action': 'ShowDownloads' };
  3469. //that.executeNative(cmdObj);
  3470. panelSocial.mosaico.downloadsMosaic()
  3471. }
  3472. this.downloadedEpubCallback = function (_msg) {
  3473. mosaicBanner.paintOfflineBook(parseInt(JSON.parse(_msg).status))
  3474. }
  3475. this.isThisADownloadedBook = function (_idTrad) {
  3476. if (executeNative) {
  3477. var cmdObj = {
  3478. Module: "OfflineApp",
  3479. Action: "FindEpub",
  3480. Parameters: ["" + _idTrad],
  3481. Callback: "panelSocial.downloadedEpubCallback",
  3482. }
  3483. var cmdNat = panelSocial.executeNative(cmdObj)
  3484. }
  3485. }
  3486. this.hasOfflineBooks = function () {
  3487. return (
  3488. executeNative &&
  3489. panelSocial.nativeCapabilitiesTxt.indexOf("OfflineApp") > -1
  3490. )
  3491. }
  3492. this.offLineAppContentRelated = function (_msg) {
  3493. var msgObj = JSON.parse(_msg)
  3494. panelSocial.mosaico.resetCache()
  3495. panelSocial.mosaico.resetBackNavigation()
  3496. if (msgObj.related_type == "book") {
  3497. panelSocial.openMosaicLink(msgObj.id_item, {
  3498. noBanner: true,
  3499. backNavig: false,
  3500. doCache: false,
  3501. })
  3502. }
  3503. if (msgObj.related_type == "search") {
  3504. panelSocial.mosaico.buscarLT(msgObj.id_item, { backNavig: false })
  3505. }
  3506. }
  3507. this.offLineAppDictionary = function (_msg) {
  3508. var msgObj = JSON.parse(_msg)
  3509. panelSocial.openDiccTotal(msgObj.word, null, {
  3510. openInTab: true,
  3511. fromOffLineApp: true,
  3512. })
  3513. }
  3514. this.getLaunchCounter = function () {
  3515. if (executeNative) {
  3516. var cmdObj = {
  3517. Module: "App",
  3518. Action: "GetLaunchCounter",
  3519. Callback: "panelSocial.getLaunchCounterCallback",
  3520. }
  3521. var cmdNat = that.executeNative(cmdObj)
  3522. }
  3523. }
  3524. this.getLaunchCounterCallback = function (_msg) {
  3525. var cb = JSON.parse(_msg)
  3526. var lCounter = parseInt(cb.launchCounter)
  3527. if (lCounter == 1) {
  3528. panelSocial.mosaico.showAyuda()
  3529. }
  3530. if (lCounter == 4) {
  3531. panelSocial.mosaico.showRatingApp()
  3532. }
  3533. }
  3534. this.destroyShareModal = function () {
  3535. if (shareGiftAdmObject && shareGiftAdmObject.getModalViewer()) {
  3536. shareGiftAdmObject.getModalViewer().destroy()
  3537. shareGiftAdmObject = null
  3538. }
  3539. }
  3540. this.clearAudioData = function (_boxComponent) {
  3541. if ($(_boxComponent).hasClass("boxViewerTXT")) {
  3542. $(_boxComponent)[0].that.clearAudioData()
  3543. }
  3544. }
  3545. //Deteccion de la seleccion de texto
  3546. this.checkSelection = function (_ev) {
  3547. var sel = rangy.getSelection()
  3548. var nodo = sel.focusNode
  3549. if (nodo && $(nodo.parentNode).hasClass("menuBtn")) {
  3550. //Para que se puede ejecutar la funcion del boton
  3551. return null
  3552. }
  3553. var container = $(nodo).parents(".selecTXT")[0]
  3554. if (container) {
  3555. container.selecTXTFunc(_ev)
  3556. } else {
  3557. setTimeout(panelSocial.closeContextualMenu, 200)
  3558. }
  3559. }
  3560. this.setNativeMainViewBGColor = function (r, g, b) {
  3561. if (
  3562. executeNative &&
  3563. panelSocial.nativeCapabilitiesTxt.indexOf("SetMainViewBGColor") > -1
  3564. ) {
  3565. var cmdObj = {
  3566. Module: "App",
  3567. Action: "SetMainViewBGColor",
  3568. Parameters: [r + "", g + "", b + ""],
  3569. }
  3570. var cmdNat = panelSocial.executeNative(cmdObj)
  3571. }
  3572. }
  3573. this.saveNativeCredentials = function (correo, clave) {
  3574. if (executeNativeCredentials) {
  3575. correo = correo.toLowerCase()
  3576. clave = clave.replace(/"/g, '\\"')
  3577. var cmdObj = {
  3578. Module: "KeyChain",
  3579. Action: "Update",
  3580. Parameters: ["", correo, clave],
  3581. }
  3582. var cmdNat = panelSocial.executeNative(cmdObj)
  3583. }
  3584. }
  3585. this.getNativeCredentials = function () {
  3586. if (executeNativeCredentials) {
  3587. var cmdObj = { Module: "KeyChain", Action: "Retrieve" }
  3588. var cmdNat = that.executeNative(cmdObj)
  3589. }
  3590. }
  3591. this.deleteNativeCredentials = function () {
  3592. if (executeNativeCredentials) {
  3593. var cmdObj = { Module: "KeyChain", Action: "Delete" }
  3594. var cmdNat = that.executeNative(cmdObj)
  3595. }
  3596. }
  3597. this.getNativeOrientation = function () {
  3598. return orientationNative
  3599. }
  3600. var isLogged = function (correo, clave) {
  3601. var moreParams = {}
  3602. if (correo && clave) {
  3603. moreParams.correo = encodeURIComponent(correo)
  3604. moreParams.clave = encodeURIComponent(clave)
  3605. }
  3606. SycCredentials = {
  3607. ku: $("#Valor2").val(),
  3608. ki: $("#Valor1").val(),
  3609. kp: $("#Valor3").val(),
  3610. }
  3611. var loginParams = jQuery.extend(moreParams, SycCredentials)
  3612. ltotalOS.isLogged(loginParams).done(function (_lec) {
  3613. if (_lec) {
  3614. lectorLogueado = _lec
  3615. that.textZoomVal = ltotalOS.getPreferenciaLector("textZoomVal", 1)
  3616. that.textColor = ltotalOS.getPreferenciaLector("textColor", "clear")
  3617. that.tipoLetra = ltotalOS.getPreferenciaLector("tipoLetra", 1)
  3618. that.mosaicSize = ltotalOS.getPreferenciaLector("mosaicSize", 0)
  3619. //Restablece tamano de texto
  3620. if (that.textZoomVal != 1) {
  3621. var zoomOff = parseFloat((that.textZoomVal - 1).toFixed(1))
  3622. that.textZoomVal = 1
  3623. setTimeout(function () {
  3624. that.zoomText(zoomOff, false)
  3625. }, 300)
  3626. }
  3627. } else {
  3628. //Inicia el zoom y el alto de linea
  3629. setTimeout(function () {
  3630. that.zoomText(-0.1, false)
  3631. that.zoomText(0.1, false)
  3632. }, 300)
  3633. }
  3634. loginReady = true
  3635. })
  3636. }
  3637. //Detecta capacidades nativas
  3638. if (executeNative) {
  3639. var cmdObj = {
  3640. Module: "App",
  3641. Action: "Capabilities",
  3642. Callback: "panelSocial.capabilitiesCallback",
  3643. }
  3644. var cmdNat = that.executeNative(cmdObj)
  3645. }
  3646. var ev = isTouch ? "selectionchange" : "mouseup"
  3647. document.addEventListener(ev, that.checkSelection, false)
  3648. }
  3649. function MosaicBooks(opts) {
  3650. //'use strict';
  3651. var pilarSelected,
  3652. txtPilarArte,
  3653. txtPilarMusica,
  3654. txtPilarLibros,
  3655. pilarSearch,
  3656. pilarArte,
  3657. pilarMusica,
  3658. pilarLibros,
  3659. iconSearch,
  3660. iconSearchClose,
  3661. searchLT,
  3662. boxSearchMsg,
  3663. boxSearchMos,
  3664. boxSearchClean,
  3665. buttonSearch,
  3666. servicio,
  3667. boxBottomFooter,
  3668. boxTopHeader,
  3669. boxBread,
  3670. boxPilars,
  3671. boxLogo,
  3672. boxTabs,
  3673. gridBoxSmall,
  3674. userMosaic,
  3675. closeMosaic,
  3676. backMosaic,
  3677. gridBox,
  3678. boxMosaic,
  3679. boxMosaicFull,
  3680. proceso,
  3681. boxHoverLabelMosaic,
  3682. btnHoverEraseBitac,
  3683. btnHoverEraseFavorite,
  3684. btnHoverEraseFotoPromoLibro,
  3685. btnHoverEraseRegaloLibro,
  3686. boxMenu,
  3687. categsMenuBox,
  3688. boxBtnRegister,
  3689. boxBtnLogin,
  3690. boxBtnMyAccount,
  3691. boxBtnConfig,
  3692. boxBtnContacto,
  3693. boxBtnCrearNota,
  3694. boxBtnMisNotas,
  3695. boxBtnFavoritos,
  3696. boxBtnHistorial,
  3697. boxBtnAyuda,
  3698. boxBtnFreqQuestions,
  3699. boxBtnDescargas,
  3700. footerBtnHome,
  3701. footerBtnDescargas,
  3702. footerBtnGuia,
  3703. footerBtnBiblio,
  3704. bodyDiv = panelSocial.bodyDiv,
  3705. mosaico = this,
  3706. that = this,
  3707. settings = $.extend({}, opts)
  3708. var timerDestroyHoverLabel,
  3709. timerTouchingItem,
  3710. isTouchingItem = false
  3711. var timerAnimBanner = null
  3712. var itemsToLoad = []
  3713. var labelJustClicked = false
  3714. var isSmartPhone = ltotalOS.isSmartPhone
  3715. var isTablet = ltotalOS.isTablet
  3716. var isTouch = isSmartPhone || isTablet
  3717. var platf = navigator.userAgent.toLowerCase()
  3718. var executeNative = panelSocial.executeNative("TEST")
  3719. var executeNativePlatform = panelSocial.executeNative("PLATFORM")
  3720. var tabManager = null
  3721. var searchWords = ""
  3722. var searchTXTWords = ""
  3723. var loginAttempts = 0
  3724. var mosaicCache = [],
  3725. mosaicNavigation = [],
  3726. lastPilarItemSelected,
  3727. lastServiceSelected,
  3728. lastItemSelected
  3729. this.mainFrame = document.createElement("div")
  3730. this.mainFrame.setAttribute("class", "containMosaic active")
  3731. $(panelSocial.bodyDiv).click(function (ev) {
  3732. if (
  3733. !$(ev.target).is(
  3734. ".boxMenu, .categsMenuBox, .userMosaic, .boxMenuButton, .boxMenuLabel, .boxMenuIcon, .categsMenuScrollPart",
  3735. )
  3736. ) {
  3737. hideMenu()
  3738. hideCategsMenu()
  3739. }
  3740. })
  3741. proceso = document.createElement("div")
  3742. proceso.setAttribute("class", "proceso")
  3743. $(proceso).css("display", "none")
  3744. $(that.mainFrame).append(proceso)
  3745. boxMosaic = document.createElement("div")
  3746. boxMosaic.setAttribute("class", "boxMosaic")
  3747. $(this.mainFrame).append(boxMosaic)
  3748. gridBox = document.createElement("div")
  3749. gridBox.setAttribute("class", "gridBox")
  3750. $(boxMosaic).append(gridBox)
  3751. backMosaic = document.createElement("div")
  3752. backMosaic.setAttribute("class", "backMosaic")
  3753. backMosaic.onclick = function () {
  3754. that.getBackNavigation()
  3755. }
  3756. closeMosaic = document.createElement("div")
  3757. closeMosaic.setAttribute("class", "closeMosaic")
  3758. closeMosaic.onclick = function () {
  3759. that.cerrar()
  3760. }
  3761. $(this.mainFrame).fadeTo(250, 1)
  3762. function goHome() {
  3763. that.clickSobrePilar("libros")
  3764. if (executeNative) {
  3765. var cmdObj = { Module: "OfflineApp", Action: "GoHome" }
  3766. var cmdNat = panelSocial.executeNative(cmdObj)
  3767. }
  3768. }
  3769. function detectDeviceResolution() {
  3770. var rsnClass = ltotalOS.detectDeviceResolution()
  3771. isSmartPhone = ltotalOS.isSmartPhone
  3772. isTablet = ltotalOS.isTablet
  3773. isTouch = isSmartPhone || isTablet
  3774. panelSocial.setTabletVars()
  3775. removeClassRegex(/ltr_[a-z]*/g, document.body)
  3776. removeClassRegex(/ltr_[a-z]*/g, panelSocial.bodyDiv)
  3777. removeClassRegex(/ltr_[a-z]*/g, that.mainFrame)
  3778. removeClassRegex(/ltr_[a-z]*/g, boxMosaic)
  3779. $(document.body).addClass(rsnClass)
  3780. $(panelSocial.bodyDiv).addClass(rsnClass)
  3781. $(that.mainFrame).addClass(rsnClass)
  3782. $(boxMosaic).addClass(rsnClass)
  3783. }
  3784. function generateMenus() {
  3785. if (!settings.modePilars) {
  3786. return null
  3787. }
  3788. $([boxTopHeader, boxBottomFooter]).remove()
  3789. $(boxBread).remove()
  3790. $(boxPilars).remove()
  3791. boxTopHeader = document.createElement("div")
  3792. boxTopHeader.setAttribute("class", "boxTopHeader")
  3793. boxBread = document.createElement("div")
  3794. boxBread.setAttribute("class", "boxBread")
  3795. $(that.mainFrame).prepend(boxBread)
  3796. boxPilars = document.createElement("div")
  3797. boxPilars.setAttribute("class", "boxPilars")
  3798. boxLogo = document.createElement("div")
  3799. boxLogo.setAttribute("class", "boxLogo")
  3800. if (!boxTabs) {
  3801. $(boxTabs).remove()
  3802. boxTabs = document.createElement("div")
  3803. boxTabs.setAttribute("class", "boxTabs")
  3804. $(boxBread).after(boxTabs)
  3805. }
  3806. //Libros
  3807. pilarLibros = document.createElement("div")
  3808. pilarLibros.setAttribute(
  3809. "class",
  3810. "pilarlibros pilarBtn pilarlibros_0 t_item_1",
  3811. )
  3812. pilarLibros.pilarID = "pilarlibros_0"
  3813. txtPilarLibros = document.createElement("div")
  3814. txtPilarLibros.setAttribute("class", "txtPilarLibros txtpilar")
  3815. txtPilarLibros.innerHTML = "LIBROS"
  3816. $(pilarLibros).append(txtPilarLibros)
  3817. //Musica
  3818. pilarMusica = document.createElement("div")
  3819. pilarMusica.setAttribute(
  3820. "class",
  3821. "pilarmusica pilarBtn pilarmusica_0 t_item_10",
  3822. )
  3823. pilarMusica.pilarID = "pilarmusica_0"
  3824. txtPilarMusica = document.createElement("div")
  3825. txtPilarMusica.setAttribute("class", "txtPilarmusica txtpilar")
  3826. txtPilarMusica.innerHTML = "MÚSICA"
  3827. $(pilarMusica).append(txtPilarMusica)
  3828. //Arte
  3829. pilarArte = document.createElement("div")
  3830. pilarArte.setAttribute("class", "pilararte pilarBtn pilararte_0 t_item_6")
  3831. pilarArte.pilarID = "pilararte_0"
  3832. txtPilarArte = document.createElement("div")
  3833. txtPilarArte.setAttribute("class", "txtPilarArte txtpilar")
  3834. txtPilarArte.innerHTML = "ARTE"
  3835. $(pilarArte).append(txtPilarArte)
  3836. //Buscar
  3837. pilarSearch = document.createElement("div")
  3838. pilarSearch.setAttribute(
  3839. "class",
  3840. "pilarSearch pilarbuscar pilarBtn pilarSearch_0",
  3841. )
  3842. pilarSearch.pilarID = "pilarSearch_0"
  3843. if (isTouch) {
  3844. //Input del buscador
  3845. if (!searchLT) {
  3846. searchLT = document.createElement("input")
  3847. searchLT.setAttribute("placeholder", "Expresión a buscar")
  3848. iconSearch = document.createElement("div")
  3849. }
  3850. $(pilarSearch).append(iconSearch)
  3851. } else {
  3852. searchLT = document.createElement("input")
  3853. searchLT.setAttribute("placeholder", "BUSCAR")
  3854. iconSearch = document.createElement("div")
  3855. makeRoundButton(pilarSearch)
  3856. $(".squared", pilarSearch).append([searchLT, iconSearch])
  3857. }
  3858. searchLT.setAttribute("type", "text")
  3859. searchLT.setAttribute("class", "searchLT")
  3860. iconSearch.setAttribute("class", "iconSearch")
  3861. //Mensaje de resultados de busqueda
  3862. $(boxSearchMsg).remove()
  3863. boxSearchMsg = document.createElement("div")
  3864. boxSearchMsg.setAttribute("class", "boxSearchMsg")
  3865. $(boxTabs).after(boxSearchMsg)
  3866. //Menu de opciones
  3867. userMosaic = document.createElement("div")
  3868. userMosaic.setAttribute("class", "userMosaic")
  3869. userMosaic.addEventListener(
  3870. isTouch && !ltotalOS.forcedTabletMode ? "touchstart" : "click",
  3871. function (_ev) {
  3872. _ev.stopPropagation()
  3873. hideCategsMenu()
  3874. $(boxMenu).css({ "z-index": "1" })
  3875. $(boxMenu).slideToggle()
  3876. },
  3877. false,
  3878. )
  3879. //Caja del menu
  3880. $(boxMenu).remove()
  3881. boxMenu = document.createElement("div")
  3882. boxMenu.className = "boxMenu"
  3883. $(boxMenu).css({ display: "none" })
  3884. $(that.mainFrame).append(boxMenu)
  3885. //Registrate
  3886. boxBtnRegister = document.createElement("div")
  3887. boxBtnRegister.className = "boxMenuButton loginShowReg boxBtnRegister"
  3888. boxBtnRegister.innerHTML =
  3889. '<div class="boxMenuIcon regist"></div><div class="boxMenuLabel">Crear cuenta</div>'
  3890. boxBtnRegister.addEventListener(
  3891. isTouch && !ltotalOS.forcedTabletMode ? "touchstart" : "click",
  3892. that.btnRegisterClick,
  3893. false,
  3894. )
  3895. //Recuadro para mostar los libros a pantalla completa
  3896. if (!boxMosaicFull) {
  3897. boxMosaicFull = document.createElement("div")
  3898. boxMosaicFull.setAttribute("class", "boxMosaicFull")
  3899. $(boxMosaicFull).css({ display: "none" })
  3900. $(bodyDiv).append(boxMosaicFull)
  3901. }
  3902. //Ordena los pilares y menu
  3903. if (isSmartPhone || isTablet) {
  3904. $(userMosaic).css({ display: "" })
  3905. $(boxBread).append([
  3906. userMosaic,
  3907. boxLogo,
  3908. backMosaic,
  3909. pilarSearch,
  3910. closeMosaic,
  3911. ])
  3912. $(boxMosaic).after(boxTopHeader)
  3913. $(boxTopHeader).append([boxBread, boxPilars])
  3914. $(boxPilars).append([pilarLibros, pilarMusica, pilarArte])
  3915. $(boxMosaic).after(boxSearchMsg)
  3916. //Caja del buscador
  3917. if (!boxSearchMos) {
  3918. boxSearchMos = document.createElement("div")
  3919. boxSearchMos.setAttribute("class", "boxSearchMos")
  3920. iconSearchClose = document.createElement("div")
  3921. iconSearchClose.setAttribute("class", "iconSearchClose")
  3922. iconSearchClose.onclick = deActivateSearch
  3923. buttonSearch = document.createElement("div")
  3924. buttonSearch.setAttribute("class", "buttonSearch")
  3925. $(boxSearchMos).append(buttonSearch)
  3926. buttonSearch.onclick = buscarLT
  3927. boxSearchClean = document.createElement("div")
  3928. boxSearchClean.setAttribute("class", "boxSearchClean")
  3929. $(boxSearchMos).append(boxSearchClean)
  3930. boxSearchClean.onclick = function (_ev) {
  3931. _ev.stopPropagation()
  3932. $(".autocomplete-suggestions").hide()
  3933. $(searchLT).val("")
  3934. }
  3935. $(boxSearchMos).append(searchLT)
  3936. $(boxSearchMos).append(iconSearchClose)
  3937. $(that.mainFrame).append(boxSearchMos)
  3938. }
  3939. } else {
  3940. $(".suggest_home_box").remove()
  3941. $(".autocomplete-suggestions").remove()
  3942. $(boxSearchMsg).css({ "margin-top": "10px" })
  3943. closeMosaic.innerHTML = "SALIR"
  3944. makeRoundButton(userMosaic)
  3945. $(".squared", userMosaic)[0].innerHTML = "MENÚ"
  3946. $(boxBread).append([
  3947. boxLogo,
  3948. userMosaic,
  3949. backMosaic,
  3950. pilarLibros,
  3951. pilarMusica,
  3952. pilarArte,
  3953. pilarSearch,
  3954. closeMosaic,
  3955. ])
  3956. }
  3957. if (settings.withLogin) {
  3958. //Boton de Login
  3959. boxBtnLogin = document.createElement("div")
  3960. boxBtnLogin.className = "boxMenuButton boxBtnLogin"
  3961. boxBtnLogin.addEventListener(
  3962. isTouch && !ltotalOS.forcedTabletMode ? "touchstart" : "click",
  3963. that.btnLoginClick,
  3964. false,
  3965. )
  3966. $(boxMenu).append(boxBtnLogin)
  3967. }
  3968. //Mis Favoritos
  3969. boxBtnFavoritos = document.createElement("div")
  3970. boxBtnFavoritos.innerHTML =
  3971. '<div class="boxMenuIcon fav"></div><div class="boxMenuLabel">Mis favoritos</div>'
  3972. boxBtnFavoritos.className = "boxMenuButton boxBtnFavoritos"
  3973. boxBtnFavoritos.onclick = function () {
  3974. hideMenu()
  3975. var item = document.createElement("div")
  3976. item.className = "cell 44_0 cvLD"
  3977. panelSocial.clickSobreItem(item, "libros", that)
  3978. }
  3979. //Mis Descargas
  3980. boxBtnDescargas = document.createElement("div")
  3981. boxBtnDescargas.innerHTML =
  3982. '<div class="boxMenuIcon download"></div><div class="boxMenuLabel">Mis descargas</div>'
  3983. boxBtnDescargas.className = "boxMenuButton boxBtnDescargas"
  3984. boxBtnDescargas.onclick = function () {
  3985. hideMenu()
  3986. panelSocial.showDownloads()
  3987. }
  3988. //Mis Historial
  3989. boxBtnHistorial = document.createElement("div")
  3990. boxBtnHistorial.innerHTML =
  3991. '<div class="boxMenuIcon hist"></div><div class="boxMenuLabel">Mi historial</div>'
  3992. boxBtnHistorial.className = "boxMenuButton boxBtnHistorial"
  3993. boxBtnHistorial.onclick = function () {
  3994. hideMenu()
  3995. var item = document.createElement("div")
  3996. item.className = "cell 18_0 cvLD"
  3997. panelSocial.clickSobreItem(item, "libros", that)
  3998. }
  3999. //Crear Nota
  4000. boxBtnCrearNota = document.createElement("div")
  4001. boxBtnCrearNota.innerHTML =
  4002. '<div class="boxMenuIcon newnote"></div><div class="boxMenuLabel">Crear nota</div>'
  4003. boxBtnCrearNota.className = "boxMenuButton boxBtnCrearNota"
  4004. boxBtnCrearNota.onclick = function () {
  4005. hideMenu()
  4006. var extra = { idProy: 0, toBook: false }
  4007. panelSocial.editNote(17, 0, extra)
  4008. }
  4009. //Mis Notas
  4010. boxBtnMisNotas = document.createElement("div")
  4011. boxBtnMisNotas.innerHTML =
  4012. '<div class="boxMenuIcon notes"></div><div class="boxMenuLabel">Mis notas</div>'
  4013. boxBtnMisNotas.className = "boxMenuButton boxBtnMisNotas"
  4014. boxBtnMisNotas.onclick = function () {
  4015. hideMenu()
  4016. panelSocial.openBookNotas(27, 0)
  4017. }
  4018. //Mi Cuenta
  4019. boxBtnMyAccount = document.createElement("div")
  4020. boxBtnMyAccount.innerHTML =
  4021. '<div class="boxMenuIcon cuenta"></div><div class="boxMenuLabel">Editar cuenta</div>'
  4022. boxBtnMyAccount.className = "boxMenuButton boxBtnMyAccount"
  4023. boxBtnMyAccount.onclick = function () {
  4024. hideMenu()
  4025. llector.editBio("null")
  4026. }
  4027. //Configuracion
  4028. boxBtnConfig = document.createElement("div")
  4029. boxBtnConfig.innerHTML =
  4030. '<div class="boxMenuIcon config"></div><div class="boxMenuLabel">Configuración</div>'
  4031. boxBtnConfig.className = "boxMenuButton boxBtnConfig"
  4032. boxBtnConfig.onclick = function () {
  4033. hideMenu()
  4034. panelSocial.showConfig()
  4035. }
  4036. //Contactenos
  4037. boxBtnContacto = document.createElement("div")
  4038. boxBtnContacto.className = "boxMenuButton boxBtnContacto"
  4039. boxBtnContacto.innerHTML =
  4040. '<div class="boxMenuIcon contact"></div><div class="boxMenuLabel">Contáctenos</div>'
  4041. boxBtnContacto.onclick = function () {
  4042. if (isSmartPhone) {
  4043. that.showContactenosPreview()
  4044. } else {
  4045. that.showContactenos()
  4046. }
  4047. }
  4048. $(boxMenu).append(boxBtnContacto)
  4049. //Ayuda
  4050. boxBtnAyuda = document.createElement("div")
  4051. boxBtnAyuda.className = "boxMenuButton boxBtnAyuda"
  4052. boxBtnAyuda.innerHTML =
  4053. '<div class="boxMenuIcon guia"></div><div class="boxMenuLabel">Guía de uso</div>'
  4054. boxBtnAyuda.onclick = function () {
  4055. that.showAyuda()
  4056. }
  4057. $(boxMenu).append(boxBtnAyuda)
  4058. //Preguntas frecuentes
  4059. boxBtnFreqQuestions = document.createElement("div")
  4060. boxBtnFreqQuestions.className = "boxMenuButton boxBtnFreqQuestions"
  4061. boxBtnFreqQuestions.innerHTML =
  4062. '<div class="boxMenuIcon preg"></div><div class="boxMenuLabel">Preguntas frecuentes</div>'
  4063. boxBtnFreqQuestions.onclick = function () {
  4064. that.showFrequentQuestions()
  4065. }
  4066. $(boxMenu).append(boxBtnFreqQuestions)
  4067. //Comandos de la busqueda
  4068. iconSearch.onclick = isSmartPhone || isTablet ? activateSearch : buscarLT
  4069. $(searchLT).focus(function () {
  4070. //Autocompletar
  4071. if (!searchLT.autocomp) {
  4072. $(searchLT).devbridgeAutocomplete({
  4073. serviceUrl: "/ltotal/inicio/utils/ut_46.jsp",
  4074. minChars: 2,
  4075. deferRequestBy: 80,
  4076. maxHeight: 500,
  4077. triggerSelectOnValidInput: false,
  4078. onSelect: function (suggestion) {
  4079. var mosa = panelSocial.mosaico
  4080. var doOpenItem = false
  4081. var tipoItem = suggestion.item_type
  4082. var idItem = suggestion.item_id
  4083. //NOTA!!!
  4084. //Para este proceso se debe buscar la forma que se unifique con
  4085. //panelSocial.openMosaicLink
  4086. //OJOO con tipoItem == 3 con x_extralabels_1
  4087. if (tipoItem == 1) {
  4088. var item = document.createElement("div")
  4089. item.className = "cell 1_" + idItem
  4090. panelSocial.clickSobreItem(item, "libros", mosa, null)
  4091. doOpenItem = true
  4092. }
  4093. if (tipoItem == 3) {
  4094. var item = document.createElement("div")
  4095. item.className =
  4096. "cell 3_" + idItem.replace(/_/g, ",") + " x_extralabels_1"
  4097. panelSocial.clickSobreItem(item, "libros", mosa, null)
  4098. doOpenItem = true
  4099. }
  4100. if (tipoItem == 4) {
  4101. var item = document.createElement("div")
  4102. item.className = "cell 4_" + idItem.replace("_", ",")
  4103. $(item).css({
  4104. "background-image": "url(" + suggestion.cover + ")",
  4105. })
  4106. panelSocial.clickSobreItem(item, "libros", mosa, null)
  4107. doOpenItem = true
  4108. }
  4109. if (tipoItem == 8) {
  4110. var item = document.createElement("div")
  4111. item.className = "cell 8_" + idItem.replace("_", ",")
  4112. panelSocial.clickSobreItem(item, "libros", mosa, null)
  4113. doOpenItem = true
  4114. }
  4115. if (tipoItem == 10) {
  4116. panelSocial.openMusicByID(idItem)
  4117. doOpenItem = true
  4118. }
  4119. if (tipoItem == 14) {
  4120. var item = document.createElement("div")
  4121. item.className = "cell 14_" + idItem + " x_showfiltrogenero_1"
  4122. panelSocial.clickSobreItem(item, "libros", mosa, null)
  4123. doOpenItem = true
  4124. }
  4125. if (tipoItem == 16) {
  4126. var pubDomain = suggestion.value3 == 1 ? true : false
  4127. panelSocial.openDiccTotal(null, idItem, {
  4128. openInTab: true,
  4129. diccAlfabetico: true,
  4130. publicDomain: pubDomain,
  4131. })
  4132. doOpenItem = true
  4133. }
  4134. if (tipoItem == 23) {
  4135. var item = document.createElement("div")
  4136. item.className = "cell 23_-2" + " x_showqueriesmenu_1"
  4137. panelSocial.clickSobreItem(item, "libros", mosa, null)
  4138. doOpenItem = true
  4139. }
  4140. if (tipoItem == 24) {
  4141. var item = document.createElement("div")
  4142. item.className = "cell 24_" + idItem
  4143. panelSocial.clickSobreItem(item, "libros", mosa, null)
  4144. doOpenItem = true
  4145. }
  4146. if (tipoItem == 32) {
  4147. var item = document.createElement("div")
  4148. item.className = "cell 32_" + idItem
  4149. panelSocial.clickSobreItem(item, "libros", mosa, null)
  4150. doOpenItem = true
  4151. }
  4152. if (tipoItem == 45) {
  4153. panelSocial.openDiccTotal(suggestion.value, null, {
  4154. openInTab: true,
  4155. })
  4156. doOpenItem = true
  4157. }
  4158. if (tipoItem == 47) {
  4159. var item = document.createElement("div")
  4160. item.className = "cell 47_" + idItem.replace(/_/g, ",")
  4161. panelSocial.clickSobreItem(item, "libros", mosa, null)
  4162. doOpenItem = true
  4163. }
  4164. if (tipoItem == 50) {
  4165. var item = document.createElement("div")
  4166. item.className = "cell 50_" + idItem
  4167. panelSocial.clickSobreItem(item, "libros", mosa, null)
  4168. doOpenItem = true
  4169. }
  4170. if (tipoItem == 51) {
  4171. var item = document.createElement("div")
  4172. item.className = "cell 51_" + idItem
  4173. panelSocial.clickSobreItem(item, "libros", mosa, null)
  4174. doOpenItem = true
  4175. }
  4176. if (tipoItem == "mydownld") {
  4177. var classFormat = suggestion.format
  4178. ? " format_" + suggestion.format
  4179. : " format_epub"
  4180. var item = document.createElement("div")
  4181. item.className = "cell mydownld_" + idItem + classFormat
  4182. panelSocial.clickSobreItem(item, "libros", mosa, null)
  4183. doOpenItem = true
  4184. }
  4185. if (doOpenItem) {
  4186. $(searchLT).blur()
  4187. if (isSmartPhone || isTablet) {
  4188. deActivateSearch()
  4189. }
  4190. } else {
  4191. buscarLT(suggestion.value)
  4192. }
  4193. },
  4194. beforeRender: function (container, suggestions) {
  4195. //You may manipulate suggestions DOM before it is displayed
  4196. setTimeout(function () {
  4197. //Asegura el scrollTop este en 0 cuando hay nueva busqueda
  4198. if (container[0].valor != searchLT.value) {
  4199. container[0].valor = searchLT.value
  4200. container[0].scrollTop = 0
  4201. }
  4202. }, 300)
  4203. },
  4204. leftRelativeParent: true,
  4205. extraWidth: 300,
  4206. showHomePanel: {
  4207. msg: "Recuerda que no podemos publicar libros protegidos por derechos de autor. Todos los contenidos son libres o autorizados para la difusión en la biblioteca.",
  4208. clase: "suggest_home_box",
  4209. },
  4210. })
  4211. searchLT.autocomp = true
  4212. }
  4213. })
  4214. searchLT.onkeyup = function (event) {
  4215. if (event.which == 13) {
  4216. buscarLT()
  4217. }
  4218. }
  4219. boxLogo.onclick = goHome
  4220. }
  4221. function generateFooterMenu() {
  4222. boxBottomFooter = document.createElement("div")
  4223. boxBottomFooter.setAttribute("class", "boxBottomFooter")
  4224. $(that.mainFrame).append(boxBottomFooter)
  4225. footerBtnHome = document.createElement("div")
  4226. footerBtnHome.innerHTML =
  4227. '<div class="footerBtn home"></div><div class="footerLabel">Inicio</div>'
  4228. footerBtnHome.className = "boxFooterButton"
  4229. footerBtnHome.style = "margin-left: 0"
  4230. footerBtnHome.addEventListener("touchstart", function (_ev) {
  4231. if ($(backMosaic).is(":visible") || $(".cells_extended")[0]) {
  4232. goHome()
  4233. } else {
  4234. gridBoxSmall.scrollTo({ top: 0, behavior: "smooth" })
  4235. }
  4236. })
  4237. footerBtnDescargas = document.createElement("div")
  4238. footerBtnDescargas.innerHTML =
  4239. '<div class="footerBtn download"></div><div class="footerLabel">Descargas</div>'
  4240. footerBtnDescargas.className = "boxFooterButton"
  4241. footerBtnDescargas.addEventListener(
  4242. "touchstart",
  4243. panelSocial.showDownloads,
  4244. )
  4245. footerBtnGuia = document.createElement("div")
  4246. footerBtnGuia.innerHTML =
  4247. '<div class="footerBtn guia"></div><div class="footerLabel">Guía de uso</div>'
  4248. footerBtnGuia.className = "boxFooterButton"
  4249. footerBtnGuia.addEventListener("touchstart", that.showAyuda)
  4250. footerBtnBiblio = document.createElement("div")
  4251. footerBtnBiblio.innerHTML =
  4252. '<div class="footerBtn biblio"></div><div class="footerLabel">Mi biblioteca</div>'
  4253. footerBtnBiblio.className = "boxFooterButton"
  4254. footerBtnBiblio.addEventListener("touchstart", function () {
  4255. var item = document.createElement("div")
  4256. item.className = "cell 24_mibliblio x_showmisdescargas_1"
  4257. panelSocial.clickSobreItem(item, "libros", panelSocial.mosaico, {})
  4258. })
  4259. $(boxBottomFooter).append([
  4260. footerBtnHome,
  4261. footerBtnDescargas,
  4262. footerBtnGuia,
  4263. footerBtnBiblio,
  4264. ])
  4265. }
  4266. function hideMenu() {
  4267. $(boxMenu).css({ "z-index": "" })
  4268. if ($(boxMenu).is(":visible")) {
  4269. $(boxMenu).slideToggle()
  4270. }
  4271. }
  4272. function showTopHeader(_modo) {
  4273. if (_modo == "hide" && !$(boxTopHeader).hasClass("ontop")) {
  4274. $(gridBox.labelAtTop).css({ visibility: "hidden" })
  4275. $(boxTopHeader)
  4276. .addClass("ontop")
  4277. .animate({ top: "-150px" }, 400, function () {
  4278. if (gridBox.labelAtTop) {
  4279. LPPutLabelAtTop(gridBox.labelAtTop.label)
  4280. }
  4281. })
  4282. $(boxBottomFooter).animate({ bottom: "-60px" }, 400)
  4283. }
  4284. if (_modo == "show" && $(boxTopHeader).hasClass("ontop")) {
  4285. $(gridBox.labelAtTop).css({ visibility: "hidden" })
  4286. $(boxTopHeader)
  4287. .removeClass("ontop")
  4288. .animate({ top: "0px" }, 400, function () {
  4289. if (gridBox.labelAtTop) {
  4290. LPPutLabelAtTop(gridBox.labelAtTop.label)
  4291. }
  4292. })
  4293. $(boxBottomFooter).animate({ bottom: "0px" }, 400)
  4294. }
  4295. }
  4296. function focusItem(_elem, _txtIN, _cont) {
  4297. var $elem = $(_elem)
  4298. _elem.setAttribute("placeholder", _txtIN)
  4299. $elem.focusin(function () {
  4300. _elem.setAttribute("placeholder", "")
  4301. })
  4302. $elem.focusout(function () {
  4303. _elem.setAttribute("placeholder", _txtIN)
  4304. })
  4305. if (_cont) {
  4306. _elem.onkeyup = function (ev) {
  4307. executeEnter(ev, function () {
  4308. $(".loginInitSes, .loginReg", _cont).trigger("click")
  4309. })
  4310. }
  4311. }
  4312. }
  4313. function saveLastNavigation() {
  4314. var navData = null
  4315. if (panelSocial.selectedBook) {
  4316. var setts = panelSocial.selectedBook.settings
  4317. var tipo = setts.tipoLibro
  4318. var modo = setts.modoLibro
  4319. var idLib = setts.idLibro
  4320. var percent = setts.numePaginaPercent
  4321. if (tipo == 1) {
  4322. navData = [1, idLib, setts.idTrad, setts.pgFin, percent]
  4323. }
  4324. if (tipo == 27) {
  4325. if (modo == 0) {
  4326. navData = [27, idLib]
  4327. }
  4328. if (modo == 1) {
  4329. navData = [17, setts.idItemFin]
  4330. }
  4331. if (modo == 2) {
  4332. navData = [17, idLib]
  4333. }
  4334. }
  4335. if (tipo == 32) {
  4336. navData = [15, idLib, setts.idItemFin, percent]
  4337. }
  4338. } else if ($(".caratula_banner")[0]) {
  4339. var bData = $(".caratula_banner")[0]
  4340. .className.match(/\d+_\d+/)[0]
  4341. .split("_")
  4342. navData = bData
  4343. }
  4344. if (navData && navData.length > 0) {
  4345. ltotalUtils.toLocalStorage("lastNavData", navData.join("_"))
  4346. }
  4347. }
  4348. function placeMainBtns() {
  4349. if (ltotalOS.forcedTabletMode && $(window).width() > 1040) {
  4350. ltotalOS.forcedTabletMode = false
  4351. setTimeout(that.rePaint, 200)
  4352. return null
  4353. }
  4354. if (isTouch) {
  4355. //Reduce un poco el tamaño del los botones cuando el boton de arte se sale de la pantalla
  4356. var btnsPilares = $([pilarLibros, pilarMusica, pilarArte])
  4357. var squared = $(".squared", btnsPilares)
  4358. btnsPilares.css({ "margin-left": "", width: "" })
  4359. squared.css({ width: "" })
  4360. var pfin = pilarArte.offsetLeft + pilarArte.offsetWidth
  4361. var ww = $(window).width()
  4362. if (pfin > ww) {
  4363. btnsPilares.css({ "margin-left": "0", width: "107px" })
  4364. squared.css({ width: "71px" })
  4365. }
  4366. } else {
  4367. //Ubica los 3 botones principales en escritorio
  4368. var widthPilars = 500
  4369. var widthBtnBack = 40
  4370. var pini = boxLogo.offsetLeft + boxLogo.offsetWidth + widthBtnBack
  4371. var pfin = userMosaic.offsetLeft
  4372. var largo = pfin - pini
  4373. var left = (largo - widthPilars) / 2 + pini
  4374. var btnsPilares = $([pilarLibros, pilarMusica, pilarArte])
  4375. if (left < pini) {
  4376. //Reduce el tamaño de los botones
  4377. btnsPilares.css({ width: "112px" })
  4378. $(".squared", btnsPilares).css({ width: "76px" })
  4379. $(pilarLibros).css({ "margin-left": pini + "px" })
  4380. var artfin = pilarArte.offsetLeft + pilarArte.offsetWidth
  4381. var deltaPfinArtfin = pfin - artfin
  4382. if (deltaPfinArtfin < 10) {
  4383. ltotalOS.forcedTabletMode = true
  4384. setTimeout(that.rePaint, 200)
  4385. }
  4386. } else {
  4387. //Restablece el tamaño de los botones
  4388. btnsPilares.css({ width: "" })
  4389. $(".squared", btnsPilares).css({ width: "" })
  4390. $(pilarLibros).css({ "margin-left": left + "px" })
  4391. }
  4392. }
  4393. }
  4394. this.aumentarSizeMosaico = function (_caso, _extra) {
  4395. if (_caso == 0) {
  4396. $(panelSocial.bodyDiv).removeClass("aumented")
  4397. $(boxMosaic).removeClass("aumented")
  4398. $(that.mainFrame).removeClass("aumented")
  4399. }
  4400. if (_caso == 1) {
  4401. $(panelSocial.bodyDiv).addClass("aumented")
  4402. $(boxMosaic).addClass("aumented")
  4403. $(that.mainFrame).addClass("aumented")
  4404. }
  4405. $(".cell.mydownld").each(function () {
  4406. loadNativeCover(this)
  4407. })
  4408. repaintFluid()
  4409. panelSocial.mosaicSize = _caso
  4410. ltotalOS.setPreferenciaLector("mosaicSize", _caso)
  4411. }
  4412. this.configBtnLogin = function () {
  4413. if (lectorLogueado) {
  4414. $(boxBtnLogin)
  4415. .addClass("closeSes")
  4416. .removeClass("initSes")
  4417. .html(
  4418. '<div class="boxMenuIcon logout"></div><div class="boxMenuLabel">Cerrar sesión</div>',
  4419. )
  4420. $(boxBtnContacto).before(boxBtnMyAccount)
  4421. $(boxMenu).prepend(boxBtnCrearNota)
  4422. $(boxMenu).prepend(boxBtnHistorial)
  4423. $(boxMenu).prepend(boxBtnFavoritos)
  4424. $(boxBtnCrearNota).after(boxBtnMisNotas)
  4425. $(boxMenu).append(boxBtnLogin)
  4426. } else {
  4427. $(boxBtnLogin)
  4428. .addClass("initSes")
  4429. .removeClass("closeSes")
  4430. .html(
  4431. '<div class="boxMenuIcon login"></div><div class="boxMenuLabel">Iniciar sesión</div>',
  4432. )
  4433. $(boxBtnLogin).before(boxBtnRegister)
  4434. $(boxMenu).prepend(boxBtnLogin)
  4435. }
  4436. $(boxBtnContacto).before(boxBtnConfig)
  4437. if (panelSocial.hasOfflineBooks()) {
  4438. $(boxMenu).prepend(boxBtnDescargas)
  4439. generateFooterMenu()
  4440. }
  4441. }
  4442. this.btnRegisterClick = function () {
  4443. that.showLogin.call(boxBtnRegister)
  4444. }
  4445. this.btnLoginClick = function () {
  4446. that.showLogin.call(boxBtnLogin)
  4447. }
  4448. function showCaptcha(_cont) {
  4449. $(".divCaptcha, .loginCaptcha", _cont).css({ display: "" })
  4450. $(".reloadCaptcha", _cont)[0].onclick = function () {
  4451. getCaptcha(_cont)
  4452. }
  4453. }
  4454. function getCaptcha(_cont) {
  4455. var urlCaptcha = "/ltotal/lector/captcha.jsp"
  4456. $.post(urlCaptcha, {}).done(function (_d) {
  4457. var proc = $("#proceso").html(_d)
  4458. var captcha_img = $(".captcha_img", proc).text()
  4459. $(".imgCaptcha", _cont)[0].src = "data:image/png;base64, " + captcha_img
  4460. loginAttempts = parseInt($(".loginAttempts", proc).text())
  4461. if (loginAttempts > 0) {
  4462. showCaptcha(_cont)
  4463. }
  4464. })
  4465. }
  4466. this.showLogin = function () {
  4467. var $this = $(this)
  4468. hideMenu()
  4469. var setts = {
  4470. heightV: null,
  4471. widthV: null,
  4472. scrollSyc: false,
  4473. bgColor: "rgb(255, 255, 255)",
  4474. fnAfterClose: function () {
  4475. panelSocial.setNativeMainViewBGColor(11, 28, 43)
  4476. },
  4477. }
  4478. //Form iniciar sesion
  4479. var isLogin = $this.hasClass("initSes")
  4480. if (isLogin) {
  4481. var HTML =
  4482. '\
  4483. <div class="initSesScreen">\
  4484. <div class="loginHeader">Para hacer notas, agregar favoritos, ver el historial y acceder a otros servicios, debe crear una <span onclick="$(\'.btnCloseAlert\', alertLM.getContain()).trigger(\'click\'); $(\'.loginShowReg\').trigger(\'click\');" style="color:#0873F5; cursor:pointer;">cuenta gratis</span> como lector.</div>\
  4485. <input type="text" class="loginField loginEmail" place="Correo" />\
  4486. <div class="divPasswd">\
  4487. <input type="password" class="loginField passwdField loginPass" place="Contraseña" />\
  4488. <div class="passwd_view"></div>\
  4489. </div>\
  4490. <div class="divCaptcha" style="display:none;"><img class="imgCaptcha" src="" /><img class="reloadCaptcha" src="/estaticosED/files/img/refresh.svg" style="cursor:pointer; width:50px; height:50px;" title="Cambiar de imagen" /></div>\
  4491. <input type="text" autocapitalize="none" autocorrect="off" class="loginField loginCaptcha" place="Digite el texto de la imagen" style="display:none;" />\
  4492. <div class="loginMsg"></div>\
  4493. <div class="loginBtn loginInitSes">Iniciar sesión</div>\
  4494. <div class="loginBtn loginShowRecClave">Restaurar contraseña</div>\
  4495. <div class="loginBtn loginShowReg">Crear cuenta</div>\
  4496. </div>\
  4497. '
  4498. }
  4499. //Form cerrar sesion
  4500. if ($this.hasClass("closeSes")) {
  4501. var nLect = $.trim(lectorLogueado.nombre).split(/\s+/)[0]
  4502. var HTML =
  4503. '\
  4504. <div style="width:100%;">\
  4505. <div class="loginHeader" style="text-align:justify;">' +
  4506. nLect +
  4507. ',<br><br>Va a salir del espacio personal "Mi Biblioteca". Para volver a ingresar debe escribir su correo y contraseña nuevamente.</div>\
  4508. <div class="loginBtn loginCloseSes">Cerrar sesión</div>\
  4509. </div>\
  4510. '
  4511. }
  4512. //Form cancelar cuenta
  4513. if ($this.hasClass("killAccount")) {
  4514. var nLect = $.trim(lectorLogueado.nombre).split(/\s+/)[0]
  4515. var HTML =
  4516. '\
  4517. <div style="width:100%;">\
  4518. <div class="loginHeader" style="text-align:justify;">' +
  4519. nLect +
  4520. ',<br><br>Se dispone a cancelar su cuenta en la Biblioteca El Libro Total: recuerde que sin registro, el sistema no podrá recordar sus últimas lecturas, notas personales y demás funcionalidades únicamente disponibles para los usuarios con cuenta activa. Si decide cancelarla, podrá registrarse nuevamente cuando lo desee.</div>\
  4521. <div><div class="loginBtn loginKillAccountCancel" style="float:left; left:0;">Cancelar</div><div class="loginBtn loginKillAccount" style="float:left; left:0;">Confirmar</div></div>\
  4522. </div>\
  4523. '
  4524. setts.heightV = 320
  4525. }
  4526. //Form registro
  4527. var isRegistro = $this.hasClass("loginShowReg")
  4528. if (isRegistro) {
  4529. var HTML =
  4530. '\
  4531. <div class="loginShowRegScreen">\
  4532. <div class="loginHeader">Para hacer notas, agregar favoritos, ver el historial y acceder a otros servicios, debe crear una <span style="color:#0873F5;">cuenta gratis</span> como lector.</div>\
  4533. <input type="text" class="loginField loginRegName" place="Nombres y apellidos" />\
  4534. <input type="text" class="loginField loginRegEmail" place="Correo electrónico" />\
  4535. <input type="text" class="loginField loginRegEmailConfirm" place="Confirmar correo electrónico" />\
  4536. <div class="divPasswd">\
  4537. <input type="password" class="loginField passwdField loginRegPass" place="Contraseña" />\
  4538. <div class="passwd_view"></div>\
  4539. </div>\
  4540. <div class="divPasswd">\
  4541. <input type="password" class="loginField passwdField loginRegPassConfirm" place="Confirmar contraseña" />\
  4542. <div class="passwd_view"></div>\
  4543. </div>\
  4544. <div class="loginShowRegBoxPTI"><input type="checkbox" class="loginRegCheckPTI" />&nbsp;Autorizo y Acepto la <span class="loginRegReadPTI" title="Leer Política de tratamiento de información personal">Política de tratamiento de la información</span> y el <span class="loginRegReadMGU" title="Leer Marco general de uso de la plataforma del Libro Total">Marco general de uso.</span></div>\
  4545. <div class="loginBtn loginReg">Crear cuenta</div>\
  4546. <div style="position:relative; width:100%; height:300px; box-sizing: border-box;"></div>\
  4547. </div>\
  4548. '
  4549. }
  4550. //Form restaurar clave
  4551. if ($this.hasClass("loginShowRecClave")) {
  4552. var HTML =
  4553. '\
  4554. <div style="width:100%;">\
  4555. <div class="loginHeader">En los próximos minutos se le enviarán las instrucciones para restaurar su contraseña al correo electrónico.</div>\
  4556. <input type="text" class="loginField loginRecClaveEmail" place="Correo electrónico" />\
  4557. <div class="loginBtn loginRecClave">Enviar</div>\
  4558. </div>\
  4559. '
  4560. }
  4561. //FIN. Formularios
  4562. var fTV = panelSocial.openModalTxtViewer(HTML, setts)
  4563. var cont = $(fTV.getContain())
  4564. panelSocial.setNativeMainViewBGColor(255, 255, 255)
  4565. cont.addClass("boxLogin")
  4566. $(".contentHtml", cont).css({ width: "90%", "margin-left": "5%" })
  4567. if (isLogin) {
  4568. getCaptcha(cont)
  4569. }
  4570. //tamano para hacer scroll form registro, div temporal en el formulario. Quitar cuando tengamo App en android puro.
  4571. if (isRegistro) {
  4572. $(".contentHtml", cont).css({ height: "90%" })
  4573. }
  4574. $(".loginField", cont).each(function () {
  4575. focusItem(this, $(this).attr("place"), cont)
  4576. })
  4577. $(".passwd_view", cont).each(function () {
  4578. this.onclick = function () {
  4579. var btn = $(this)
  4580. var divp = btn.parent()
  4581. var inpt = $("input", divp)[0]
  4582. if (inpt.type === "password") {
  4583. inpt.type = "text"
  4584. btn.addClass("textual")
  4585. } else {
  4586. inpt.type = "password"
  4587. btn.removeClass("textual")
  4588. }
  4589. }
  4590. })
  4591. //Iniciar sesion
  4592. $(".loginInitSes", cont).click(function () {
  4593. var btn = this
  4594. var correo = $(".loginEmail", cont).val().trim()
  4595. var clave = $(".loginPass", cont).val().trim()
  4596. var captcha = $(".loginCaptcha", cont).val().trim()
  4597. if (correo.length == 0 || clave.length == 0) {
  4598. return $(".loginMsg", cont)
  4599. .css({ display: "block" })
  4600. .text("Por favor digite su correo y contraseña.")
  4601. }
  4602. var datosCorreo = correo.split("@")
  4603. if (datosCorreo.length == 1) {
  4604. correo = correo + "@syc.com.co"
  4605. }
  4606. if (loginAttempts > 0 && captcha.length == 0) {
  4607. return $(".loginMsg", cont)
  4608. .css({ display: "block" })
  4609. .text("Por favor digite el texto de la imagen de verificación.")
  4610. }
  4611. btn.innerHTML = "<em>Iniciando sesión...</em>"
  4612. ltotalOS.login(correo, clave, captcha).done(function (_r) {
  4613. if (_r == "EXITO") {
  4614. panelSocial.saveNativeCredentials(correo, clave)
  4615. saveLastNavigation()
  4616. $(".closeModalViewer", cont).trigger("click")
  4617. location.reload()
  4618. }
  4619. if (_r == "FRACASO") {
  4620. loginAttempts++
  4621. getCaptcha(cont)
  4622. $(".loginMsg", cont)
  4623. .css({ display: "block" })
  4624. .text(
  4625. "Por favor verifique su correo, contraseña y el código de verificación.",
  4626. )
  4627. btn.innerHTML = "Iniciar sesión"
  4628. }
  4629. })
  4630. })
  4631. //Cerrar sesion
  4632. $(".loginCloseSes", cont).click(function () {
  4633. ltotalOS.logOut().done(function () {
  4634. panelSocial.deleteNativeCredentials()
  4635. saveLastNavigation()
  4636. $(".closeModalViewer", cont).trigger("click")
  4637. location.reload()
  4638. })
  4639. })
  4640. //Cancelar cuenta
  4641. $(".loginKillAccount", cont).click(function () {
  4642. ltotalOS.cancelRegister().done(function (d) {
  4643. if (d == "EXITO") {
  4644. ltotalOS.logOut().done(function () {
  4645. panelSocial.deleteNativeCredentials()
  4646. location.reload()
  4647. })
  4648. } else {
  4649. alertLM.show(
  4650. bodyDiv,
  4651. "No fué posible cancelar su cuenta.<br>Por favor contáctenos para revisar su caso.",
  4652. )
  4653. }
  4654. })
  4655. })
  4656. //Cerrar cancelar cuenta
  4657. $(".loginKillAccountCancel", cont).click(function () {
  4658. fTV.destroy()
  4659. })
  4660. //Mostrar registro de usuario
  4661. $(".loginShowReg", cont).click(function () {
  4662. that.showLogin.call(this)
  4663. })
  4664. //Leer PTI
  4665. $(".loginRegReadPTI", cont).click(function () {
  4666. panelPTI({ idLibro: 11425, idTrad: 11197, hostDiv: bodyDiv })
  4667. })
  4668. //Leer MGU
  4669. $(".loginRegReadMGU", cont).click(function () {
  4670. panelPTI({ idLibro: 11020, idTrad: 10735, hostDiv: bodyDiv })
  4671. })
  4672. //Registro de usuario
  4673. $(".loginReg", cont).click(function () {
  4674. var btn = this
  4675. var nombre = $(".loginRegName", cont).val()
  4676. var correo = $(".loginRegEmail", cont)
  4677. .val()
  4678. .toLowerCase()
  4679. .replace(/\s+/g, "")
  4680. var correoConfirm = $(".loginRegEmailConfirm", cont)
  4681. .val()
  4682. .toLowerCase()
  4683. .replace(/\s+/g, "")
  4684. var clave = $(".loginRegPass", cont).val()
  4685. var claveConfirm = $(".loginRegPassConfirm", cont).val()
  4686. if (
  4687. nombre.length < 1 ||
  4688. correo.length < 1 ||
  4689. correoConfirm.length < 1
  4690. ) {
  4691. alertLM.show(bodyDiv, "Por favor llene todos los datos")
  4692. return null
  4693. }
  4694. if (clave.length < 6) {
  4695. alertLM.show(bodyDiv, "La clave debe tener 6 caracteres o más")
  4696. return null
  4697. }
  4698. if (clave != claveConfirm) {
  4699. alertLM.show(bodyDiv, "La clave y la confirmación deben ser iguales")
  4700. return null
  4701. }
  4702. if (
  4703. correo.indexOf("@") == -1 ||
  4704. correo.indexOf(".") == -1 ||
  4705. correoConfirm.indexOf("@") == -1 ||
  4706. correoConfirm.indexOf(".") == -1
  4707. ) {
  4708. alertLM.show(bodyDiv, "Por favor verifique su correo")
  4709. return null
  4710. }
  4711. if (correo != correoConfirm) {
  4712. alertLM.show(
  4713. bodyDiv,
  4714. "El correo y la confirmación de correo deben ser iguales",
  4715. )
  4716. return null
  4717. }
  4718. if (!$(".loginRegCheckPTI", cont).prop("checked")) {
  4719. alertLM.show(
  4720. bodyDiv,
  4721. "Para registrarse en el Libro Total, debe aceptar la política de tratamiento de datos personales.",
  4722. )
  4723. return null
  4724. }
  4725. //Integridad del correo electronico
  4726. //Validacion con respecto a dominios conocidos mal escritos
  4727. var correoArr = correo.split("@")
  4728. if (correoArr.length == 2) {
  4729. var correoOK = true
  4730. correoArr = correoArr[1].split(/\./g)
  4731. var badDomains = [
  4732. "gmal",
  4733. "gamil",
  4734. "gmali",
  4735. "gamail",
  4736. "gamali",
  4737. "gmil",
  4738. "gamal",
  4739. "oulook",
  4740. "outlok",
  4741. "yaho",
  4742. "homail",
  4743. "homal",
  4744. "hotmal",
  4745. ]
  4746. for (var ibd = 0; ibd < badDomains.length; ibd++) {
  4747. if (correoArr[0] == badDomains[ibd]) {
  4748. correoOK = false
  4749. break
  4750. }
  4751. }
  4752. if (!correoOK) {
  4753. alertLM.show(
  4754. bodyDiv,
  4755. "Por favor verifique su correo.<br>Es posible que parte de la dirección " +
  4756. correoArr.join(".") +
  4757. " esté mal escrita.",
  4758. )
  4759. return null
  4760. }
  4761. } else {
  4762. alertLM.show(
  4763. bodyDiv,
  4764. 'Por favor verifique su correo.<br>Sólo debe haber un (1) caracter "@".',
  4765. )
  4766. return null
  4767. }
  4768. btn.innerHTML = "<em>Creando registro...</em>"
  4769. var extra = {
  4770. id_cliente: panelSocial.getIDCliente(),
  4771. }
  4772. ltotalOS
  4773. .register(nombre, correo, correoConfirm, clave, extra)
  4774. .done(function (_r) {
  4775. if (_r == "EXITO") {
  4776. ltotalOS.login(correo, clave).done(function (_r) {
  4777. if (_r == "EXITO") {
  4778. panelSocial.saveNativeCredentials(correo, clave)
  4779. location.reload()
  4780. }
  4781. })
  4782. }
  4783. if (_r == "NO_DISPONIBLE") {
  4784. alertLM.show(
  4785. bodyDiv,
  4786. "El correo proporcionado (" + correo + ") ya está inscrito",
  4787. )
  4788. }
  4789. if (_r == "CONFIRMAR_CORREO") {
  4790. alertLM.show(
  4791. bodyDiv,
  4792. "El correo y la confirmación de correo deben ser iguales",
  4793. )
  4794. }
  4795. if (_r == "ERROR") {
  4796. alertLM.show(
  4797. bodyDiv,
  4798. "Hubo un problema en el registro.\nPor favor intente mas tarde",
  4799. )
  4800. }
  4801. btn.innerHTML = "Registrarme"
  4802. })
  4803. })
  4804. //Mostrar restaurar contraseña
  4805. $(".loginShowRecClave", cont).click(function () {
  4806. that.showLogin.call(this)
  4807. })
  4808. //Restaurar contraseña
  4809. $(".loginRecClave", cont).click(function () {
  4810. var correo = $.trim($(".loginRecClaveEmail", cont).val())
  4811. if (
  4812. correo.length == 0 ||
  4813. correo.indexOf("@") == -1 ||
  4814. correo.indexOf(".") == -1
  4815. ) {
  4816. alertLM.show(
  4817. bodyDiv,
  4818. "Por favor escriba la dirección de correo electrónico que usó para registrarse en El Libro Total",
  4819. )
  4820. return null
  4821. }
  4822. ltotalOS.remember(correo).done(function (_r) {
  4823. if (_r == "EXITO") {
  4824. $(".closeModalViewer", fTV.getContain()).trigger("click")
  4825. }
  4826. if (_r == "ERROR") {
  4827. alertLM.show(
  4828. bodyDiv,
  4829. "No es posible realizar el proceso en este momento.\nPor favor intente mas tarde.",
  4830. )
  4831. }
  4832. })
  4833. })
  4834. }
  4835. this.showContactenosPreview = function () {
  4836. hideMenu()
  4837. var HTML =
  4838. '\
  4839. <div class="showContactenosScreen">\
  4840. <div class="contactIcon"></div>\
  4841. <div class="contactHeader">Por favor comparta con nosotros sus comentarios e inquietudes sobre la biblioteca del Libro Total a través del medio de su preferencia.</div>\
  4842. <div class="contactBtn whatsapp"><div class="contactWhatsAppIcon"></div><a class="lnk_whatsapp" href="whatsapp://send?phone=573178941441&text=&source=&data=" target="_blank"></a>Vía WhatsApp</div>\
  4843. <div class="contactBtn mail" onclick="panelSocial.mosaico.showContactenos();"><div class="contactEmailIcon"></div>Correo electrónico</div>\
  4844. </div>'
  4845. //https://wa.me/573178941441
  4846. var fTV = panelSocial.openModalTxtViewer(HTML, {
  4847. scrollSyc: false,
  4848. bgColor: "rgb(255, 255, 255)",
  4849. })
  4850. $(".contentHtml", $(fTV.getContain())).css({
  4851. width: "90%",
  4852. "margin-left": "5%",
  4853. })
  4854. $(fTV.getContain()).addClass("boxContact")
  4855. }
  4856. this.showContactenos = function () {
  4857. hideMenu()
  4858. var setts = {
  4859. heightV: null,
  4860. widthV: null,
  4861. scrollSyc: false,
  4862. bgColor: "rgb(255, 255, 255)",
  4863. }
  4864. var savingContMsg = false
  4865. var HTML =
  4866. '\
  4867. <div class="showContactenosScreen">\
  4868. <div class="contactHeader">Por favor comparta con nosotros sus comentarios e inquietudes sobre la biblioteca del Libro Total.</div>\
  4869. <input type="text" class="contactField contactName" place="Su nombre" />\
  4870. <input type="text" class="contactField contactEmail" place="Su correo electrónico" />\
  4871. <textarea class="contactField contactMsg" place="Su mensaje para la biblioteca del Libro Total" style="resize:none; overflow:auto;"></textarea>\
  4872. <div class="contactShowBoxPTI"><input type="checkbox" class="contactCheckPTI" />&nbsp;Autorizo y Acepto la <span class="contactReadPTI" title="Leer Política de tratamiento de información personal">Política de tratamiento de la información</span> y el <span class="contactReadMGU" title="Leer Marco general de uso de la plataforma del Libro Total">Marco general de uso.</span></div>\
  4873. <div class="contactBtn contactSend">Enviar</div>\
  4874. </div>\
  4875. '
  4876. var fTV = panelSocial.openModalTxtViewer(HTML, setts)
  4877. var cont = $(fTV.getContain())
  4878. cont.addClass("boxContact")
  4879. $(".contentHtml", cont).css({ width: "90%", "margin-left": "5%" })
  4880. $(".contactField", cont).each(function () {
  4881. focusItem(this, $(this).attr("place"), null)
  4882. })
  4883. //Enviar mensaje
  4884. $(".contactSend", cont).click(function () {
  4885. var nombre = $(".contactName", cont).val()
  4886. var mail = $(".contactEmail", cont).val()
  4887. var msg = $(".contactMsg", cont).val()
  4888. var checker = $(".contactCheckPTI", cont)
  4889. if (mail.indexOf("@") == -1 || mail.indexOf(".") == -1) {
  4890. return alertLM.show(
  4891. bodyDiv,
  4892. "Por favor escriba su correo electrónico",
  4893. )
  4894. }
  4895. if ($.trim(msg).length == 0) {
  4896. return alertLM.show(bodyDiv, "Por favor escriba su mensaje")
  4897. }
  4898. if (!checker.prop("checked")) {
  4899. return alertLM.show(
  4900. bodyDiv,
  4901. "Para enviar el mensaje, debe aceptar la política de tratamiento de datos personales",
  4902. )
  4903. }
  4904. if (!savingContMsg) {
  4905. savingContMsg = true
  4906. ltotalOS.contact(nombre, mail, msg).done(function () {
  4907. fTV.destroy()
  4908. })
  4909. }
  4910. })
  4911. //Leer PTI
  4912. $(".contactReadPTI", cont).click(function () {
  4913. panelPTI({ idLibro: 8509, idTrad: 8133, hostDiv: bodyDiv })
  4914. })
  4915. //Leer MGU
  4916. $(".contactReadMGU", cont).click(function () {
  4917. panelPTI({ idLibro: 11020, idTrad: 10735, hostDiv: bodyDiv })
  4918. })
  4919. if (lectorLogueado) {
  4920. $(".contactName", cont).val(lectorLogueado.nombre)
  4921. $(".contactEmail", cont).val(lectorLogueado.mail)
  4922. }
  4923. }
  4924. this.showAyuda = function () {
  4925. hideMenu()
  4926. ltotalUtils.loadScript(
  4927. panelSocial.getContextoEstaticos() + "/js/ltotal/helper.js",
  4928. )
  4929. ltotalUtils.loadScript(
  4930. panelSocial.getContextoEstaticos() + "/css/ltotal/helper.css",
  4931. )
  4932. helper.init()
  4933. }
  4934. this.showRatingApp = function () {
  4935. hideMenu()
  4936. ltotalUtils.loadScript(
  4937. panelSocial.getContextoEstaticos() + "/js/ltotal/rating_app.js",
  4938. )
  4939. ltotalUtils.loadScript(
  4940. panelSocial.getContextoEstaticos() + "/css/ltotal/rating_app.css",
  4941. )
  4942. ratingApp.init()
  4943. }
  4944. this.showFrequentQuestions = function (_extraParams) {
  4945. hideMenu()
  4946. var xParams =
  4947. _extraParams && _extraParams.txtCoord
  4948. ? _extraParams
  4949. : { openInIndex: true }
  4950. panelSocial.openBook(1, 1565, 1616, xParams)
  4951. }
  4952. this.activateCategsMenuBtns = function () {
  4953. $(".categsMenuBox", that.mainFrame).remove()
  4954. categsMenuBox = $(
  4955. '<div class="categsMenuBox" style="display:none;"></div>',
  4956. )
  4957. $(that.mainFrame).append(categsMenuBox)
  4958. var categs = {
  4959. libros:
  4960. "Historia#Bélico#Terror#Juvenil#Infantil#Fantástico#Ciencia ficción#Filosofía#Política#Espiritualidad#Policial#Romántico#Gastronomía#Pedagogía#Biografía#Artículos#Ensayos#Cuentos#Novelas#Poesía#Teatro#Crónica#Frases",
  4961. musica: "Culta#Folclórica#Instrumental#Rock#Ópera",
  4962. }
  4963. var replaceAccent = function (_str) {
  4964. return _str
  4965. .replace(/á/, "a")
  4966. .replace(/é/, "e")
  4967. .replace(/í/, "i")
  4968. .replace(/ó/, "o")
  4969. .replace(/ú/, "u")
  4970. .replace(/\s/, "")
  4971. }
  4972. for (var property in categs) {
  4973. if (categs.hasOwnProperty(property)) {
  4974. var cats = categs[property].split("#")
  4975. var catsBtns = []
  4976. $.each(cats, function () {
  4977. var ct = this
  4978. var ctclass = replaceAccent(ct).toLowerCase()
  4979. var catBtn = $(
  4980. '<div class="categsMenuButton categ_' +
  4981. property +
  4982. " serv_" +
  4983. property +
  4984. " cat_" +
  4985. ctclass +
  4986. '"><div class="categ_icon"></div><div class="categ_label">' +
  4987. ct +
  4988. "</div></div>",
  4989. )[0]
  4990. catsBtns.push(catBtn)
  4991. catBtn.onclick = function () {
  4992. var ctxt = $(this).text().toLowerCase()
  4993. if ($(this).hasClass("serv_libros")) {
  4994. var item = document.createElement("div")
  4995. item.className = "cell 14_" + replaceAccent(ctxt) + " cvLD"
  4996. panelSocial.clickSobreItem(item, "libros", that, {
  4997. extra_labels: 1,
  4998. list_detail_genero: 1,
  4999. })
  5000. }
  5001. if ($(this).hasClass("serv_musica")) {
  5002. var idsGens = {
  5003. Culta: 551,
  5004. Folclórica: 441,
  5005. Instrumental: 511,
  5006. Rock: 520,
  5007. Ópera: 473,
  5008. }
  5009. var nombGen = $(this).text()
  5010. var idGen = idsGens[nombGen]
  5011. var item = document.createElement("div")
  5012. item.className = "cell 38_" + idGen + " cvLD"
  5013. panelSocial.clickSobreItem(item, "musica", that, {
  5014. extra_labels: 1,
  5015. listlabels: 1,
  5016. })
  5017. }
  5018. }
  5019. })
  5020. categsMenuBox[0][property] = catsBtns
  5021. }
  5022. }
  5023. //Botones particulares Libros
  5024. var confrontadosBtn = $(
  5025. '<div class="categsMenuButton categ_libros cat_confrontados"><div class="categ_icon"></div><div class="categ_label">Confrontados a otros idiomas</div></div>',
  5026. )
  5027. categsMenuBox[0]["libros"].unshift(confrontadosBtn[0])
  5028. confrontadosBtn[0].onclick = function () {
  5029. var item = document.createElement("div")
  5030. item.className = "cell 8_1,7 cvLD"
  5031. panelSocial.clickSobreItem(item, "libros", that, { extra_labels: 1 })
  5032. }
  5033. var audioLibrosBtn = $(
  5034. '<div class="categsMenuButton categ_libros cat_audiolibros"><div class="categ_icon"></div><div class="categ_label">Audiolibros</div></div>',
  5035. )
  5036. categsMenuBox[0]["libros"].unshift(audioLibrosBtn[0])
  5037. audioLibrosBtn[0].onclick = function () {
  5038. var item = document.createElement("div")
  5039. item.className = "cell 23_-14 cvLD"
  5040. panelSocial.clickSobreItem(item, "libros", that, { extra_labels: 1 })
  5041. }
  5042. var dicciosBtn = $(
  5043. '<div class="categsMenuButton categ_libros cat_diccionarios"><div class="categ_icon"></div><div class="categ_label">Diccionarios</div></div>',
  5044. )
  5045. categsMenuBox[0]["libros"].unshift(dicciosBtn[0])
  5046. dicciosBtn[0].onclick = function () {
  5047. var item = document.createElement("div")
  5048. item.className = "cell 16_0 cvLD"
  5049. panelSocial.clickSobreItem(item, "libros", that, {
  5050. extra_labels: 1,
  5051. doDiccsQuery: 1,
  5052. })
  5053. }
  5054. var autoresBtn = $(
  5055. '<div class="categsMenuButton categ_libros cat_autores"><div class="categ_icon"></div><div class="categ_label">Autores</div></div>',
  5056. )
  5057. categsMenuBox[0]["libros"].unshift(autoresBtn[0])
  5058. autoresBtn[0].onclick = function () {
  5059. var item = document.createElement("div")
  5060. item.className = "cell 3_0,1,0 cvLD"
  5061. panelSocial.clickSobreItem(item, "libros", that, {
  5062. extra_labels: 1,
  5063. noBanner: true,
  5064. })
  5065. }
  5066. var frasesRandomBtn = $(
  5067. '<div class="categsMenuButton categ_libros cat_frases_random"><div class="categ_icon"></div><div class="categ_label">Frases aleatorias</div></div>',
  5068. )
  5069. categsMenuBox[0]["libros"].unshift(frasesRandomBtn[0])
  5070. frasesRandomBtn[0].onclick = function () {
  5071. panelSocial.screenSaver({ withFrases: true })
  5072. }
  5073. var contraInteligenceBtn = $(
  5074. '<div class="categsMenuButton categ_libros cat_contrainteligence"><div class="categ_icon"></div><div class="categ_label">Contrainteligencia artificial</div></div>',
  5075. )
  5076. categsMenuBox[0]["libros"].unshift(contraInteligenceBtn[0])
  5077. contraInteligenceBtn[0].onclick = function () {
  5078. panelSocial.screenSaver({
  5079. withFrases: true,
  5080. withMusic: true,
  5081. combinedArt: true,
  5082. })
  5083. }
  5084. //Boton Noticias. Editorial
  5085. /*
  5086. var editorialBtn = $('<div class="categsMenuButton">NOTICIAS. EDITORIAL</div>');
  5087. if (ltotalUtils.checkPermiso("personaje")) {
  5088. editorialBtn.append('<div class="btn_pescar_editorial" title="Crear nueva Noticia. Editorial"></div>');
  5089. $(".btn_pescar_editorial", editorialBtn)[0].onclick = function(_ev) {
  5090. _ev.stopPropagation();
  5091. hideCategsMenu();
  5092. fisher.newLooseNote();
  5093. }
  5094. }
  5095. categsMenuBox[0]["libros"].unshift(editorialBtn[0]);
  5096. editorialBtn[0].onclick = function() { panelSocial.openBookNotas(32, 12); }
  5097. */
  5098. //Botones particulares Musica
  5099. var inspLibrosBtn = $(
  5100. '<div class="categsMenuButton categ_musica cat_insplibros"><div class="categ_icon"></div><div class="categ_label">Inspirada en libros</div></div>',
  5101. )
  5102. categsMenuBox[0]["musica"].unshift(inspLibrosBtn[0])
  5103. inspLibrosBtn[0].onclick = function () {
  5104. var item = document.createElement("div")
  5105. item.className = "cell 10_0 cvLD"
  5106. panelSocial.clickSobreItem(item, "libros", that, {
  5107. extra_labels: 1,
  5108. noBanner: true,
  5109. insp_libros: 1,
  5110. })
  5111. }
  5112. var interpretesBtn = $(
  5113. '<div class="categsMenuButton categ_musica cat_interpretes"><div class="categ_icon"></div><div class="categ_label">Intérpretes</div></div>',
  5114. )
  5115. categsMenuBox[0]["musica"].unshift(interpretesBtn[0])
  5116. interpretesBtn[0].onclick = function () {
  5117. var item = document.createElement("div")
  5118. item.className = "cell 3_0,13,0 cvLD"
  5119. panelSocial.clickSobreItem(item, "libros", that, {
  5120. extra_labels: 1,
  5121. noBanner: true,
  5122. })
  5123. }
  5124. var compositoresBtn = $(
  5125. '<div class="categsMenuButton categ_musica cat_compositores"><div class="categ_icon"></div><div class="categ_label">Compositores</div></div>',
  5126. )
  5127. categsMenuBox[0]["musica"].unshift(compositoresBtn[0])
  5128. compositoresBtn[0].onclick = function () {
  5129. var item = document.createElement("div")
  5130. item.className = "cell 3_0,10,0 cvLD"
  5131. panelSocial.clickSobreItem(item, "libros", that, {
  5132. extra_labels: 1,
  5133. noBanner: true,
  5134. })
  5135. }
  5136. var musRandomBtn = $(
  5137. '<div class="categsMenuButton categ_musica cat_music_random"><div class="categ_icon"></div><div class="categ_label">Música aleatoria</div></div>',
  5138. )
  5139. categsMenuBox[0]["musica"].push(musRandomBtn[0])
  5140. musRandomBtn[0].onclick = function () {
  5141. panelSocial.ewallMusic("MosaicBooks")
  5142. }
  5143. var openArtMusic = function () {
  5144. panelSocial.screenSaver({ withArt: true, withMusic: true })
  5145. }
  5146. var openFotoMusic = function () {
  5147. panelSocial.screenSaver({ withFoto: true, withMusic: true })
  5148. }
  5149. var artmusRandomBtn = $(
  5150. '<div class="categsMenuButton categ_musica cat_art_music_random"><div class="categ_icon"></div><div class="categ_label">Arte y música aleatorios</div></div>',
  5151. )
  5152. categsMenuBox[0]["musica"].push(artmusRandomBtn[0])
  5153. artmusRandomBtn[0].onclick = openArtMusic
  5154. var fotomusRandomBtn = $(
  5155. '<div class="categsMenuButton categ_musica cat_foto_music_random"><div class="categ_icon"></div><div class="categ_label">Fotografía y música aleatorios</div></div>',
  5156. )
  5157. categsMenuBox[0]["musica"].push(fotomusRandomBtn[0])
  5158. fotomusRandomBtn[0].onclick = openFotoMusic
  5159. //Botones particulares Arte
  5160. categsMenuBox[0]["arte"] = []
  5161. var paisesBtn = $(
  5162. '<div class="categsMenuButton categ_arte cat_paises"><div class="categ_icon"></div><div class="categ_label">Por países</div></div>',
  5163. )
  5164. categsMenuBox[0]["arte"].unshift(paisesBtn[0])
  5165. paisesBtn[0].onclick = function () {
  5166. var item = document.createElement("div")
  5167. item.className = "cell 6_0,3 cvLD"
  5168. panelSocial.clickSobreItem(item, "libros", that, {
  5169. extra_labels: 1,
  5170. noBanner: true,
  5171. paises: 1,
  5172. queryArt: 1,
  5173. })
  5174. }
  5175. var fotografiaBtn = $(
  5176. '<div class="categsMenuButton categ_arte cat_fotografia"><div class="categ_icon"></div><div class="categ_label">Fotografía</div></div>',
  5177. )
  5178. categsMenuBox[0]["arte"].unshift(fotografiaBtn[0])
  5179. fotografiaBtn[0].onclick = function () {
  5180. var item = document.createElement("div")
  5181. item.className = "cell 6_0,2 cvLD"
  5182. panelSocial.clickSobreItem(item, "libros", that, {
  5183. extra_labels: 1,
  5184. noBanner: true,
  5185. fotografia: 1,
  5186. queryArt: 1,
  5187. })
  5188. }
  5189. var inspLibrosArtBtn = $(
  5190. '<div class="categsMenuButton categ_arte cat_insplibrosart"><div class="categ_icon"></div><div class="categ_label">Inspirado en libros </div></div>',
  5191. )
  5192. categsMenuBox[0]["arte"].unshift(inspLibrosArtBtn[0])
  5193. inspLibrosArtBtn[0].onclick = function () {
  5194. var item = document.createElement("div")
  5195. item.className = "cell 6_0,1 cvLD"
  5196. panelSocial.clickSobreItem(item, "libros", that, {
  5197. extra_labels: 1,
  5198. noBanner: true,
  5199. insp_libros: 1,
  5200. queryArt: 1,
  5201. })
  5202. }
  5203. var artistasBtn = $(
  5204. '<div class="categsMenuButton categ_arte cat_artistas"><div class="categ_icon"></div><div class="categ_label">Artistas</div></div>',
  5205. )
  5206. categsMenuBox[0]["arte"].unshift(artistasBtn[0])
  5207. artistasBtn[0].onclick = function () {
  5208. var item = document.createElement("div")
  5209. item.className = "cell 3_0,6,0 cvLD"
  5210. panelSocial.clickSobreItem(item, "libros", that, {
  5211. extra_labels: 1,
  5212. noBanner: true,
  5213. })
  5214. }
  5215. var artmusRandomBtn2 = artmusRandomBtn.clone()
  5216. var fotomusRandomBtn2 = fotomusRandomBtn.clone()
  5217. artmusRandomBtn2[0].onclick = openArtMusic
  5218. fotomusRandomBtn2[0].onclick = openFotoMusic
  5219. categsMenuBox[0]["arte"].push(artmusRandomBtn2[0])
  5220. categsMenuBox[0]["arte"].push(fotomusRandomBtn2[0])
  5221. if (ltotalUtils.checkPermiso("adminarte")) {
  5222. var arteAnotadoBtn = $(
  5223. '<div class="categsMenuButton categ_arte cat_arte_anotado"><div class="categ_icon"></div><div class="categ_label">Arte anotado</div></div>',
  5224. )
  5225. categsMenuBox[0]["arte"].push(arteAnotadoBtn[0])
  5226. arteAnotadoBtn[0].onclick = function () {
  5227. panelSocial.screenSaver({ arteAnotado: true })
  5228. }
  5229. }
  5230. categsMenuBox.append(
  5231. '<div class="categsMenuBoxContentScrollable"><div class="categsMenuBoxContent"></div></div>',
  5232. )
  5233. var toggling = false
  5234. var currentService = ""
  5235. categsMenuBox[0].scrolles = { libros: 0, musica: 0, arte: 0 }
  5236. var scrollCB = function () {
  5237. if (!toggling) {
  5238. categsMenuBox[0].scrolles[currentService] = scrollableBox.scrollTop
  5239. categsScroll.repaintContain()
  5240. }
  5241. }
  5242. var scrollableBox = $(".categsMenuBoxContentScrollable", categsMenuBox)[0]
  5243. var categsScroll = new ScrollSyc({
  5244. hostDiv: categsMenuBox[0],
  5245. scrollDiv: scrollableBox,
  5246. claseScroll: "categsMenuScroll categsMenuScrollPart",
  5247. position: "right",
  5248. callback: scrollCB,
  5249. })
  5250. var scrollCont = categsScroll.getContain()
  5251. $(scrollCont).find("*").addClass("categsMenuScrollPart")
  5252. $(scrollCont).css({ top: "2%", height: "96%" })
  5253. $(".boxScrollBtn", scrollCont).css({ "background-color": "transparent" })
  5254. $(".scrollBtn", scrollCont).css({ "background-color": "#A7B0B7" })
  5255. var binScrollSetts = { callback: scrollCB }
  5256. bindScroll(scrollableBox, binScrollSetts)
  5257. bindTouch(scrollableBox, {
  5258. start: function (px, py) {
  5259. $(this).stop()
  5260. },
  5261. move: function (dx, dy) {
  5262. this.scrollTop += dy
  5263. },
  5264. end: function (DX, DY, DT) {
  5265. if (DT < 400) {
  5266. var st = this.scrollTop - DY * 2
  5267. if (Math.abs(DY) > 0) {
  5268. $(this).animate(
  5269. { scrollTop: st },
  5270. { duration: 500, easing: "easeOutQuart" },
  5271. )
  5272. }
  5273. }
  5274. },
  5275. })
  5276. categsMenuBox[0].categLabel = ""
  5277. var btnsPilares = $([pilarLibros, pilarMusica, pilarArte])
  5278. btnsPilares.each(function () {
  5279. makeRoundButton(this)
  5280. $(".squared", this).append($(".txtpilar", this))
  5281. $(".right", this)[0].onclick = function (_ev) {
  5282. _ev.preventDefault()
  5283. _ev.stopPropagation()
  5284. $(".categsMenuToggle", this.parentNode).trigger("click")
  5285. }
  5286. })
  5287. btnsPilares.each(function () {
  5288. var btn = $(this)
  5289. var menuToggle = $('<div class="categsMenuToggle"></div>')
  5290. $(".piece.squared", btn).append(menuToggle)
  5291. menuToggle[0].onclick = function (_ev) {
  5292. _ev.stopPropagation()
  5293. var toggle = $(this)
  5294. hideMenu()
  5295. var categLabel = ""
  5296. var pilarBtn = $(this).parents(".pilarBtn").eq(0)
  5297. if (pilarBtn.hasClass("pilarlibros")) {
  5298. categLabel = "libros"
  5299. }
  5300. if (pilarBtn.hasClass("pilarmusica")) {
  5301. categLabel = "musica"
  5302. }
  5303. if (pilarBtn.hasClass("pilararte")) {
  5304. categLabel = "arte"
  5305. }
  5306. currentService = categLabel
  5307. $(".categsMenuBoxContent", categsMenuBox).html(
  5308. categsMenuBox[0][categLabel],
  5309. )
  5310. var topCont = 0
  5311. var leftCont = 0
  5312. var widthCont = 0
  5313. if (isSmartPhone) {
  5314. topCont = 145
  5315. widthCont = "100%"
  5316. } else if (isTablet) {
  5317. topCont = 135
  5318. leftCont = boxPilars.offsetLeft
  5319. widthCont = boxPilars.offsetWidth + 10 + "px"
  5320. } else {
  5321. topCont = 80
  5322. leftCont = pilarLibros.offsetLeft
  5323. widthCont =
  5324. pilarArte.offsetLeft + pilarArte.offsetWidth - leftCont + "px"
  5325. }
  5326. categsMenuBox.css({
  5327. top: topCont + "px",
  5328. left: leftCont + "px",
  5329. width: widthCont,
  5330. height: "calc(100% - " + topCont + "px)",
  5331. })
  5332. $(scrollCont).css({ display: "block" })
  5333. scrollableBox.scrollTop = categsMenuBox[0].scrolles[currentService]
  5334. categsScroll.repaintContain()
  5335. //La caja de las cetegorias que no crece mas de lo necesario
  5336. var winH = $(window).height()
  5337. var contH = winH - topCont
  5338. var categH = 60
  5339. var maxCategs = contH / categH
  5340. var categsCount = categsMenuBox[0][categLabel].length
  5341. if (categsCount < maxCategs) {
  5342. var newH = categH * categsCount
  5343. categsMenuBox.css({ height: newH + "px" })
  5344. }
  5345. $(".toggle_active", btnsPilares).removeClass("toggle_active")
  5346. var btnParent = menuToggle.parent().parent()
  5347. var roundeRight = $(".rounded.right", btnParent)
  5348. roundeRight.addClass("toggle_active")
  5349. menuToggle.addClass("toggle_active")
  5350. if (
  5351. categsMenuBox[0].categLabel == categLabel &&
  5352. $(categsMenuBox).is(":visible")
  5353. ) {
  5354. roundeRight.removeClass("toggle_active")
  5355. menuToggle.removeClass("toggle_active")
  5356. }
  5357. if (
  5358. categsMenuBox[0].categLabel == categLabel ||
  5359. !$(categsMenuBox).is(":visible")
  5360. ) {
  5361. toggling = true
  5362. $(categsMenuBox).slideToggle(function () {
  5363. if ($(categsMenuBox).is(":visible")) {
  5364. scrollableBox.scrollTop =
  5365. categsMenuBox[0].scrolles[currentService]
  5366. categsScroll.repaintContain()
  5367. toggling = false
  5368. }
  5369. })
  5370. }
  5371. categsMenuBox[0].categLabel = categLabel
  5372. }
  5373. //Click del pilar
  5374. $(".left, .squared", this).click(function () {
  5375. var serv = "libros"
  5376. var papaClass = $(this).parents(".pilarBtn")[0].className
  5377. if (papaClass.indexOf("musica") > -1) {
  5378. serv = "musica"
  5379. }
  5380. if (papaClass.indexOf("arte") > -1) {
  5381. serv = "arte"
  5382. }
  5383. that.clickSobrePilar(serv)
  5384. })
  5385. })
  5386. placeMainBtns()
  5387. }
  5388. this.makeRoundButton = function (_btn) {
  5389. makeRoundButton(_btn)
  5390. }
  5391. function makeRoundButton(_btn) {
  5392. var htmlPieces =
  5393. '<div class="layer_rounded"><div class="piece rounded left"></div><div class="piece rounded right"></div><div class="piece squared"></div></div>'
  5394. $(_btn).append(htmlPieces)
  5395. }
  5396. function hideCategsMenu(_extra) {
  5397. var btnsPilares = $([pilarLibros, pilarMusica, pilarArte])
  5398. $(".toggle_active", btnsPilares).removeClass("toggle_active")
  5399. var doAnim = true
  5400. if (_extra) {
  5401. if (_extra.no_animate) {
  5402. doAnim = false
  5403. }
  5404. }
  5405. if ($(categsMenuBox).is(":visible")) {
  5406. if (doAnim) {
  5407. categsMenuBox.slideToggle()
  5408. } else {
  5409. categsMenuBox.css({ display: "none" })
  5410. }
  5411. }
  5412. }
  5413. function activateSearch() {
  5414. if (!searchLT.touchbinded) {
  5415. $(searchLT).on("touchstart", function () {
  5416. $(this).focus()
  5417. })
  5418. searchLT.touchbinded = true
  5419. }
  5420. $(boxSearchMos).slideToggle(function () {
  5421. boxSearchMos.isReady = true
  5422. $(searchLT).trigger("touchstart")
  5423. })
  5424. if (ltotalOS.isIOS) {
  5425. $(searchLT).trigger("touchstart")
  5426. }
  5427. }
  5428. function deActivateSearch() {
  5429. $(".autocomplete-suggestions").hide()
  5430. $(".suggest_home_box").hide()
  5431. $(boxSearchMos).slideToggle(function () {
  5432. boxSearchMos.isReady = false
  5433. })
  5434. }
  5435. this.buscarLT = function (_wordsToSearch, _extra) {
  5436. buscarLT(_wordsToSearch, _extra)
  5437. }
  5438. function buscarLT(_wordsToSearch, _extra) {
  5439. $(searchLT).blur()
  5440. var words = $.trim($(searchLT).val())
  5441. if (_wordsToSearch && typeof _wordsToSearch == "string") {
  5442. words = _wordsToSearch
  5443. }
  5444. if ($(boxSearchMos).is(":visible") && boxSearchMos.isReady) {
  5445. deActivateSearch()
  5446. }
  5447. if (words.length > 0) {
  5448. var extraparams = { expandRelas: 1 }
  5449. jQuery.extend(extraparams, mosaico.SycCredentials)
  5450. try {
  5451. var xhr = ltotalOS.loadData("buscar", "", words, extraparams)
  5452. searchWords = words
  5453. $(gridBoxSmall).detach()
  5454. LPRemoveLabelAtTop()
  5455. deSelectPilares()
  5456. pilarSelected = "buscar"
  5457. servicio = "libros"
  5458. $(boxSearchMsg).css({ display: "block" }).text("Buscando...")
  5459. if (xhr) {
  5460. xhr.done(function (html) {
  5461. //Estadistica de buscador en interfaz eDesk
  5462. ltotalOS.statistics(84, words)
  5463. var proc = $("#proceso").html(html)
  5464. var cellsc = $(".cell", proc).length
  5465. filterBuscar(proc)
  5466. var msgHTML =
  5467. '<span class="items_counter">' + cellsc + "</span> resultados"
  5468. if (!isSmartPhone) {
  5469. msgHTML +=
  5470. ' de "' + words + '" en el catálogo general de la Biblioteca'
  5471. }
  5472. $(boxSearchMsg).css({ display: "block" }).html(msgHTML)
  5473. $(boxMosaic).addClass("withSearchMsg")
  5474. var itemc = proc.children().length
  5475. LPWrapItems(proc[0].children)
  5476. var labels = $(".cell_label", proc)
  5477. labels.each(function () {
  5478. var lbl = this
  5479. var items = $(lbl).nextUntil(".cell_label")
  5480. items.each(function () {
  5481. this.lbl = lbl
  5482. })
  5483. lbl.items = items
  5484. items.detach()
  5485. if (items.length > 30) {
  5486. lbl.fullItems = items
  5487. lbl.items = items.slice(0, 30)
  5488. }
  5489. $(lbl).after(lbl.items)
  5490. })
  5491. var backNavig = true
  5492. if (_extra && _extra.backNavig == false) {
  5493. backNavig = false
  5494. }
  5495. mosaico.createMosaic2(
  5496. proc[0].children,
  5497. servicio,
  5498. pilarSearch,
  5499. 0,
  5500. { backNav: backNavig },
  5501. )
  5502. mosaico.deleteMosaicCache("buscar_pilarSearch_0")
  5503. })
  5504. panelSocial.createLoaderItem(pilarSearch, xhr, null)
  5505. }
  5506. } catch (e) {}
  5507. }
  5508. }
  5509. function searchTXT() {
  5510. var label = this
  5511. var wds = $(".wds_lbl", label).text()
  5512. gridBoxSmall.searchTXTWords = wds
  5513. searchTXTWords = wds
  5514. var extra = {}
  5515. var id_lib_exception = label.className.match(/id_lib_exception_\d+/)
  5516. if (id_lib_exception) {
  5517. extra.id_lib_exception = id_lib_exception[0].match(/\d+/)[0]
  5518. }
  5519. var id_aut_exception = label.className.match(/id_aut_exception_\d+/)
  5520. if (id_aut_exception) {
  5521. extra.id_aut_exception = id_aut_exception[0].match(/\d+/)[0]
  5522. }
  5523. jQuery.extend(extra, mosaico.SycCredentials)
  5524. var xhr = ltotalOS.loadData("buscartexto", "txtsearch", wds, extra)
  5525. if (xhr) {
  5526. xhr.done(function (htmlData) {
  5527. if (panelSocial.selectedBook && settings.modePilars) {
  5528. return null
  5529. }
  5530. //Estadistica de busqueda de texto en interfaz eDesk
  5531. ltotalOS.statistics(85, wds)
  5532. if ($.trim(htmlData).length > 0) {
  5533. //Actualiza el contador de resultados
  5534. var count = 0
  5535. var proc = $("#proceso").html(htmlData)
  5536. $(".cell", proc).each(function () {
  5537. count += parseInt(
  5538. this.className.match(/counter_\d+/)[0].match(/\d+/)[0],
  5539. )
  5540. })
  5541. var itemCounter = $(".items_counter", boxSearchMsg)
  5542. itemCounter.text(parseInt(itemCounter.text()) + count)
  5543. filterBuscar(proc)
  5544. //Orden de los items de la seccion de libros
  5545. var labelLibros = $(".cell_label.tipo_item_txtsearch", proc)
  5546. var cellsArray = labelLibros.nextUntil(
  5547. ".cell_label.tipo_item_16, .cell_label.tipo_item_51",
  5548. )
  5549. cellsArray.sort(function (x, y) {
  5550. var cx = parseInt(
  5551. x.className.match(/counter_\d+/)[0].match(/\d+/)[0],
  5552. )
  5553. var cy = parseInt(
  5554. y.className.match(/counter_\d+/)[0].match(/\d+/)[0],
  5555. )
  5556. if (cy < cx) {
  5557. return -1
  5558. }
  5559. if (cy > cx) {
  5560. return 1
  5561. }
  5562. return 0
  5563. })
  5564. labelLibros = labelLibros.detach()
  5565. cellsArray = cellsArray.detach()
  5566. var restOfChildren = proc.children().detach()
  5567. proc.append(labelLibros)
  5568. proc.append(cellsArray)
  5569. proc.append(restOfChildren)
  5570. //Fin. Orden de los items de la seccion de libros
  5571. LPWrapItems(proc.children())
  5572. var labels = $(".cell_label", proc)
  5573. labels.each(function () {
  5574. var lbl = this
  5575. var items = $(lbl).nextUntil(".cell_label")
  5576. items.each(function () {
  5577. this.lbl = lbl
  5578. })
  5579. lbl.items = items
  5580. items.detach()
  5581. if (items.length > 30) {
  5582. lbl.fullItems = items
  5583. lbl.items = items.slice(0, 30)
  5584. }
  5585. $(lbl).after(lbl.items)
  5586. })
  5587. $(label).replaceWith(proc.children())
  5588. labels.each(function () {
  5589. configureLabel(this)
  5590. })
  5591. //diagramCellLabels();
  5592. //Trata de ajustar el último slider para que no se corte
  5593. setTimeout(function () {
  5594. configHorizGridBoxes()
  5595. }, 500)
  5596. } else {
  5597. $(".tag_label", label).html(
  5598. 'No hay resultados para <span class="wds_lbl">"' +
  5599. wds +
  5600. '"</span> en las páginas de los Libros',
  5601. )
  5602. }
  5603. })
  5604. panelSocial.createLoaderItem(label, xhr, null)
  5605. }
  5606. }
  5607. function filterBuscar(_proc) {
  5608. //Filtra items de la busqueda segun reglas arbitrarias
  5609. //El libro de la DIAN 4281 solo se ve en www.syc.com.co
  5610. var libDian = $(".1_4281, .4_4281\\,4348", _proc)
  5611. if (libDian[0] && location.href.indexOf("www.syc.com.co") == -1) {
  5612. libDian.remove()
  5613. }
  5614. }
  5615. function closeSearch() {
  5616. $(boxSearchMsg).css({ display: "none" })
  5617. $(boxMosaic).removeClass("withSearchMsg")
  5618. }
  5619. //Asigna etiquetas a elementos tipo Libro y Musica
  5620. function booksHoverLabel(item) {
  5621. if (item) {
  5622. var $item = $(item)
  5623. //Botones de accion contextuales
  5624. //Borrar libro de bitacora de lectura reciente
  5625. if ($item.hasClass("erase_bitac")) {
  5626. createBtnEraseBitac(item)
  5627. }
  5628. //Borrar libro de mis favoritos
  5629. if (item.erase_favorite) {
  5630. createBtnEraseFavorite(item)
  5631. }
  5632. //Borrar foto promo libro de mis favoritos
  5633. if (item.erase_foto_promo_libro) {
  5634. createBtnEraseFotoPromoLibro(item)
  5635. }
  5636. //Borrar libro regalo de mis favoritos
  5637. if (item.erase_regalo_libro) {
  5638. createBtnEraseRegaloLibro(item)
  5639. }
  5640. }
  5641. }
  5642. //Asigna etiquetas a elementos tipo Imagenes
  5643. function imagesHoverLabel(item) {
  5644. var imgin = $(".art_thumbnail", item)[0]
  5645. if (imgin) {
  5646. //Borrar imagen de bitacora de lectura reciente
  5647. if ($(item).hasClass("erase_bitac")) {
  5648. createBtnEraseBitac(item)
  5649. }
  5650. //Borrar imagen de mis favoritos
  5651. if (item.erase_favorite) {
  5652. createBtnEraseFavorite(item)
  5653. }
  5654. }
  5655. }
  5656. // Hover de un objeto.
  5657. function hoverElement(item) {
  5658. if (item.hoverElementEv) {
  5659. return null
  5660. }
  5661. var cellid = getCellID(item)
  5662. var tipo_item = cellid[0]
  5663. var id_item = cellid[1]
  5664. var proyValido = tipo_item == 27 && id_item > 0
  5665. var preZoom = function () {
  5666. if (that.hoveredMosaicElement != item) {
  5667. destroyHoverLabel(that.hoveredMosaicElement)
  5668. }
  5669. clearTimeout(timerTouchingItem)
  5670. timerTouchingItem = setTimeout(zoomItem, 800)
  5671. }
  5672. var zoomItem = function () {
  5673. if ($(item).parent().hasClass("zoomed_item")) {
  5674. return null
  5675. }
  5676. that.hoveredMosaicElement = item
  5677. var w = item.parentNode.offsetWidth
  5678. var l = parseInt($(item).parent().css("left"))
  5679. var r = l + w
  5680. item.parentNode.leftMosa = l + "px"
  5681. var offsetw = (0.8 * w) / 2
  5682. var lf = l - offsetw
  5683. var rf = r + offsetw
  5684. if (lf < 0) {
  5685. l = l + offsetw
  5686. $(item)
  5687. .parent()
  5688. .animate({ left: l + "px" }, 200)
  5689. }
  5690. if (rf > gridBoxSmall.offsetWidth) {
  5691. l = l - offsetw
  5692. $(item)
  5693. .parent()
  5694. .animate({ left: l + "px" }, 200)
  5695. }
  5696. $(item).parent().css({
  5697. transition: "transform .2s",
  5698. transform: "scale(1.8)",
  5699. "z-index": "1",
  5700. })
  5701. $(item).parent().prepend('<div class="caratula_back_cont"></div>')
  5702. $(item).parent().addClass("zoomed_item")
  5703. if (isTouch) {
  5704. $(item).parent()[0].justZoomed = true
  5705. }
  5706. }
  5707. var reduceItem = function (e) {
  5708. var isEraseBtn = $(e.relatedTarget).is(
  5709. ".erase_bitac_btn, .erase_favorite_btn, .erase_foto_promo_libro_btn, .erase_regalo_libro_btn",
  5710. )
  5711. if (!isEraseBtn) {
  5712. destroyHoverLabel(item)
  5713. }
  5714. }
  5715. if (
  5716. tipo_item == 1 ||
  5717. tipo_item == 3 ||
  5718. tipo_item == 4 ||
  5719. tipo_item == 10 ||
  5720. tipo_item == 17 ||
  5721. proyValido ||
  5722. tipo_item == 32 ||
  5723. tipo_item == 45 ||
  5724. tipo_item == 51 ||
  5725. tipo_item == "mydownld"
  5726. ) {
  5727. if (isTouch) {
  5728. bindTouch(item, bindTouchHandleHoverLabel(item, "BOOK", zoomItem))
  5729. } else {
  5730. item.onmouseover = function () {
  5731. booksHoverLabel(item)
  5732. //preZoom();
  5733. }
  5734. item.onmouseout = function (e) {
  5735. //reduceItem(e);
  5736. }
  5737. }
  5738. }
  5739. if (tipo_item == 6) {
  5740. if (isTouch) {
  5741. bindTouch(item, bindTouchHandleHoverLabel(item, "IMAGE", zoomItem))
  5742. } else {
  5743. item.onmouseover = function () {
  5744. imagesHoverLabel(item)
  5745. //preZoom();
  5746. }
  5747. item.onmouseout = function (e) {
  5748. //reduceItem(e);
  5749. }
  5750. }
  5751. }
  5752. item.hoverElementEv = true
  5753. }
  5754. function createBtnEraseBitacLabel(_label, _tipo) {
  5755. var elemBtcLabel = document.createElement("div")
  5756. $(elemBtcLabel).addClass("erase_label_bitac_btn")
  5757. var recienMsg = {
  5758. 1: "todos los libros",
  5759. 6: "todas las imágenes",
  5760. 10: "todas las piezas musicales",
  5761. 45: "todas las palabras",
  5762. 51: "todos los videos",
  5763. }
  5764. elemBtcLabel.title = "Eliminar " + recienMsg[_tipo] + " recientes"
  5765. $(".erase_label_bitac_btn", _label).remove()
  5766. $(_label).prepend(elemBtcLabel)
  5767. elemBtcLabel.onclick = function (ev) {
  5768. if (
  5769. _label.items.length == 1 &&
  5770. _label.items[0].className.indexOf("minibookhelp") > -1
  5771. ) {
  5772. return
  5773. }
  5774. ev.preventDefault()
  5775. ev.stopPropagation()
  5776. var dialogo = new DialogueLM({
  5777. show: true,
  5778. ModoBtn: true,
  5779. btnClose: true,
  5780. btnCancelar: "Cancelar",
  5781. btnAceptar: "Aceptar",
  5782. texto: "¿Desea eliminar " + recienMsg[_tipo] + " recientes?",
  5783. fnAceptar: function () {
  5784. if (_tipo == 45) {
  5785. _tipo = 16
  5786. }
  5787. $.each(_label.items, function () {
  5788. if ($(this).hasClass("mydownld")) {
  5789. var idDld = getCellID(this)[1]
  5790. var docID = idDld
  5791. var accion = "DeleteRecentBook"
  5792. if (!$(this).hasClass("format_epub")) {
  5793. docID = idDld.replace("pdf", "")
  5794. accion = "DeleteRecentPDFDocumento"
  5795. }
  5796. var cmdObj = {
  5797. Module: "OfflineApp",
  5798. Action: accion,
  5799. Parameters: ["" + docID],
  5800. }
  5801. panelSocial.executeNative(cmdObj)
  5802. }
  5803. })
  5804. var url = "/ltotal/lector/borrar_bitacora.jsp"
  5805. var queryURL = ltotalOS.getPostURL(url)
  5806. var params = {
  5807. idLibro: "-1",
  5808. idTrad: "-1",
  5809. tipo_comp: _tipo,
  5810. palabra: "",
  5811. ltotalurl: url,
  5812. caso: "2",
  5813. }
  5814. jQuery.extend(params, that.SycCredentials)
  5815. params = $.trim(decodeURIComponent($.param(params)))
  5816. $.post(queryURL, params).done(function () {
  5817. reloadLabel(_label)
  5818. })
  5819. },
  5820. fnCancelar: function () {},
  5821. })
  5822. if (isSmartPhone) {
  5823. $(".boxDialogue", dialogo.getContain()).css({
  5824. width: "100%",
  5825. padding: "20px 0px 0px",
  5826. })
  5827. }
  5828. }
  5829. }
  5830. function destroyHoverLabel(parent) {
  5831. //$(boxHoverLabelMosaic).detach();
  5832. clearTimeout(timerTouchingItem)
  5833. if ($(parent).parent().hasClass("zoomed_item")) {
  5834. var cssObj = { transform: "", "z-index": "" }
  5835. if (parent && parent.parentNode && parent.parentNode.leftMosa) {
  5836. cssObj.left = parent.parentNode.leftMosa
  5837. }
  5838. $(parent).parent().css(cssObj)
  5839. $(".caratula_back_cont", $(parent).parent()).remove()
  5840. $(parent).parent().removeClass("zoomed_item")
  5841. $(parent).parent()[0].justZoomed = false
  5842. //setTimeout(function() {
  5843. //if (!panelSocial.selectedBook) {
  5844. // that.createMosaic(null);
  5845. //}
  5846. //}, 300);
  5847. }
  5848. }
  5849. this.destroyHoverLabel = function (parent) {
  5850. destroyHoverLabel(parent)
  5851. }
  5852. function createBtnEraseBitac(item) {
  5853. if (!btnHoverEraseBitac) {
  5854. btnHoverEraseBitac = document.createElement("div")
  5855. $(btnHoverEraseBitac).addClass("erase_bitac_btn")
  5856. btnHoverEraseBitac.title = "Eliminar de mis lecturas recientes"
  5857. btnHoverEraseBitac.onclick = deleteBitacora
  5858. }
  5859. $(item).append(btnHoverEraseBitac)
  5860. }
  5861. function createBtnEraseFavorite(item) {
  5862. if (!btnHoverEraseFavorite) {
  5863. btnHoverEraseFavorite = document.createElement("div")
  5864. $(btnHoverEraseFavorite).addClass("erase_favorite_btn")
  5865. btnHoverEraseFavorite.title = "Eliminar de mis favoritos"
  5866. btnHoverEraseFavorite.onclick = deleteFavorite
  5867. }
  5868. $(item).append(btnHoverEraseFavorite)
  5869. }
  5870. function createBtnEraseFotoPromoLibro(item) {
  5871. if (!btnHoverEraseFotoPromoLibro) {
  5872. btnHoverEraseFotoPromoLibro = document.createElement("div")
  5873. $(btnHoverEraseFotoPromoLibro).addClass("erase_foto_promo_libro_btn")
  5874. btnHoverEraseFotoPromoLibro.title = "Eliminar de mis favoritos"
  5875. btnHoverEraseFotoPromoLibro.onclick = deleteFotoPromoLibro
  5876. }
  5877. $(item).append(btnHoverEraseFotoPromoLibro)
  5878. }
  5879. function createBtnEraseRegaloLibro(item) {
  5880. if (!btnHoverEraseRegaloLibro) {
  5881. btnHoverEraseRegaloLibro = document.createElement("div")
  5882. $(btnHoverEraseRegaloLibro).addClass("erase_regalo_libro_btn")
  5883. btnHoverEraseRegaloLibro.title = "Eliminar de mis favoritos"
  5884. btnHoverEraseRegaloLibro.onclick = deleteRegaloLibro
  5885. }
  5886. $(item).append(btnHoverEraseRegaloLibro)
  5887. }
  5888. function bindTouchHandleHoverLabel(item, elem, zoomItem) {
  5889. return {
  5890. start: function (px, py, ev) {
  5891. if (isTouchingItem) {
  5892. return null
  5893. }
  5894. clearTimeout(timerTouchingItem)
  5895. isTouchingItem = true
  5896. if (that.hoveredMosaicElement != item) {
  5897. destroyHoverLabel(that.hoveredMosaicElement)
  5898. }
  5899. timerTouchingItem = setTimeout(function () {
  5900. if (isTouchingItem) {
  5901. clearTimeout(timerDestroyHoverLabel)
  5902. ev.preventDefault()
  5903. ev.stopPropagation()
  5904. if (elem == "BOOK") {
  5905. booksHoverLabel(item)
  5906. }
  5907. if (elem == "IMAGE") {
  5908. imagesHoverLabel(item)
  5909. }
  5910. //zoomItem();
  5911. }
  5912. }, 800)
  5913. },
  5914. move: function (dx, dy) {
  5915. clearTimeout(timerTouchingItem)
  5916. },
  5917. end: function (DX, DY, DT, ev) {
  5918. isTouchingItem = false
  5919. setTimeout(function () {
  5920. destroyHoverLabel(item)
  5921. }, 200)
  5922. },
  5923. }
  5924. }
  5925. function createCaratulaBanner(_bnnr, _opts) {
  5926. var general = true
  5927. if (!_bnnr || !$(_bnnr).hasClass("caratula_banner")) {
  5928. return null
  5929. }
  5930. if ($(_bnnr).hasClass("banner_destacados")) {
  5931. mosaicBanner.createMosaicBannerDestacados(_bnnr, _opts)
  5932. general = false
  5933. }
  5934. if (general) {
  5935. mosaicBanner.createMosaicBanner(_bnnr, _opts, gridBox, that)
  5936. }
  5937. }
  5938. function createCaratulaDashboard(_dash, _opts) {
  5939. ltotalUtils.loadScript("/estaticosED/files/js/ltotal/panelDashboard.js")
  5940. panelDashboard.createMosaicDashboard(_dash, _opts ? _opts : {})
  5941. }
  5942. this.setMosaicCache = function (_opts) {
  5943. //Cachea el estado del mosaico
  5944. if (lastPilarItemSelected) {
  5945. if (
  5946. gridBoxSmall.hasChildNodes() &&
  5947. !$(gridBoxSmall).hasClass("no_cache")
  5948. ) {
  5949. var cacheExcept = { libros_dashboard_dashboard_x_dashgen_1: true }
  5950. var st = gridBoxSmall.scrollTopValue
  5951. var html = $(gridBoxSmall).detach()
  5952. if (!cacheExcept[lastPilarItemSelected]) {
  5953. mosaicCache[lastPilarItemSelected] = [html, st]
  5954. }
  5955. if (_opts.backNav) {
  5956. that.setBackNavigation()
  5957. }
  5958. }
  5959. if ($(gridBoxSmall).hasClass("no_cache")) {
  5960. $(gridBoxSmall).remove()
  5961. }
  5962. }
  5963. }
  5964. this.getMosaicCache = function (_pilar, _item) {
  5965. var itemID = getCellID(_item).join("_")
  5966. var xParms = _item.className.match(/x_\w+_\w+/g)
  5967. $.each(xParms, function () {
  5968. itemID += "_" + this
  5969. })
  5970. var cache = mosaicCache[_pilar + "_" + itemID]
  5971. return cache
  5972. }
  5973. this.deleteMosaicCache = function (_idItem) {
  5974. var cache = mosaicCache[_idItem]
  5975. if (cache) {
  5976. /*if (typeof cache[0] == "object" && cache[0].hasClass("gridBoxSmall")) {
  5977. cache[0].remove();
  5978. }*/
  5979. delete mosaicCache[_idItem]
  5980. }
  5981. }
  5982. this.setBackNavigation = function () {
  5983. //Controla que no se repita el mismo item seguido en la hitoria
  5984. if (mosaicNavigation.length > 0) {
  5985. var last = mosaicNavigation[mosaicNavigation.length - 1]
  5986. if (last[0] == lastPilarItemSelected) {
  5987. return null
  5988. }
  5989. }
  5990. mosaicNavigation.push([
  5991. lastPilarItemSelected,
  5992. lastServiceSelected,
  5993. lastItemSelected,
  5994. ])
  5995. $(backMosaic).css({ display: "block" })
  5996. history.pushState(1, null, null)
  5997. if (settings.backNavigationFunc) {
  5998. settings.backNavigationFunc()
  5999. }
  6000. }
  6001. function doBackNavigation() {
  6002. LPRemoveLabelAtTop()
  6003. var last = mosaicNavigation.pop()
  6004. if (last) {
  6005. var cacheAddr = last[0]
  6006. if (cacheAddr == "item_palabra_flex") {
  6007. goHome()
  6008. return true
  6009. }
  6010. pilarSelected = cacheAddr.split("_")[0]
  6011. servicio = last[1]
  6012. var item = last[2]
  6013. var cache = mosaicCache[cacheAddr]
  6014. if (cache) {
  6015. var html = cache[0]
  6016. var mosaicTop = cache[1]
  6017. mosaico.createMosaic2(html, servicio, item, mosaicTop, {
  6018. backNav: false,
  6019. })
  6020. configHorizGridBoxes()
  6021. }
  6022. if (mosaicNavigation.length == 0) {
  6023. if (settings.endBackNavigationFunc) {
  6024. settings.endBackNavigationFunc()
  6025. }
  6026. }
  6027. return true
  6028. }
  6029. return false
  6030. }
  6031. this.getBackNavigation = function () {
  6032. if (!settings.modePilars) {
  6033. return doBackNavigation()
  6034. }
  6035. //Cuando se esta visualizando un libro en escritorio, restaura el ultimo mosaico
  6036. var gridB = $(".gridBox", boxMosaic)[0]
  6037. if (!gridB) {
  6038. restoreLastMosaic()
  6039. return true
  6040. }
  6041. //modalviewer
  6042. var mdLT = $(".modalViewerLT", panelSocial.bodyDiv)
  6043. if (mdLT[0]) {
  6044. history.pushState(1, null, null)
  6045. $(".closeModalViewer", mdLT).trigger("click")
  6046. return true
  6047. }
  6048. //Cerrar visor de imagenes
  6049. var bvi = $(".boxViewerImg", panelSocial.bodyDiv)
  6050. if (bvi[0]) {
  6051. $(".closeViewer", bvi).trigger("click")
  6052. return true
  6053. }
  6054. //diccionario
  6055. var dicctotal = $("#dicc_total")
  6056. if (dicctotal[0]) {
  6057. $(".control.close", dicctotal).trigger("click")
  6058. return true
  6059. }
  6060. if (isTouch && $(boxMosaicFull).is(":visible")) {
  6061. //Morphology
  6062. var korpuz = panelSocial.selectedBook.corpus
  6063. if (korpuz && korpuz.activated) {
  6064. korpuz.close()
  6065. return true
  6066. }
  6067. $(boxMosaicFull).css({ display: "none" }).empty()
  6068. $(boxTabs).css({ display: "none" }).empty()
  6069. restoreLastMosaic()
  6070. history.pushState(1, null, null)
  6071. return true
  6072. }
  6073. var last = doBackNavigation()
  6074. if (last) {
  6075. deSelectPilares()
  6076. $(".pilar" + pilarSelected, boxBread).addClass("pilarSelec")
  6077. $(".pilar" + pilarSelected, boxPilars).addClass("pilarSelec")
  6078. if (mosaicNavigation.length == 0) {
  6079. resetBackNavigation()
  6080. }
  6081. return true
  6082. }
  6083. return false
  6084. }
  6085. this.resetCache = function () {
  6086. resetCache()
  6087. }
  6088. function resetCache() {
  6089. mosaicCache = []
  6090. }
  6091. this.resetBackNavigation = function () {
  6092. resetBackNavigation()
  6093. }
  6094. function resetBackNavigation() {
  6095. mosaicNavigation = []
  6096. $(backMosaic).css({ display: "" })
  6097. }
  6098. this.getSearchWords = function () {
  6099. $(searchLT).val(searchWords)
  6100. return searchWords
  6101. }
  6102. this.getSearchTXTWords = function () {
  6103. return gridBoxSmall.searchTXTWords
  6104. }
  6105. function shuffleArray(a) {
  6106. var j, x
  6107. for (var i = a.length; i; --i) {
  6108. j = Math.floor(Math.random() * i)
  6109. x = a[i - 1]
  6110. a[i - 1] = a[j]
  6111. a[j] = x
  6112. }
  6113. return a
  6114. }
  6115. function diagramCellLabels() {
  6116. if (!gridBoxSmall) {
  6117. return
  6118. }
  6119. gridBoxSmall.cell_labels = []
  6120. $(".cell_label", gridBoxSmall).each(function (il, la) {
  6121. gridBoxSmall.cell_labels.push(la)
  6122. if (il == 0) {
  6123. var papaModal = $(la).parents(".modalViewerLT")[0]
  6124. var mt0 = isTouch ? 130 : 0
  6125. if (papaModal) {
  6126. mt0 = 0
  6127. }
  6128. $(la).css({ "margin-top": mt0 + "px" })
  6129. } else {
  6130. var prevItem = la.previousSibling
  6131. if (
  6132. $(la).is(".banners_banners, .mibliblio_0") ||
  6133. $(prevItem).is(
  6134. ".mibibliocell, .randombtncell, .horiGridBox, .caratula_banner",
  6135. )
  6136. ) {
  6137. $(la).css({ "margin-top": "50px" })
  6138. } else {
  6139. $(la).css({ "margin-top": "" })
  6140. }
  6141. }
  6142. //Margen Top de la primera linea de items
  6143. if (
  6144. !$(la).is(
  6145. ".21_0, .banners_banners, .mibliblio_0, .24_1010, .24_66, .cells_semihidden",
  6146. ) &&
  6147. la.items &&
  6148. la.items.length > 0
  6149. ) {
  6150. $(la.itemsTop).css({ "margin-top": "" })
  6151. la.itemsTop = []
  6152. //NOTA!!!!!! OJO!!!!
  6153. //Utilizar gridBox.NIPAL y gridBox.NIDASH para alinear las palabras y los dashboards!!
  6154. //-----------------------------------------------!!!!!!
  6155. var nItems = gridBox.NI
  6156. //if ($(la).hasClass("dashboard_0")) { nItems = gridBox.NIDASH; }
  6157. for (var idx = 1; idx <= la.items.length; idx++) {
  6158. if (idx <= nItems) {
  6159. var itt = la.items[idx - 1]
  6160. $(itt).css({ "margin-top": "20px" })
  6161. la.itemsTop.push(itt)
  6162. }
  6163. if (idx > nItems) {
  6164. break
  6165. }
  6166. }
  6167. }
  6168. })
  6169. }
  6170. function loadDataCellLabel(_label) {
  6171. if ($(_label).hasClass("autotxtsearch")) {
  6172. $(_label).removeClass("autotxtsearch")
  6173. searchTXT.call(_label)
  6174. return
  6175. }
  6176. if (!$(_label).hasClass("load_items")) {
  6177. return
  6178. }
  6179. $(_label).removeClass("load_items")
  6180. var data = getLabelID(_label)
  6181. var tipo_item = data[0]
  6182. var id_item = data[1]
  6183. if (tipo_item == "mydownld") {
  6184. var cmdObj = {
  6185. Module: "OfflineApp",
  6186. Action: "DownloadedBooks",
  6187. Callback: "panelSocial.mosaico.downloadsMosaicCallback",
  6188. }
  6189. return panelSocial.executeNative(cmdObj)
  6190. }
  6191. var parentNode = _label.parentNode
  6192. //Concatena parametros extra codificados con el patron /x_\w+_\w+/g
  6193. var extraparams = { expandRelas: 1 }
  6194. if ($(_label).hasClass("extra_labels")) {
  6195. extraparams.extra_labels = 1
  6196. }
  6197. var extraData = _label.className.match(/x_\w+_\w+/g)
  6198. if (extraData != null) {
  6199. $.each(extraData, function () {
  6200. var xd = this.replace("x_", "").split("_")
  6201. extraparams[xd[0]] = xd[1]
  6202. })
  6203. }
  6204. jQuery.extend(extraparams, mosaico.SycCredentials)
  6205. try {
  6206. var xhr = ltotalOS
  6207. .loadData(servicio, tipo_item, id_item, extraparams)
  6208. .done(function (htmlData) {
  6209. var proc = $("#proceso").html(htmlData)
  6210. var cells = $(".cell", proc).detach()
  6211. var rec_novedad = $(".rec_novedad", proc).detach()
  6212. if (cells.length == 0) {
  6213. cells = $(".item_to_load", proc)
  6214. .removeClass("item_to_load")
  6215. .detach()
  6216. }
  6217. var labelVivo = true
  6218. if (cells.length == 0) {
  6219. labelVivo = false
  6220. }
  6221. //Elimina nuevos rotulos
  6222. var newLabels = $(".cell_label", proc)
  6223. if ($(_label).hasClass("kill_extra_cell_labels")) {
  6224. newLabels.remove()
  6225. newLabels = null
  6226. }
  6227. //Reemplaza rotulo por el nuevo
  6228. if ($(_label).hasClass("replace_with_new_label") && labelVivo) {
  6229. var newLink = newLabels[0].className.match(/link_.+_link/)
  6230. if (newLink) {
  6231. $(_label).addClass(newLink[0])
  6232. }
  6233. $(".tag_label", _label).html($(".tag_label", newLabels[0]).html())
  6234. newLabels.remove()
  6235. newLabels = null
  6236. }
  6237. if (newLabels) {
  6238. newLabels
  6239. .each(function () {
  6240. this.items = $(this).nextUntil(".cell_label").detach()
  6241. })
  6242. .detach()
  6243. }
  6244. //Cache del aleatorio de los items
  6245. if ($(_label).hasClass("shuffle_items") && cells.length > 0) {
  6246. shuffleArray(cells)
  6247. }
  6248. //Simula un "label" o "slider" infinito multiplicando los items originales
  6249. if ($(_label).hasClass("multiply_infinite") && cells.length >= 10) {
  6250. var origCells = cells.clone()
  6251. for (var im = 1; im <= 20; im++) {
  6252. cells = cells.add(origCells.clone())
  6253. }
  6254. }
  6255. //Post-procesa items
  6256. if (tipo_item == 18) {
  6257. cells.addClass("erase_bitac")
  6258. createBtnEraseBitacLabel(_label, id_item)
  6259. if (panelSocial.hasOfflineBooks() && id_item == 1) {
  6260. $(_label).addClass("mydownld")
  6261. _label.itemsMixDownloads = cells
  6262. cells = $()
  6263. var cmdObj = {
  6264. Module: "OfflineApp",
  6265. Action: "RecentBooks",
  6266. Callback: "panelSocial.mosaico.recentBooksDownloadedCallback",
  6267. }
  6268. panelSocial.executeNative(cmdObj)
  6269. }
  6270. }
  6271. if (tipo_item == 44) {
  6272. cells.each(function () {
  6273. //Los libros foto_promo y regalo_libro estan en la seccion de Mis Favoritos
  6274. var cfp = hasClassRegex(/foto_promo_libro_\d+/, this)
  6275. if (cfp) {
  6276. this.erase_foto_promo_libro = true
  6277. }
  6278. var crl = hasClassRegex(/regalo_libro_\d+/, this)
  6279. if (crl) {
  6280. this.erase_regalo_libro = true
  6281. }
  6282. if (!cfp && !crl && !$(this).hasClass("lib_priv")) {
  6283. this.erase_favorite = true
  6284. }
  6285. })
  6286. }
  6287. $(_label)
  6288. .removeClass("counter_0")
  6289. .addClass("counter_" + cells.length)
  6290. LPWrapItems(cells)
  6291. cells.each(function () {
  6292. this.lbl = _label
  6293. })
  6294. if (cells.length > 30) {
  6295. _label.fullItems = cells
  6296. cells = cells.slice(0, 30)
  6297. }
  6298. _label.items = cells
  6299. $(_label).append(rec_novedad)
  6300. $(_label).after(cells)
  6301. //Adjunta nuevos rotulos
  6302. if (newLabels && newLabels.length > 0) {
  6303. newLabels.each(function () {
  6304. //$(this).after(this.items);
  6305. cells.last().after(this)
  6306. })
  6307. LPWrapItems(newLabels)
  6308. }
  6309. configureLabel(_label)
  6310. diagramCellLabels()
  6311. preloadItems(cells[0])
  6312. if ($(_label).is(".banners_banners")) {
  6313. mosaico.activateLabelAnim(_label)
  6314. }
  6315. })
  6316. panelSocial.createLoaderItem(_label, xhr, {
  6317. timeOutFN: function () {
  6318. $(_label).addClass("load_items")
  6319. },
  6320. })
  6321. } catch (e) {
  6322. $(_label).addClass("load_items")
  6323. }
  6324. }
  6325. function LPWrapItemCaratula(_item, _itemClase) {
  6326. var div = document.createElement("div")
  6327. div.className = _item.className
  6328. div.style.display = "block"
  6329. $(div).append($(_item).children())
  6330. _item.className = _itemClase
  6331. _item.appendChild(div)
  6332. }
  6333. function LPCountCounters(_items) {
  6334. var counter = 0
  6335. $.each(_items, function () {
  6336. var c = this
  6337. if (c) {
  6338. var cClass = c.className.match(/counter_\d+/)
  6339. if (cClass && cClass[0]) {
  6340. counter += parseInt(cClass[0].match(/\d+/)[0])
  6341. }
  6342. }
  6343. })
  6344. return counter
  6345. }
  6346. function LPRemoveLabelAtTop() {
  6347. $(gridBox.labelAtTop).remove()
  6348. gridBox.labelAtTop = null
  6349. }
  6350. function LPPutLabelAtTop(_label) {
  6351. LPRemoveLabelAtTop()
  6352. var gBSmallParent =
  6353. _label.parentNode && _label.parentNode.parentNode ? true : false
  6354. //Solo pone labels si esta desplegado y el label tiene padre
  6355. if (!$(_label).hasClass("cells_semihidden") && gBSmallParent) {
  6356. gridBox.labelAtTop = $(_label).clone()[0]
  6357. gridBox.labelAtTop.label = _label
  6358. var topHeaderTop = $(boxTopHeader).hasClass("ontop")
  6359. var mt0 = isTouch && !topHeaderTop ? 130 : 0
  6360. if (isTouch && $(boxSearchMsg).is(":visible") && topHeaderTop) {
  6361. mt0 += 22
  6362. }
  6363. $(gridBox.labelAtTop).css({
  6364. position: "absolute",
  6365. visibility: "visible",
  6366. top: mt0 + "px",
  6367. "margin-top": "0",
  6368. })
  6369. gridBox.labelAtTop.onclick = function () {
  6370. $(_label).trigger("click")
  6371. }
  6372. //Boton de borrar Historial
  6373. $(".erase_label_bitac_btn", gridBox.labelAtTop).click(function (_ev) {
  6374. _ev.stopPropagation()
  6375. $(".erase_label_bitac_btn", _label).trigger("click")
  6376. })
  6377. $(gridBox).parent().append(gridBox.labelAtTop)
  6378. gridBox.labelAtTop.items = _label.items
  6379. }
  6380. }
  6381. function LPShowLabelCounter() {
  6382. var label = this
  6383. var $label = $(label)
  6384. var isLabelFlex = $label.is(".21_0")
  6385. $label.removeClass("has_more_cells")
  6386. var gbh = gridBox.offsetHeight
  6387. var gbsh = gridBoxSmall.scrollHeight
  6388. var counterDelta = 0
  6389. var items = label.fullItems ? label.fullItems : label.items
  6390. var NI = gridBox.NI
  6391. var isLabelPaldic = $label.is(".18_45, .44_45")
  6392. if (isLabelPaldic) {
  6393. NI = gridBox.NIPAL
  6394. }
  6395. var sl = label.hGrid ? label.hGrid[0].scrollLeft : 0
  6396. var st = gridBoxSmall.scrollTop
  6397. var iw = items[0].offsetWidth + parseInt($(items[0]).css("margin-left"))
  6398. var xh = isSmartPhone ? 80 : 70
  6399. var ih = items[0].offsetHeight + xh
  6400. //Calcula el valor del contador
  6401. if ($label.hasClass("txtsearch")) {
  6402. //Cuenta los contadores de cada item (paginas y palabras busqueda texto)
  6403. var nItems = items.slice(0, NI)
  6404. var counter = LPCountCounters(items)
  6405. var counterN = LPCountCounters(nItems)
  6406. counterDelta = counter - counterN
  6407. //Descuenta segun el scroll horizontal
  6408. if (counterDelta > 0) {
  6409. $label.addClass("has_more_cells")
  6410. //Descuenta segun el scroll horizontal
  6411. if ($label.hasClass("cells_semihidden")) {
  6412. var off = Math.ceil(sl / iw)
  6413. nItems = items.slice(0, NI + off)
  6414. counterN = LPCountCounters(nItems)
  6415. counterDelta = counter - counterN
  6416. } else {
  6417. //Descuenta segun el scroll vertical
  6418. if ($label.hasClass("cells_extended")) {
  6419. var NIY = parseInt(gbh / ih) - 1
  6420. var NIT = NI * NIY
  6421. var ROUT = parseInt(st / ih)
  6422. var NIOUT = NI * ROUT
  6423. var NIOFF = NIOUT + NIT
  6424. var itemsOff = items.slice(0, NIOFF)
  6425. var nItemsOff = LPCountCounters(itemsOff)
  6426. counterDelta = counter - nItemsOff
  6427. //console.log("st " + st + " NIY " + NIY + " NIT " + NIT + " ROUT " + ROUT);
  6428. } else {
  6429. counterDelta = 0
  6430. }
  6431. }
  6432. }
  6433. } else {
  6434. var counter = items.length
  6435. counterDelta = counter - NI
  6436. if (counterDelta > 0) {
  6437. $label.addClass("has_more_cells")
  6438. //Descuenta segun el scroll horizontal
  6439. if ($label.hasClass("cells_semihidden")) {
  6440. var off = sl / iw
  6441. counterDelta -= off
  6442. } else {
  6443. //Descuenta segun el scroll vertical
  6444. if ($label.hasClass("cells_extended")) {
  6445. var off = NI * parseInt(st / ih)
  6446. counterDelta = counter - off
  6447. } else {
  6448. counterDelta = 0
  6449. }
  6450. }
  6451. }
  6452. }
  6453. var tag_folder = $(".tag_folder", label)
  6454. var tag_see_more = $(".tag_see_more", label)
  6455. var tag_see_more_top = gridBox.labelAtTop
  6456. ? $(".tag_see_more", gridBox.labelAtTop)
  6457. : $("<div></div>")
  6458. if ($label.hasClass("has_more_cells")) {
  6459. tag_folder.css({ visibility: "" })
  6460. } else {
  6461. tag_folder.css({ visibility: "hidden" })
  6462. }
  6463. var cds = parseInt(("" + counterDelta).split(".")[0])
  6464. if (cds > 0) {
  6465. $label.addClass("has_more_cells")
  6466. tag_see_more.css({ visibility: "" })
  6467. var tagTxt = isSmartPhone ? cds + " más" : "Ver " + cds + " más"
  6468. tag_see_more.text(tagTxt)
  6469. if ($label.hasClass("cells_extended") && gridBox.labelAtTop) {
  6470. tag_see_more_top.css({ visibility: "" }).text(tagTxt)
  6471. }
  6472. } else {
  6473. tag_see_more.css({ visibility: "hidden" })
  6474. if ($label.hasClass("cells_extended") && gridBox.labelAtTop) {
  6475. tag_see_more_top.css({ visibility: "hidden" })
  6476. }
  6477. }
  6478. if (isLabelFlex && $.trim($(".tag_label", label).text()).length == 0) {
  6479. tag_see_more.css({ visibility: "hidden" })
  6480. tag_see_more_top.css({ visibility: "hidden" })
  6481. }
  6482. }
  6483. function LPClickFlexWord() {
  6484. var cellid = getCellID(this)
  6485. var tItem = cellid[0]
  6486. var idItem = cellid[1]
  6487. var elem = this
  6488. var papa = elem.parentNode
  6489. var thisLabel = papa.lbl
  6490. $(thisLabel.cellSelected).removeClass("cell_selected")
  6491. $(elem).addClass("cell_selected")
  6492. thisLabel.cellSelected = elem
  6493. //Repliega el label
  6494. if (!$(thisLabel).hasClass("cells_semihidden")) {
  6495. $(thisLabel).trigger("click")
  6496. setTimeout(function () {
  6497. $(thisLabel).next()[0].scrollLeft =
  6498. papa.offsetLeft - $(window).width() / 2 // + (papa.offsetWidth);
  6499. }, 200)
  6500. }
  6501. var horiGrid = $(thisLabel).next()
  6502. var elemsToRemove = horiGrid.nextUntil()
  6503. var extraparams = {}
  6504. var extraData = elem.className.match(/x_\w+_\w+/g)
  6505. $.each(extraData, function () {
  6506. var xd = this.replace("x_", "").split("_")
  6507. extraparams[xd[0]] = xd[1]
  6508. })
  6509. var xhr = ltotalOS.loadData("libros", tItem, idItem, extraparams)
  6510. if (xhr) {
  6511. panelSocial.createLoaderItem(this, xhr, null)
  6512. xhr.done(function (htmlData) {
  6513. var proc = $("#proceso").html(htmlData)
  6514. LPWrapItems(proc.children())
  6515. var labels = $(".cell_label", proc)
  6516. labels.each(function () {
  6517. var lbl = this
  6518. var items = $(lbl).nextUntil(".cell_label")
  6519. items.each(function () {
  6520. this.lbl = lbl
  6521. })
  6522. lbl.items = items
  6523. items.detach()
  6524. if (items.length > 30) {
  6525. lbl.fullItems = items
  6526. lbl.items = items.slice(0, 30)
  6527. }
  6528. $(lbl).after(lbl.items)
  6529. })
  6530. horiGrid.after(proc.children())
  6531. elemsToRemove.remove()
  6532. labels.each(function () {
  6533. configureLabel(this)
  6534. })
  6535. gridBoxSmall.scrollTo(0, thisLabel.offsetTop)
  6536. if (mosaicNavigation.length == 0) {
  6537. mosaicNavigation.push([
  6538. "item_palabra_flex",
  6539. lastServiceSelected,
  6540. "item_palabra_flex",
  6541. ])
  6542. $(backMosaic).css({ display: "block" })
  6543. history.pushState(1, null, null)
  6544. }
  6545. ltotalOS.timeStats({ sumSegs: 3 })
  6546. })
  6547. }
  6548. //Estadistica de clicks a las pildoras de Generos y Tematicas
  6549. var filtroID = elem.className.match(
  6550. /x_(filtrogenero|audiolibsgenero)_\d+/,
  6551. )
  6552. filtroID =
  6553. filtroID && filtroID[0] ? " " + filtroID[0].replace("x_", "") : ""
  6554. ltotalOS.statistics(89, tItem + "_" + idItem + filtroID)
  6555. }
  6556. function LPWrapItems(_items) {
  6557. $.each(_items, function () {
  6558. var item = this
  6559. var $item = $(item)
  6560. if ($item.hasClass("cell_palabra_flex")) {
  6561. LPWrapItemCaratula(item, "caratula_palabra_flex")
  6562. $(".cell", item)[0].onclick = LPClickFlexWord
  6563. var nc = $item.text().length
  6564. var px = nc < 18 ? 12 : 10
  6565. var wx = nc * px < 280 ? nc * px : 280
  6566. $item.css({ width: wx + "px" })
  6567. } else {
  6568. if ($item.hasClass("cell")) {
  6569. item.onclick = function () {
  6570. panelSocial.clickSobreItem(this, servicio, mosaico)
  6571. }
  6572. hoverElement(item)
  6573. }
  6574. }
  6575. if (!item.observed) {
  6576. if ($item.hasClass("cell_label")) {
  6577. labelsObserver.observe(item)
  6578. } else {
  6579. itemsObserver.observe(item)
  6580. }
  6581. item.observed = true
  6582. }
  6583. })
  6584. }
  6585. this.LPWrapItems = function (_items) {
  6586. LPWrapItems(_items)
  6587. }
  6588. function postProcPortadas(es) {
  6589. var esAnotador = ltotalUtils.checkPermiso("anotador,grupoinvestigacion")
  6590. var rnd =
  6591. !isTouch && esAnotador
  6592. ? "?v=" + ("" + Math.random()).replace(".", "")
  6593. : ""
  6594. for (var i = 0; i < es.length; i++) {
  6595. var e = es[i]
  6596. var $e = $(e)
  6597. $(".label", e).each(function () {
  6598. var labelName = $(this).attr("labelname")
  6599. $e.attr(labelName, $(this).detach()[0].value)
  6600. })
  6601. var cara = $(".caraSlider", e).remove()
  6602. if (cara[0]) {
  6603. $e.css({ "background-image": "url(" + cara.attr("src") + rnd + ")" })
  6604. }
  6605. $(".art_thumbnail", e).css({ width: "", height: "", margin: "" })
  6606. //Contadores
  6607. var counter = e.className.match(/counter_\d+/)
  6608. if (counter) {
  6609. var count_tag = document.createElement("div")
  6610. count_tag.className = "tag_counter"
  6611. count_tag.innerHTML = counter[0].match(/\d+/)[0]
  6612. $e.append(count_tag)
  6613. }
  6614. //Cinta de recuerdo para los libros foto_promo
  6615. if (hasClassRegex(/foto_promo_libro_\d+/, e)) {
  6616. var rutaTape = ltotalOS.replaceRepoDir(
  6617. "/testLtotal/CARATULAS/generic_covers/tapes/recuerdo_tape.png",
  6618. )
  6619. $(e).append(
  6620. '<img class="recuerdo_tape" style="position:absolute; width:70%; height:40%; left:30%; top:60%;" src="' +
  6621. rutaTape +
  6622. '" />',
  6623. )
  6624. }
  6625. //Cinta de regalo para los libros regalados
  6626. if (hasClassRegex(/regalo_libro_\d+/, e)) {
  6627. var rutaTape = ltotalOS.replaceRepoDir(
  6628. "/testLtotal/CARATULAS/generic_covers/tapes/regalo_tape.png",
  6629. )
  6630. $(e).append(
  6631. '<img class="regalo_tape" style="position:absolute; width:70%; height:40%; left:30%; top:60%;" src="' +
  6632. rutaTape +
  6633. '" />',
  6634. )
  6635. }
  6636. if ($e.attr("label_cell_info")) {
  6637. $(e.parentNode.lbl).addClass("label_cell_info")
  6638. createBoxCellInfo($e)
  6639. }
  6640. if (!esAnotador) {
  6641. $(".nopublico", e).remove()
  6642. }
  6643. }
  6644. }
  6645. function createBoxCellInfo(_e) {
  6646. var tipo_item = getCellID(_e[0])[0]
  6647. if ($(".boxCellInfo", _e)[0]) {
  6648. return null
  6649. }
  6650. _e.append('<div class="boxCellInfo"></div>')
  6651. var b = $(".boxCellInfo", _e)
  6652. var formatAutor = function (_a) {
  6653. var autor = _a
  6654. var autorD = autor.split(",")
  6655. if (autorD.length == 2) {
  6656. var aa = $.trim(autorD[0])
  6657. var nn = $.trim(autorD[1])
  6658. autor = nn + " " + aa
  6659. }
  6660. return autor
  6661. }
  6662. var procRawName = function () {
  6663. var autor = formatAutor(getLabel("label_autor_raw"))
  6664. var papa = _e[0].lbl
  6665. if (hasClassRegex(/x_librosautor_1/, papa)) {
  6666. autor = $(".tag_label", papa)
  6667. .text()
  6668. .replace(/Libros\s+de\s+/, "")
  6669. }
  6670. b.append('<div class="bci_data">' + autor + "</div>")
  6671. }
  6672. var getLabel = function (_l) {
  6673. return _e.attr(_l) ? _e.attr(_l) : ""
  6674. }
  6675. var procLabel = function (_l, _xc, _extra) {
  6676. if (_l.length > 0) {
  6677. b.append(
  6678. '<div class="bci_data' +
  6679. _xc +
  6680. '">' +
  6681. getTxtLabel(_extra, getLabel(_l)) +
  6682. "</div>",
  6683. )
  6684. }
  6685. }
  6686. var getTxtLabel = function (_obj, _label) {
  6687. var txtLabel = _label
  6688. if (_obj && _obj.txtLabel) {
  6689. txtLabel =
  6690. _obj.txtAdd == "prepend"
  6691. ? _obj.txtLabel + _label
  6692. : _label + _obj.txtLabel
  6693. }
  6694. return txtLabel
  6695. }
  6696. if (tipo_item == 1 || tipo_item == 4) {
  6697. procRawName()
  6698. if ($(_e[0].lbl).hasClass("label_versiones")) {
  6699. var labelTrad = "",
  6700. txtIdioma = ""
  6701. if (getLabel("label_autor") !== getLabel("label_traductor")) {
  6702. txtIdioma = "Trad. al "
  6703. labelTrad = "label_traductor"
  6704. }
  6705. procLabel("label_idioma", " odd", {
  6706. txtLabel: txtIdioma,
  6707. txtAdd: "prepend",
  6708. })
  6709. procLabel(labelTrad, "")
  6710. } else {
  6711. procLabel("label_genero", " odd")
  6712. procLabel("label_year", " small")
  6713. }
  6714. }
  6715. if (tipo_item == "mydownld") {
  6716. procLabel("label_titulo", "")
  6717. if (getLabel("label_titulo") != getLabel("label_autor_raw")) {
  6718. procLabel("label_autor_raw", "")
  6719. }
  6720. procLabel("label_genero", " odd")
  6721. }
  6722. if (
  6723. tipo_item == 3 ||
  6724. tipo_item == 6 ||
  6725. tipo_item == 10 ||
  6726. tipo_item == 51
  6727. ) {
  6728. procRawName()
  6729. procLabel("label_year", " odd")
  6730. }
  6731. if (tipo_item == 16) {
  6732. procLabel("label_year", "")
  6733. }
  6734. if (tipo_item == 17 || tipo_item == 27) {
  6735. var ar = getLabel("label_autor_rela")
  6736. if (ar.length > 0) {
  6737. b.append('<div class="bci_data">Relacionado a</div>')
  6738. b.append('<div class="bci_data">' + formatAutor(ar) + "</div>")
  6739. }
  6740. }
  6741. }
  6742. function deSelectPilares() {
  6743. closeSearch()
  6744. $(".bookTab.active", boxTabs).removeClass("active")
  6745. $(".pilarSelec", boxBread).removeClass("pilarSelec")
  6746. $(".pilarSelec", boxPilars).removeClass("pilarSelec")
  6747. }
  6748. function restoreLastMosaic() {
  6749. var rePaint = false
  6750. if (panelSocial.settings.doARepaint) {
  6751. rePaint = true
  6752. panelSocial.settings.doARepaint = false
  6753. }
  6754. var cache = mosaicCache[lastPilarItemSelected]
  6755. if (cache) {
  6756. var html = cache[0]
  6757. var mosaicTop = cache[1]
  6758. mosaico.createMosaic2(
  6759. html,
  6760. lastServiceSelected,
  6761. lastItemSelected,
  6762. mosaicTop,
  6763. { backNav: false, rePaint: rePaint },
  6764. )
  6765. configHorizGridBoxes()
  6766. }
  6767. }
  6768. function configHoriGridBoxButtons(hGrid) {
  6769. if (!isTouch) {
  6770. if (!gridBox.horBtnLeft) {
  6771. var clickHorizontalButtons = function () {
  6772. var thGrid = this.hGrid
  6773. var gsw = gridBox.offsetWidth
  6774. var off = $(this).hasClass("btn_right") ? gsw : gsw * -1
  6775. var sl = thGrid.scrollLeft + off
  6776. $(thGrid).stop()
  6777. $(thGrid).animate({ scrollLeft: sl }, 400, function () {
  6778. checkHoriGridButtons(thGrid)
  6779. })
  6780. }
  6781. var horBtnLeft = document.createElement("div")
  6782. horBtnLeft.className = "horiz_btn btn_left"
  6783. horBtnLeft.onclick = clickHorizontalButtons
  6784. var horBtnRight = document.createElement("div")
  6785. horBtnRight.className = "horiz_btn btn_right"
  6786. horBtnRight.onclick = clickHorizontalButtons
  6787. gridBox.horBtnLeft = horBtnLeft
  6788. gridBox.horBtnRight = horBtnRight
  6789. }
  6790. hGrid.addEventListener(
  6791. "mouseover",
  6792. function (_ev) {
  6793. var thGrid = $(_ev.target).hasClass("horiGridBox")
  6794. ? _ev.target
  6795. : $(_ev.target).parents(".horiGridBox")[0]
  6796. var btnL = gridBox.horBtnLeft
  6797. var btnR = gridBox.horBtnRight
  6798. btnL.hGrid = thGrid
  6799. btnR.hGrid = thGrid
  6800. var topOff = $(thGrid.lbl).is(
  6801. ".21_0, .banners_banners, .mibliblio_0, .25_32",
  6802. )
  6803. ? 30
  6804. : 56
  6805. var topBtn =
  6806. thGrid.offsetTop -
  6807. gridBoxSmall.scrollTop +
  6808. thGrid.offsetHeight / 2 -
  6809. topOff
  6810. var btns = $([btnL, btnR])
  6811. btns.detach()
  6812. btns.css({ top: topBtn + "px" })
  6813. checkHoriGridButtons(thGrid)
  6814. },
  6815. false,
  6816. )
  6817. }
  6818. }
  6819. function checkHoriGridButtons(hGrid) {
  6820. var btnL = gridBox.horBtnLeft
  6821. var btnR = gridBox.horBtnRight
  6822. var sl = hGrid.scrollLeft
  6823. var gsw = gridBox.offsetWidth
  6824. var offRight = sl + gsw
  6825. if (offRight >= hGrid.scrollWidth) {
  6826. $(btnR).detach()
  6827. } else {
  6828. $(gridBoxSmall).append(btnR)
  6829. }
  6830. if (sl == 0) {
  6831. $(btnL).detach()
  6832. } else {
  6833. $(gridBoxSmall).append(btnL)
  6834. }
  6835. }
  6836. function configHoriGridBox(horiGrid) {
  6837. var innerGrid = horiGrid[0].innerGrid
  6838. innerGrid.css({ width: "" })
  6839. var hGrid = innerGrid.parent()
  6840. var lastItem = innerGrid.children().last()
  6841. var limt = parseInt(lastItem.css("margin-top"))
  6842. var hGridW = lastItem[0].offsetLeft + lastItem[0].offsetWidth + 30
  6843. var hGridH = lastItem[0].offsetHeight + limt
  6844. var hGridHori = hGridH
  6845. if (
  6846. !lastItem.is(
  6847. ".caratula_palabra_flex, .caratula_banner, .mibibliocell, .randombtncell",
  6848. )
  6849. ) {
  6850. hGridH += limt * 3
  6851. if ($(panelSocial.bodyDiv).hasClass("aumented")) {
  6852. hGridH += 16
  6853. }
  6854. }
  6855. if ($(lastItem[0].lbl).is(".18_1")) {
  6856. hGridW += $(panelSocial.bodyDiv).hasClass("aumented") ? 60 : 30
  6857. }
  6858. if ($(lastItem[0].lbl).is(".25_32, .pais_0")) {
  6859. hGridH = hGridHori + 15
  6860. }
  6861. hGridH += 12
  6862. horiGrid.css({ height: hGridH + "px" })
  6863. innerGrid.css({ width: hGridW + "px" })
  6864. }
  6865. function configHorizGridBoxes() {
  6866. $(".horiGridBox", gridBoxSmall).each(function () {
  6867. configHoriGridBox($(this))
  6868. })
  6869. }
  6870. function createHoriGridBox(label) {
  6871. var $label = $(label)
  6872. if ($label.hasClass("cells_semihidden")) {
  6873. var hGrid = $(
  6874. '<div class="horiGridBox"><div class="horiGridBoxInner"></div></div>',
  6875. )
  6876. $label.after(hGrid)
  6877. if (label.fullItems) {
  6878. $(label.fullItems).detach()
  6879. }
  6880. var innerGrid = $(".horiGridBoxInner", hGrid)
  6881. innerGrid.html(label.items)
  6882. hGrid[0].innerGrid = innerGrid
  6883. hGrid[0].lbl = label
  6884. label.hGrid = hGrid
  6885. if (platf.indexOf("android") == -1) {
  6886. horiBoxesObserver.observe(hGrid[0])
  6887. }
  6888. configHoriGridBox(hGrid)
  6889. hGrid[0].addEventListener(
  6890. "scroll",
  6891. function () {
  6892. if ($(this.lbl).is(".banners_banners")) {
  6893. if (!this.lbl.olAnimated) {
  6894. that.activateLabelAnim(this.lbl, { timeout: 600 })
  6895. }
  6896. }
  6897. LPShowLabelCounter.call(label)
  6898. },
  6899. false,
  6900. )
  6901. configHoriGridBoxButtons(hGrid[0])
  6902. }
  6903. }
  6904. function configureLinkLabel(label) {
  6905. var link = label.className.match(/link_.+_link/)
  6906. if (link && ltotalUtils.checkPermiso("anotador")) {
  6907. link = link[0].replace("link_", "").replace("_link", "")
  6908. //Adjunta boton para compartir link del rotulo
  6909. if (!$(".tag_share", label)[0]) {
  6910. var tagFolder = $(".tag_folder", label)
  6911. tagFolder.before('<div class="tag_share" title="' + link + '"></div>')
  6912. var tagLabel = $(".tag_label", label)
  6913. var titleLabel =
  6914. (link.split("__").length > 1
  6915. ? "Compartir "
  6916. : "Compartir colección de ") + tagLabel.text()
  6917. var tagShare = $(".tag_share", label)
  6918. tagShare[0].onclick = function (_ev) {
  6919. _ev.stopPropagation()
  6920. var shareOptions = {
  6921. tipoItem: "mlnk",
  6922. idItem: -1,
  6923. nombItem: titleLabel,
  6924. mlnk: link,
  6925. clickClose: function () {
  6926. panelSocial.destroyShareModal()
  6927. },
  6928. }
  6929. panelSocial.shareGift(shareOptions)
  6930. }
  6931. }
  6932. }
  6933. }
  6934. function configureLabel(label) {
  6935. var $label = $(label)
  6936. //Pone clase cells_semihidden al cell_label que tiene mas de una linea de items
  6937. label.items = $label.nextUntil(".cell_label")
  6938. var lItemsCount = label.items.length
  6939. if (
  6940. lItemsCount == 0 &&
  6941. !$label.hasClass("load_items") &&
  6942. !$label.hasClass("txtsearch") &&
  6943. !label.itemsMixDownloads
  6944. ) {
  6945. $label.remove()
  6946. }
  6947. if (lItemsCount == 0) {
  6948. return
  6949. }
  6950. $label.addClass("cells_semihidden")
  6951. if ($label.hasClass("start_visible")) {
  6952. $label.removeClass("cells_semihidden")
  6953. }
  6954. if ($label.hasClass("counter_0")) {
  6955. $label
  6956. .removeClass("counter_0")
  6957. .addClass("counter_" + label.items.length)
  6958. }
  6959. //Adjunta boton indicador de pliegue
  6960. if (!$(".tag_folder", $label)[0]) {
  6961. $label.append('<div class="tag_folder"></div>')
  6962. $label.append('<div class="tag_see_more"></div>')
  6963. }
  6964. if ($label.hasClass("mydownld_1")) {
  6965. $(".tag_folder, .tag_see_more, .tag_doc", label).remove()
  6966. $label.append(
  6967. '<div class="tag_doc" style="float: right; width: 30px; height: 100%; background-image: url(\'/estaticosED/files/img/folder.png\'); background-size: 100% 100%; margin-right: 10px;"></div>',
  6968. )
  6969. $(".tag_doc", label)[0].onclick = function (_ev) {
  6970. _ev.stopPropagation()
  6971. var cmdObj = { Module: "OfflineApp", Action: "ShowDocuments" }
  6972. panelSocial.executeNative(cmdObj)
  6973. }
  6974. }
  6975. configureLinkLabel(label)
  6976. createHoriGridBox(label)
  6977. LPShowLabelCounter.call(label)
  6978. label.onclick = clickLabel
  6979. if ($label.is(".mydownld_1.start_visible")) {
  6980. label.onclick = function () {}
  6981. }
  6982. }
  6983. function clickLabel() {
  6984. var label = $(this)
  6985. var deltaScroll = new Date().getTime() - gridBoxSmall.scrollTime
  6986. if (deltaScroll < 400) {
  6987. gridBoxSmall.scrollTop = gridBoxSmall.scrollTop + 2
  6988. return null
  6989. }
  6990. LPRemoveLabelAtTop()
  6991. var stoff = isTouch && !$(boxTopHeader).hasClass("ontop") ? 130 : 0
  6992. if (label[0].fullItems) {
  6993. label[0].items = label[0].fullItems.slice(0, 30)
  6994. if (label.hasClass("cells_semihidden")) {
  6995. label.addClass("cells_extended")
  6996. label.removeClass("cells_semihidden")
  6997. label.css({ visibility: "hidden" })
  6998. setTimeout(function () {
  6999. LPPutLabelAtTop(label[0])
  7000. }, 200)
  7001. gridBoxSmall.items = $(gridBoxSmall).children()
  7002. $(gridBoxSmall).empty()
  7003. $(gridBoxSmall).append(label)
  7004. label.after(label[0].items)
  7005. gridBoxSmall.scrollTop = 0
  7006. gridBoxSmall.labelExtented = true
  7007. } else {
  7008. label.removeClass("cells_extended")
  7009. label.addClass("cells_semihidden")
  7010. label.css({ visibility: "" })
  7011. if (label[0].hGrid) {
  7012. $(gridBoxSmall).empty()
  7013. $(gridBoxSmall).append(gridBoxSmall.items)
  7014. label[0].hGrid[0].innerGrid.html(label[0].items)
  7015. gridBoxSmall.scrollTop = label[0].offsetTop - 100 - stoff
  7016. } else {
  7017. label.removeClass("start_visible")
  7018. configureLabel(label[0])
  7019. }
  7020. gridBoxSmall.labelExtented = false
  7021. }
  7022. } else {
  7023. if (label[0].items.length <= gridBox.NI) {
  7024. return null
  7025. }
  7026. if (label.hasClass("cells_semihidden")) {
  7027. label.removeClass("cells_semihidden")
  7028. label.next().remove()
  7029. label.after(label[0].items)
  7030. gridBoxSmall.scrollTop = label[0].offsetTop - stoff
  7031. } else {
  7032. label.addClass("cells_semihidden")
  7033. createHoriGridBox(label[0])
  7034. var deltaTop = gridBoxSmall.scrollTop - label[0].offsetTop
  7035. if (deltaTop > 0) {
  7036. gridBoxSmall.scrollTop = label[0].offsetTop
  7037. }
  7038. }
  7039. }
  7040. setTimeout(function () {
  7041. LPShowLabelCounter.call(label[0])
  7042. }, 200)
  7043. diagramCellLabels()
  7044. labelJustClicked = true
  7045. }
  7046. var nativeCovers = {}
  7047. var nativeCoversQ = {}
  7048. function loadNativeCover(_bookElem) {
  7049. var _bookID = getCellID(_bookElem)[1]
  7050. var docID = _bookID
  7051. var accion = "CoverBook"
  7052. if (!$(_bookElem).hasClass("format_epub")) {
  7053. docID = _bookID.replace("pdf", "")
  7054. accion = "CoverPDFDocumento"
  7055. }
  7056. if (nativeCovers[_bookID]) {
  7057. that.coverBookCallback(nativeCovers[_bookID])
  7058. } else {
  7059. if (!nativeCoversQ[_bookID]) {
  7060. nativeCoversQ[_bookID] = true
  7061. var cmdObj = {
  7062. Module: "OfflineApp",
  7063. Action: accion,
  7064. Parameters: [docID],
  7065. Callback: "panelSocial.mosaico.coverBookCallback",
  7066. }
  7067. panelSocial.executeNative(cmdObj)
  7068. }
  7069. }
  7070. }
  7071. function loadPortadas() {
  7072. var extraparams = { hls: true }
  7073. jQuery.extend(extraparams, mosaico.SycCredentials)
  7074. var postItemsToLoad = itemsToLoad.slice(0)
  7075. itemsToLoad = []
  7076. if (postItemsToLoad.length > 0) {
  7077. ltotalOS.loadPortada(postItemsToLoad, extraparams).done(function (es) {
  7078. postProcPortadas(es)
  7079. })
  7080. }
  7081. }
  7082. function preloadItems(it) {
  7083. for (var id = 0; id <= gridBox.NI * 2; id++) {
  7084. if (it) {
  7085. var $it = $(it)
  7086. if (
  7087. !$it.is(
  7088. ".cell_label, .horiGridBox, .caratula_banner, .horiz_btn, .btn_right, .mydownld",
  7089. )
  7090. ) {
  7091. var childrenCount = $it.children().length
  7092. if (childrenCount == 0 && !it.loading) {
  7093. it.loading = true
  7094. itemsToLoad.push(it)
  7095. }
  7096. }
  7097. if ($it.hasClass("mydownld") && !$it.hasClass("cvLD")) {
  7098. loadNativeCover(it)
  7099. }
  7100. it = it.nextSibling
  7101. }
  7102. }
  7103. if (itemsToLoad.length > 0) {
  7104. loadPortadas()
  7105. }
  7106. }
  7107. function preloadLabels(label) {
  7108. var labelsLength = gridBoxSmall.cell_labels.length
  7109. for (var il = 0; il < labelsLength; il++) {
  7110. if (label == gridBoxSmall.cell_labels[il]) {
  7111. var ilni = il + 1
  7112. var ilnf = ilni + 1
  7113. for (var iln = ilni; iln < ilnf && iln < labelsLength; iln++) {
  7114. loadDataCellLabel(gridBoxSmall.cell_labels[iln])
  7115. }
  7116. break
  7117. }
  7118. }
  7119. }
  7120. function onEntryLabels(entry) {
  7121. $.each(entry, function () {
  7122. var item = this.target
  7123. var $item = $(item)
  7124. if (this.isIntersecting) {
  7125. loadDataCellLabel(item)
  7126. preloadLabels(item)
  7127. //if (gridBox.labelAtTop && gridBox.labelAtTop.label == item) {
  7128. //LPRemoveLabelAtTop();
  7129. //}
  7130. diagramCellLabels()
  7131. } else {
  7132. var offT = gridBoxSmall.scrollTop - item.offsetTop
  7133. if (
  7134. offT > 0 &&
  7135. !$item.hasClass("counter_0") &&
  7136. $item.hasClass("cells_extended")
  7137. ) {
  7138. LPPutLabelAtTop(item)
  7139. }
  7140. }
  7141. })
  7142. }
  7143. function onEntryItems(entry) {
  7144. $.each(entry, function () {
  7145. var item = this.target
  7146. var $item = $(item)
  7147. if (this.isIntersecting) {
  7148. try {
  7149. ltotalUtils.checkConnection(null, {
  7150. callback: function () {
  7151. if ($item.hasClass("mydownld")) {
  7152. loadNativeCover(item)
  7153. }
  7154. },
  7155. })
  7156. var items = item.lbl.items
  7157. var fullItems = item.lbl.fullItems
  7158. if (fullItems && fullItems.length > items.length) {
  7159. var itemMinus = items[items.length - 10]
  7160. var itemLast = items[items.length - 1]
  7161. if (item == itemMinus || item == itemLast) {
  7162. var newItems = []
  7163. var newi = items.length
  7164. var newif = newi + 30
  7165. for (var ifi = newi; ifi < newif; ifi++) {
  7166. if (ifi == fullItems.length) {
  7167. break
  7168. }
  7169. var newIt = fullItems[ifi]
  7170. newItems.push(newIt)
  7171. item.lbl.items.push(newIt)
  7172. }
  7173. $(itemLast).after(newItems)
  7174. if ($item.parent().hasClass("horiGridBoxInner")) {
  7175. configHoriGridBox($item.parent().parent())
  7176. }
  7177. }
  7178. }
  7179. if ($item.hasClass("caratula_banner")) {
  7180. createCaratulaBanner(item, {})
  7181. createCaratulaBanner(item.nextSibling, {})
  7182. return
  7183. }
  7184. if ($item.hasClass("caratula_dashboard")) {
  7185. createCaratulaDashboard(item, {})
  7186. return
  7187. }
  7188. $(".erase_bitac_btn, .erase_favorite_btn", item).remove()
  7189. var childrenCount = $item.children().length
  7190. if (childrenCount == 0 && !item.loading) {
  7191. item.loading = true
  7192. itemsToLoad.push(item)
  7193. }
  7194. //Precarga de items
  7195. preloadItems(item)
  7196. if ($item.hasClass("mydownld")) {
  7197. loadNativeCover(item)
  7198. }
  7199. if (
  7200. item.parentNode == gridBoxSmall &&
  7201. $(item.lbl).hasClass("cells_extended")
  7202. ) {
  7203. //if (item == items[items.length-1]) {
  7204. //var deltaTop = gridBoxSmall.scrollTop - item.offsetTop;
  7205. //if (deltaTop > 0) {
  7206. LPPutLabelAtTop(item.lbl)
  7207. //}
  7208. //}
  7209. }
  7210. } catch (e) {}
  7211. } else {
  7212. /*if (item.parentNode == gridBoxSmall && gridBox.labelAtTop) {
  7213. var items = item.lbl.items;
  7214. if (gridBox.labelAtTop.label == item.lbl && item == items[items.length-1]) {
  7215. var deltaTop = gridBoxSmall.scrollTop - item.offsetTop;
  7216. if (deltaTop > 0) {
  7217. LPRemoveLabelAtTop();
  7218. }
  7219. }
  7220. }*/
  7221. }
  7222. })
  7223. }
  7224. function onEntryhoriBoxes(entry) {
  7225. $.each(entry, function () {
  7226. var item = this.target
  7227. var $item = $(item)
  7228. if (this.isIntersecting) {
  7229. $item.html(item.innerGrid)
  7230. configHoriGridBox($item)
  7231. LPShowLabelCounter.call(item.lbl)
  7232. } else {
  7233. item.innerGrid.detach()
  7234. }
  7235. })
  7236. }
  7237. var labelsObserver = new IntersectionObserver(onEntryLabels, {
  7238. threshold: 1.0,
  7239. })
  7240. var itemsObserver = new IntersectionObserver(onEntryItems, { threshold: 0 })
  7241. var horiBoxesObserver = new IntersectionObserver(onEntryhoriBoxes, {
  7242. threshold: 0,
  7243. })
  7244. this.createMosaic2 = function (data, _servicio, item, mosaicTop, _opts) {
  7245. var configGridBoxSmall = function () {
  7246. $(boxMosaic).append(gridBox)
  7247. gridBox.labelAtTop = null
  7248. $(gridBox).focus()
  7249. }
  7250. var configLabels = function () {
  7251. gridBoxSmall.cell_labels = []
  7252. var labels = $(".cell_label", gridBoxSmall)
  7253. labels.each(function () {
  7254. var label = this
  7255. gridBoxSmall.cell_labels.push(label)
  7256. label.itemParent = item
  7257. configureLabel(label)
  7258. })
  7259. }
  7260. var saveCache = true
  7261. if (_opts && _opts.saveCache == false) {
  7262. saveCache = false
  7263. }
  7264. if (data != null) {
  7265. servicio = _servicio
  7266. mosaico.setMosaicCache({ backNav: _opts.backNav })
  7267. var itemID = item.pilarID ? item.pilarID : getCellID(item).join("_")
  7268. var xParms = item.className.match(/x_\w+_\w+/g)
  7269. $.each(xParms, function () {
  7270. itemID += "_" + this
  7271. })
  7272. lastPilarItemSelected = pilarSelected + "_" + itemID
  7273. lastServiceSelected = servicio
  7274. lastItemSelected = item
  7275. }
  7276. var mosaChild = $(boxMosaic).children()
  7277. panelSocial.clearAudioData(mosaChild)
  7278. mosaChild.detach()
  7279. if (item && !$(item).hasClass("pilarSearch")) {
  7280. closeSearch()
  7281. }
  7282. if (
  7283. data != null &&
  7284. typeof data == "object" &&
  7285. data.hasClass &&
  7286. data.hasClass("gridBoxSmall")
  7287. ) {
  7288. gridBoxSmall = data[0]
  7289. $(gridBox).prepend(gridBoxSmall)
  7290. configGridBoxSmall()
  7291. if (gridBoxSmall.labelExtented && _opts && _opts.backNav == true) {
  7292. setTimeout(function () {
  7293. $(gridBoxSmall.parentNode.nextElementSibling).trigger("click")
  7294. gridBoxSmall.scrollTop = 0
  7295. }, 100)
  7296. }
  7297. }
  7298. if (
  7299. data != null &&
  7300. (typeof data == "string" ||
  7301. getObjectType(data).toUpperCase() == "HTMLCOLLECTION")
  7302. ) {
  7303. gridBoxSmall = document.createElement("div")
  7304. gridBoxSmall.setAttribute("class", "gridBoxSmall")
  7305. gridBoxSmall.cell_labels = []
  7306. gridBoxSmall.scrollTopValue = 0
  7307. gridBoxSmall.lastScrollTopValue = 0
  7308. $(gridBox).prepend(gridBoxSmall)
  7309. gridBoxSmall.addEventListener(
  7310. "scroll",
  7311. function () {
  7312. var st = gridBoxSmall.scrollTop
  7313. gridBoxSmall.scrollTime = new Date().getTime()
  7314. gridBoxSmall.scrollTopValue = st
  7315. if (gridBoxSmall.bnnr) {
  7316. mosaicBanner.posVerMenos(gridBoxSmall.bnnr, gridBox, isTouch)
  7317. }
  7318. var lblx = $(".cell_label", gridBoxSmall)[0]
  7319. if ($(lblx).hasClass("cells_extended")) {
  7320. LPShowLabelCounter.call(lblx)
  7321. }
  7322. $([gridBox.horBtnLeft, gridBox.horBtnRight]).detach()
  7323. if (isTouch && !$(boxTopHeader).is(":animated")) {
  7324. var lst = gridBoxSmall.lastScrollTopValue
  7325. if (st > 60 && st > lst + 5 && !labelJustClicked) {
  7326. showTopHeader("hide")
  7327. }
  7328. if (st < 60 || st < lst - 5) {
  7329. showTopHeader("show")
  7330. }
  7331. }
  7332. gridBoxSmall.lastScrollTopValue = st
  7333. labelJustClicked = false
  7334. },
  7335. false,
  7336. )
  7337. configGridBoxSmall()
  7338. $(gridBoxSmall).html(data)
  7339. gridBoxSmall.items = $(gridBoxSmall).children()
  7340. configLabels()
  7341. preloadLabels(gridBoxSmall.cell_labels[0])
  7342. if (!saveCache) {
  7343. $(gridBoxSmall).addClass("no_cache")
  7344. }
  7345. }
  7346. if (isTouch) {
  7347. showTopHeader("show")
  7348. }
  7349. if (mosaicTop == null || mosaicTop == undefined) {
  7350. mosaicTop = 0
  7351. }
  7352. gridBoxSmall.scrollTop = mosaicTop
  7353. if (settings.modePilars) {
  7354. panelSocial.selectedBook = null
  7355. }
  7356. }
  7357. this.clickSobrePilar = function (pilar, _fncb) {
  7358. var basicFilters = []
  7359. var itemPilar = null
  7360. var service = pilar
  7361. if (pilar == "libros") {
  7362. itemPilar = pilarLibros
  7363. basicFilters = [
  7364. ["23", "-2", "Audiolibros", "shuffle_items replace_with_new_label"],
  7365. ["nuevos", "0", "Agregados recientemente", "shuffle_items"],
  7366. ["24", "11", "Recomendados", "shuffle_items replace_with_new_label"],
  7367. [
  7368. "librostotales",
  7369. "0",
  7370. "Libros enriquecidos",
  7371. "shuffle_items replace_with_new_label",
  7372. ],
  7373. ["25", "32", "Notas curiosas", "shuffle_items"],
  7374. [
  7375. "confrontados",
  7376. "0",
  7377. "Confrontados a otros idiomas",
  7378. "replace_with_new_label",
  7379. ],
  7380. ["autoresclasicos", "0", "Autores clásicos", "shuffle_items"],
  7381. ]
  7382. var tematicas = [
  7383. ["14", "767", "Infantil"],
  7384. ["14", "25", "Cuento"],
  7385. ["14", "1", "Novela"],
  7386. ["14", "24", "Poesía"],
  7387. ["14", "103", "Teatro"],
  7388. ["14", "2037", "Estudios literarios"],
  7389. ["14", "761", "Fantástico"],
  7390. ["14", "136", "Filosofía"],
  7391. ["14", "132", "Biografía"],
  7392. ["14", "1079", "Irónico"],
  7393. ["14", "1805", "Sentimientos"],
  7394. ["14", "736", "Ensayo"],
  7395. ["14", "990", "Familia"],
  7396. ["14", "796", "Amor"],
  7397. ["14", "1777", "Histórico"],
  7398. ["14", "800", "Animales"],
  7399. ["14", "1771", "Drama"],
  7400. ["14", "768", "Juvenil"],
  7401. ["14", "1374", "Crítica Social"],
  7402. ["14", "1829", "Memorias"],
  7403. ["14", "1140", "Mujer"],
  7404. ["14", "1139", "Muerte"],
  7405. ["14", "1117", "Matrimonio"],
  7406. ["14", "2014", "Cuento de hadas"],
  7407. ["14", "737", "Crónica"],
  7408. ["14", "1770", "Costumbrista"],
  7409. ["14", "1773", "Fábula"],
  7410. ["14", "1128", "Misterio"],
  7411. ["14", "1815", "Personajes históricos"],
  7412. ["14", "1877", "Existencial"],
  7413. ["14", "779", "Viajes"],
  7414. ["14", "1806", "Sobrenatural"],
  7415. ["14", "1778", "Microcuento"],
  7416. ["14", "795", "Amistad"],
  7417. ["14", "780", "Naturaleza"],
  7418. ["14", "1670", "Final inesperado"],
  7419. ["14", "143", "Política"],
  7420. ["14", "751", "Aventura"],
  7421. ["14", "2112", "Infortunios"],
  7422. ["14", "1125", "Militares"],
  7423. ["14", "1253", "Valores Humanos"],
  7424. ["14", "1830", "Relaciones de pareja"],
  7425. ["14", "774", "Policial"],
  7426. ["14", "1797", "Nostalgia"],
  7427. ["14", "1227", "Sátira"],
  7428. ["14", "818", "Asesinatos"],
  7429. ["14", "968", "Engaños"],
  7430. ["14", "1186", "Pobreza"],
  7431. ["14", "901", "Crimen"],
  7432. ["14", "1779", "Mitos y Leyendas"],
  7433. ["14", "1847", "Psicológico"],
  7434. ["14", "1065", "Infidelidad"],
  7435. ["14", "1063", "Indígenas"],
  7436. ["14", "1257", "Venganza"],
  7437. ["14", "1614", "Príncipes y Princesas"],
  7438. ["14", "967", "Enfermedades"],
  7439. ["14", "1689", "Tristeza"],
  7440. ["14", "991", "Fantasmas"],
  7441. ["14", "1957", "Mitología"],
  7442. ["14", "934", "Detectives"],
  7443. ["14", "1225", "Sueños"],
  7444. ["14", "1926", "Amores Imposibles"],
  7445. ["14", "1309", "Brujas y Hechiceros"],
  7446. ["14", "1783", "Terror"],
  7447. ["14", "140", "Religión"],
  7448. ["14", "775", "Romántico"],
  7449. ["14", "133", "Frases y aforismos"],
  7450. ["14", "1018", "Gastronomía"],
  7451. ["14", "773", "Pedagogía"],
  7452. ]
  7453. $.each(tematicas, function () {
  7454. this.push("shuffle_items x_hidefiltrogenero_1 replace_with_new_label")
  7455. })
  7456. basicFilters = basicFilters.concat(tematicas)
  7457. basicFilters = basicFilters.concat([
  7458. ["pais", "0", "Libros por países"],
  7459. [
  7460. "masleidos",
  7461. "0",
  7462. "Libros más leídos hoy",
  7463. "shuffle_items replace_with_new_label",
  7464. ],
  7465. [
  7466. "diccionarios",
  7467. "0",
  7468. "Diccionarios",
  7469. "x_extralabels_1 replace_with_new_label",
  7470. ],
  7471. ])
  7472. if (ltotalUtils.checkPermiso("anotador")) {
  7473. basicFilters.splice(4, 0, ["25", "27", "Grupos de investigación"])
  7474. }
  7475. }
  7476. if (pilar == "musica") {
  7477. itemPilar = pilarMusica
  7478. basicFilters = [
  7479. //["37", "0", 'Géneros musicales'],
  7480. ["24", "1010", "Contrainteligencia artificial"],
  7481. ["libros", "10", "Música inspirada en libros", "shuffle_items"],
  7482. ["38", "551", "Culta", "shuffle_items replace_with_new_label"],
  7483. ["38", "441", "Folclórica", "shuffle_items replace_with_new_label"],
  7484. ["38", "511", "Instrumental", "shuffle_items replace_with_new_label"],
  7485. ["38", "520", "Rock", "shuffle_items replace_with_new_label"],
  7486. ["38", "408", "Pop", "shuffle_items replace_with_new_label"],
  7487. ["autor", "0", "Compositores"],
  7488. ["masescuchada", "0", "Música más escuchada hoy", "shuffle_items"],
  7489. ["nueva", "0", "Música nueva"],
  7490. ["pais", "0", "Música por países"],
  7491. //['instrumentos', 'Instrumentos']
  7492. ]
  7493. }
  7494. if (pilar == "arte") {
  7495. service = "imagenes"
  7496. itemPilar = pilarArte
  7497. basicFilters = [
  7498. ["24", "66", "Contrainteligencia artificial"],
  7499. ["ewall", "0", "Arte más visto"], //Arte Universal
  7500. ["libros", "6", "Arte inspirado en libros", "shuffle_items"],
  7501. ["fotografia", "0", "Fotografía", "shuffle_items"],
  7502. ["pais", "0", "Arte por países"],
  7503. ["autor", "0", "Artistas"],
  7504. ["nuevas", "0", "Nuevas imágenes"],
  7505. ]
  7506. if (ltotalUtils.checkPermiso("anotador,anotador_imagen")) {
  7507. basicFilters.push(["42", "0", "Técnicas artísticas"])
  7508. }
  7509. }
  7510. var htmlFilters = ""
  7511. $.each(basicFilters, function (i, e) {
  7512. var extraClass = e[3] ? " " + e[3] : ""
  7513. htmlFilters +=
  7514. '<div class="cell_label load_items ' +
  7515. e[0] +
  7516. "_" +
  7517. e[1] +
  7518. " counter_0" +
  7519. extraClass +
  7520. '"><div class="tag_label">' +
  7521. e[2] +
  7522. "</div></div>"
  7523. })
  7524. var t_item = itemPilar.className.match(/t_item_\d+/)[0].match(/\d+/)[0]
  7525. var extraparams = {
  7526. expandRelas: 1,
  7527. id_cliente: panelSocial.getIDCliente(),
  7528. }
  7529. if (panelSocial.hasOfflineBooks()) {
  7530. extraparams.show_mis_descargas = 1
  7531. }
  7532. jQuery.extend(extraparams, mosaico.SycCredentials)
  7533. try {
  7534. var xhr = ltotalOS.loadData("", "24", t_item, extraparams)
  7535. deSelectPilares()
  7536. resetBackNavigation()
  7537. pilarSelected = pilar
  7538. servicio = service
  7539. $(itemPilar).addClass("pilarSelec")
  7540. if (xhr) {
  7541. xhr.done(function (_htmldata) {
  7542. var proc = $("#proceso").html(_htmldata + htmlFilters)
  7543. LPWrapItems(proc[0].children)
  7544. var miBibLabel = $(".mibliblio_0", proc)
  7545. miBibLabel.nextUntil(".cell_label").each(function () {
  7546. this.lbl = miBibLabel[0]
  7547. })
  7548. $(gridBox).empty()
  7549. var mosaicTop = 0
  7550. mosaico.createMosaic2(
  7551. proc[0].children,
  7552. servicio,
  7553. itemPilar,
  7554. mosaicTop,
  7555. { backNav: false },
  7556. )
  7557. /*var label_concurso = $(".cell.31_0", mosaico.getContain())[0];
  7558. if (label_concurso) {
  7559. ltotalUtils.loadScript("/estaticosED/files/js/ltotal/concurso.js");
  7560. ltotalUtils.loadScript("/estaticosED/files/css/ltotal/concurso.css");
  7561. }*/
  7562. if (panelSocial.hasOfflineBooks() && itemPilar == pilarLibros) {
  7563. if (lectorLogueado) {
  7564. if (!$(".cell_label.18_1")[0]) {
  7565. var cmdObj = {
  7566. Module: "OfflineApp",
  7567. Action: "RecentBooks",
  7568. Callback:
  7569. "panelSocial.mosaico.recentBooksDownloadedCallback2",
  7570. }
  7571. panelSocial.executeNative(cmdObj)
  7572. }
  7573. } else {
  7574. var cmdObj = {
  7575. Module: "OfflineApp",
  7576. Action: "DownloadedBooks",
  7577. Callback: "panelSocial.mosaico.downloadsMosaicCallback2",
  7578. }
  7579. panelSocial.executeNative(cmdObj)
  7580. }
  7581. }
  7582. if (_fncb) {
  7583. _fncb()
  7584. }
  7585. })
  7586. }
  7587. } catch (e) {}
  7588. }
  7589. this.activateLabelAnim = function (_label, _opts) {
  7590. var res = ltotalOS.deviceResolution
  7591. if (res.indexOf("ltr_phone") > -1) {
  7592. ltotalUtils.checkConnection()
  7593. clearTimeout(timerAnimBanner)
  7594. timerAnimBanner = setTimeout(
  7595. function () {
  7596. var carban = $(".caratula_banner", _label.hGrid).eq(0)
  7597. var wc = parseInt(carban.css("width"))
  7598. var mlc = parseFloat(carban.css("margin-left"))
  7599. var netw = wc + mlc
  7600. var olRela = _label.hGrid[0].scrollLeft / netw
  7601. var olRelaRound = Math.round(olRela)
  7602. var epsilon = olRela - olRelaRound
  7603. var steps =
  7604. epsilon < 0 && Math.abs(epsilon) > 0.05
  7605. ? olRelaRound
  7606. : olRelaRound + 1
  7607. var lPos = steps * netw
  7608. //Corrige posición en pantallas de ancho impar en px.
  7609. var gbsw = gridBoxSmall.offsetWidth
  7610. if (gbsw % 2 > 0) {
  7611. if (!_label.hGrid[0].slFactor) {
  7612. _label.hGrid[0].slFactor = 1
  7613. }
  7614. lPos = lPos + 0.5 * _label.hGrid[0].slFactor
  7615. _label.hGrid[0].slFactor = _label.hGrid[0].slFactor * -1
  7616. }
  7617. if (!isNaN(steps) && _label.hGrid[0].innerGrid[0].parentNode) {
  7618. _label.olAnimated = true
  7619. $(_label.hGrid).animate({ scrollLeft: lPos }, 400, function () {
  7620. setTimeout(function () {
  7621. _label.olAnimated = false
  7622. that.activateLabelAnim(_label)
  7623. }, 100)
  7624. })
  7625. } else {
  7626. that.activateLabelAnim(_label)
  7627. }
  7628. },
  7629. _opts && _opts.timeout ? _opts.timeout : 4000,
  7630. )
  7631. }
  7632. }
  7633. this.getCSSRule = function (rule) {
  7634. var cssRule = null
  7635. $.each(document.styleSheets, function () {
  7636. if (this.href) {
  7637. $.each(this.cssRules, function () {
  7638. if (this.style && this.selectorText && this.selectorText == rule) {
  7639. cssRule = this
  7640. }
  7641. })
  7642. }
  7643. })
  7644. return cssRule
  7645. }
  7646. this.configHMarginItems = function () {
  7647. var res = ltotalOS.deviceResolution
  7648. var isComputer = res.indexOf("ltr_computer") > -1
  7649. var isPhone = res.indexOf("ltr_phone") > -1
  7650. var gbw = gridBox.offsetWidth
  7651. var isAumented = $(panelSocial.bodyDiv).hasClass("aumented")
  7652. var aumented = isAumented ? ".aumented" : ""
  7653. var getMarginItems = function (_rule) {
  7654. var iw = parseInt(_rule.style["width"])
  7655. var ni = isComputer ? Math.floor(gbw / iw) - 1 : Math.floor(gbw / iw)
  7656. var itemsL = ni * iw
  7657. var gap = gbw - itemsL
  7658. var im = gap / (ni + 1)
  7659. if (ni > 3 && im < 20) {
  7660. ni--
  7661. itemsL = ni * iw
  7662. gap = gbw - itemsL
  7663. im = gap / (ni + 1)
  7664. }
  7665. if (ni >= 10) {
  7666. ni = 9
  7667. itemsL = ni * iw
  7668. gap = gbw - itemsL
  7669. im = gap / (ni + 1)
  7670. }
  7671. return { ni: ni, im: im }
  7672. }
  7673. //Items
  7674. var cssCell = isPhone
  7675. ? ".contentViewer.ltr_phone" + aumented + " .cell"
  7676. : ".contentViewer" + aumented + " .cell"
  7677. var ruleCell = that.getCSSRule(cssCell)
  7678. var dataCell = getMarginItems(ruleCell)
  7679. gridBox.NI = dataCell.ni
  7680. ruleCell.style["margin-left"] = dataCell.im + "px"
  7681. //Items horizontales
  7682. var cssCellHori = isPhone
  7683. ? ".contentViewer.ltr_phone" + aumented + " .horiGridBoxInner .cell"
  7684. : ".contentViewer .horiGridBoxInner .cell"
  7685. var ruleCellHori = that.getCSSRule(cssCellHori)
  7686. var marginHori = dataCell.im - 5 > 2 ? dataCell.im - 5 : 2
  7687. ruleCellHori.style["margin-left"] = marginHori + "px"
  7688. //Palabras
  7689. var cssPaldic = isPhone
  7690. ? ".contentViewer.ltr_phone.ltr_port .cell.paldic"
  7691. : ".contentViewer .cell.paldic"
  7692. var rulePaldic = that.getCSSRule(cssPaldic)
  7693. var dataPaldic = getMarginItems(rulePaldic)
  7694. gridBox.NIPAL = dataPaldic.ni
  7695. rulePaldic.style["margin-left"] = dataPaldic.im + "px"
  7696. //Dashboards
  7697. var cssDash = ".boxMosaic .caratula_dashboard"
  7698. var ruleDash = that.getCSSRule(cssDash)
  7699. var dataDash = getMarginItems(ruleDash)
  7700. gridBox.NIDASH = dataDash.ni
  7701. ruleDash.style["margin-left"] = dataDash.im + "px"
  7702. //Banners
  7703. if (res.indexOf("ltr_phone ltr_port") > -1) {
  7704. var navAg = navigator.userAgent.toLowerCase()
  7705. var isIOS = navAg.indexOf("ipad") != -1 || navAg.indexOf("iphone") != -1
  7706. var bnrW = isIOS ? 360 : 352
  7707. var bnrM = (gbw - bnrW) / 2
  7708. var ruleBnr = that.getCSSRule(
  7709. ".contentViewer.ltr_phone.ltr_port .banner_destacados",
  7710. )
  7711. ruleBnr.style["width"] = bnrW + "px"
  7712. ruleBnr.style["margin-left"] = bnrM + "px"
  7713. }
  7714. }
  7715. this.getPilarSelected = function () {
  7716. return pilarSelected
  7717. }
  7718. //Guarda la bitacora de ultima lectura de un libro
  7719. this.saveBitacora = function (
  7720. _tipoLibro,
  7721. _idLibro,
  7722. _idTrad,
  7723. _pgFin,
  7724. _idItemFin,
  7725. palabra,
  7726. _numePaginaPercent,
  7727. _extra,
  7728. ) {
  7729. var doSave =
  7730. _tipoLibro == 1 ||
  7731. _tipoLibro == 6 ||
  7732. _tipoLibro == 10 ||
  7733. _tipoLibro == 16 ||
  7734. _tipoLibro == 17 ||
  7735. _tipoLibro == 27 ||
  7736. _tipoLibro == 32 ||
  7737. _tipoLibro == 51
  7738. if (
  7739. (_tipoLibro == 1 && _pgFin < 1) ||
  7740. (_tipoLibro == 1 && _idLibro == 1565) || //NOTA! ID quemado
  7741. (_tipoLibro == 17 && _idItemFin == 0) ||
  7742. (_tipoLibro == 27 && _idLibro == 0) ||
  7743. (_tipoLibro == 27 && _idItemFin == 0) ||
  7744. (_tipoLibro == 32 && _idItemFin == 0) ||
  7745. (_tipoLibro == 32 && _idLibro == 12) //NOTA! ID quemado
  7746. ) {
  7747. doSave = false
  7748. }
  7749. if (!ltotalOS.isConnected) {
  7750. doSave = false
  7751. }
  7752. if (doSave) {
  7753. var url = "/ltotal/lector/save_bitacora.jsp"
  7754. var queryURL = ltotalOS.getPostURL(url)
  7755. var params = {
  7756. idLibro: _idLibro,
  7757. idTrad: _idTrad,
  7758. pagina: _pgFin,
  7759. tipo_comp: _tipoLibro,
  7760. id_comp: _idItemFin,
  7761. palabra: palabra,
  7762. ltotalurl: url,
  7763. numePaginaPercent: _numePaginaPercent,
  7764. }
  7765. if (_extra) {
  7766. if (_extra.ignorePos) {
  7767. params.ignorePos = true
  7768. }
  7769. }
  7770. jQuery.extend(params, that.SycCredentials)
  7771. params = $.trim(decodeURIComponent($.param(params)))
  7772. $.post(queryURL, params).done(function () {
  7773. _tipoLibro == 16 ? (_tipoLibro = 45) : _tipoLibro
  7774. var idItemBitac =
  7775. _tipoLibro == 1
  7776. ? "4_" + _idLibro + "," + _idTrad
  7777. : _tipoLibro + "_" + _idLibro
  7778. if (_tipoLibro == 6 || _tipoLibro == 10) {
  7779. idItemBitac = _tipoLibro + "_" + _idItemFin
  7780. }
  7781. if (_tipoLibro == 45) {
  7782. idItemBitac = palabra
  7783. }
  7784. resetLabel(18, _tipoLibro, {
  7785. createLabel: true,
  7786. createItem: true,
  7787. idItemBitac: idItemBitac,
  7788. })
  7789. })
  7790. }
  7791. }
  7792. //Elimina Recientes
  7793. function deleteBitacora(_ev) {
  7794. _ev.stopPropagation()
  7795. var item = $(this).parent()
  7796. var celldata = getCellID(item)
  7797. var tipo = celldata[0]
  7798. var id = celldata[1].split(",")
  7799. var idL = id[0]
  7800. var idT = id[1]
  7801. var palabra = ""
  7802. if (tipo == 4) {
  7803. tipo = 1
  7804. }
  7805. if (tipo == 45) {
  7806. var cellCoverText = $(".word_cover_text", item)
  7807. palabra = $.trim(cellCoverText[0].innerHTML.replace(/\s+/, " "))
  7808. tipo = 16
  7809. }
  7810. if (!idT) {
  7811. idT = -1
  7812. }
  7813. if (tipo == "mydownld") {
  7814. if ($(item[0].lbl).hasClass("mydownld_1")) {
  7815. var dialogo = new DialogueLM({
  7816. show: true,
  7817. ModoBtn: true,
  7818. btnClose: true,
  7819. btnCancelar: "Cancelar",
  7820. btnAceptar: "Aceptar",
  7821. texto:
  7822. '¿Desea eliminar "' +
  7823. item.attr("label_titulo") +
  7824. '" de este dispositivo?',
  7825. fnAceptar: function () {
  7826. var _bookID = id[0]
  7827. var docID = _bookID
  7828. var accion = "DeleteBook"
  7829. if (!item.hasClass("format_epub")) {
  7830. docID = _bookID.replace("pdf", "")
  7831. accion = "DeletePDFDocumento"
  7832. }
  7833. var cmdObj = {
  7834. Module: "OfflineApp",
  7835. Action: accion,
  7836. Parameters: ["" + docID],
  7837. }
  7838. panelSocial.executeNative(cmdObj)
  7839. refreshLabelCounters(item)
  7840. },
  7841. fnCancelar: function () {},
  7842. })
  7843. } else {
  7844. var _bookID = id[0]
  7845. var docID = _bookID
  7846. var accion = "DeleteRecentBook"
  7847. if (!item.hasClass("format_epub")) {
  7848. docID = _bookID.replace("pdf", "")
  7849. accion = "DeleteRecentPDFDocumento"
  7850. }
  7851. var cmdObj = {
  7852. Module: "OfflineApp",
  7853. Action: accion,
  7854. Parameters: ["" + docID],
  7855. }
  7856. panelSocial.executeNative(cmdObj)
  7857. refreshLabelCounters(item)
  7858. }
  7859. return null
  7860. }
  7861. var url = "/ltotal/lector/borrar_bitacora.jsp"
  7862. var queryURL = ltotalOS.getPostURL(url)
  7863. var params = {
  7864. idLibro: idL,
  7865. idTrad: idT,
  7866. tipo_comp: tipo,
  7867. palabra: palabra,
  7868. ltotalurl: url,
  7869. caso: "1",
  7870. }
  7871. jQuery.extend(params, that.SycCredentials)
  7872. params = $.trim(decodeURIComponent($.param(params)))
  7873. $.post(queryURL, params).done(function () {
  7874. refreshLabelCounters(item)
  7875. })
  7876. }
  7877. //Refresca labels de lecturas recientes (18) y favoritos (44)
  7878. function resetLabel(_tipoSeccion, _tipoItem, _extra) {
  7879. var getTipoItem = function (_tipo) {
  7880. return _tipo == 1 || _tipo == 17 || _tipo == 27 || _tipo == 32
  7881. ? 1
  7882. : _tipo
  7883. }
  7884. var tipItem = getTipoItem(_tipoItem)
  7885. var labelID = _tipoSeccion + "_" + tipItem
  7886. var idItemBitac = null
  7887. var createLabel = false
  7888. var createItem = false
  7889. if (_extra) {
  7890. if (_extra.labelID) {
  7891. labelID = _extra.labelID
  7892. }
  7893. if (_extra.createLabel) {
  7894. createLabel = true
  7895. }
  7896. if (_extra.createItem) {
  7897. createItem = true
  7898. }
  7899. if (_extra.idItemBitac) {
  7900. idItemBitac = _extra.idItemBitac
  7901. }
  7902. }
  7903. //Resetea labels
  7904. var labels = buscaLabels()
  7905. $.each(labels, function () {
  7906. var lbl = this
  7907. var $lbl = $(lbl)
  7908. if ($lbl.hasClass(labelID)) {
  7909. if ($lbl.hasClass("banners_banners")) {
  7910. if (lbl.fullItems) {
  7911. shuffleArray(lbl.fullItems)
  7912. lbl.items = lbl.fullItems.slice(0, 30)
  7913. } else {
  7914. shuffleArray(lbl.items)
  7915. }
  7916. $lbl.next()[0].innerGrid.html(lbl.items)
  7917. } else {
  7918. var items = lbl.fullItems ? lbl.fullItems : lbl.items
  7919. var itemFound = null
  7920. var pariente = null
  7921. var idx = 0
  7922. removeClassRegex(/counter_\d+/, lbl)
  7923. if (
  7924. items.length > 0 &&
  7925. items[0].className.indexOf("minibookhelp") > -1
  7926. ) {
  7927. pariente = items[0].parentNode
  7928. $(items[0]).remove()
  7929. items.splice(0, 1)
  7930. }
  7931. if (items.each) {
  7932. items.each(function (i, e) {
  7933. if (
  7934. $(this).hasClass(idItemBitac) ||
  7935. (_tipoItem == 45 && $(this).text() == idItemBitac)
  7936. ) {
  7937. itemFound = this
  7938. idx = i
  7939. }
  7940. })
  7941. }
  7942. if (itemFound) {
  7943. pariente = itemFound.parentNode
  7944. $(items[idx]).detach()
  7945. items.splice(idx, 1)
  7946. if (createItem) {
  7947. $(pariente).prepend(itemFound)
  7948. items.splice(0, 0, itemFound)
  7949. }
  7950. } else {
  7951. if (createItem && !$lbl.hasClass("load_items")) {
  7952. var newItem = $('<div class="cell ' + idItemBitac + '"></div>')
  7953. if (_tipoItem == 45) {
  7954. if (idItemBitac.split("_").length < 2) {
  7955. newItem = $(
  7956. '<div class="cell 45_-1"><div class="boxPalabra"><div class="word_cover_text paldicReci">' +
  7957. idItemBitac +
  7958. "</div></div></div>",
  7959. )
  7960. }
  7961. newItem.addClass("paldic")
  7962. }
  7963. if (_extra && _extra.extraClass) {
  7964. newItem.addClass(_extra.extraClass)
  7965. }
  7966. if (_tipoSeccion == 18 || _tipoSeccion == "mydownld") {
  7967. newItem.addClass("erase_bitac")
  7968. }
  7969. if (_tipoSeccion == 44) {
  7970. newItem[0].erase_favorite = true
  7971. }
  7972. LPWrapItems(newItem)
  7973. newItem[0].lbl = lbl
  7974. if (pariente) {
  7975. $(pariente).prepend(newItem)
  7976. } else {
  7977. $(items[0]).before(newItem)
  7978. }
  7979. items.splice(0, 0, newItem[0])
  7980. }
  7981. }
  7982. $lbl.addClass("counter_" + items.length)
  7983. lbl.items = items
  7984. if (items.length > 30) {
  7985. lbl.fullItems = items
  7986. lbl.items = items.slice(0, 30)
  7987. }
  7988. if (lbl.items.length > 0) {
  7989. if ($lbl.next().hasClass("horiGridBox")) {
  7990. configHoriGridBox($lbl.next())
  7991. } else {
  7992. $lbl.after(lbl.items)
  7993. diagramCellLabels()
  7994. }
  7995. } else {
  7996. if (lbl.hGrid) {
  7997. lbl.hGrid.remove()
  7998. }
  7999. $lbl.addClass("load_items")
  8000. $lbl.css({ display: "none" })
  8001. setTimeout(function () {
  8002. $lbl.css({ display: "block" })
  8003. }, 300)
  8004. }
  8005. }
  8006. }
  8007. })
  8008. //Crear un nuevo label de Recientes (18) al principio del mosaico pilar
  8009. if (createLabel) {
  8010. var PID = ""
  8011. var labelTitle = ""
  8012. if (tipItem == 1) {
  8013. PID = "libros"
  8014. labelTitle = "Continuar leyendo"
  8015. }
  8016. if (tipItem == 6) {
  8017. PID = "arte"
  8018. labelTitle = "Arte visto recientemente"
  8019. }
  8020. if (tipItem == 10) {
  8021. PID = "musica"
  8022. labelTitle = "Música escuchada recientemente"
  8023. }
  8024. if (labelID == "mydownld_1") {
  8025. labelTitle = "Mis descargas"
  8026. }
  8027. var pilarID = "pilar" + PID
  8028. var cacheID = PID + "_" + pilarID + "_0"
  8029. //Busca el grid del pilar
  8030. var gbs = null
  8031. if ($(lastItemSelected).hasClass(pilarID)) {
  8032. gbs = gridBoxSmall
  8033. } else {
  8034. for (var idCach in mosaicCache) {
  8035. if (mosaicCache.hasOwnProperty(idCach) && idCach == cacheID) {
  8036. gbs = mosaicCache[idCach][0][0]
  8037. break
  8038. }
  8039. }
  8040. }
  8041. if (gbs) {
  8042. var hayLabel = false
  8043. $.each(gbs.cell_labels, function () {
  8044. if ($(this).hasClass(labelID)) {
  8045. hayLabel = true
  8046. }
  8047. })
  8048. if (!hayLabel) {
  8049. createLabelRecientes(labelID, labelTitle, gbs)
  8050. }
  8051. }
  8052. }
  8053. }
  8054. this.resetLabel = function (_tipoSeccion, _tipoItem, _extra) {
  8055. resetLabel(_tipoSeccion, _tipoItem, _extra)
  8056. }
  8057. function createLabelRecientes(labelID, labelTitle, gbs) {
  8058. var divLabel = $(
  8059. '<div class="cell_label load_items ' +
  8060. labelID +
  8061. ' counter_0"><div class="tag_label">' +
  8062. labelTitle +
  8063. "</div></div>",
  8064. )
  8065. for (var i = 0; i < gbs.cell_labels.length; i++) {
  8066. if ($(gbs.cell_labels[i]).hasClass("mibliblio_0")) {
  8067. LPWrapItems(divLabel)
  8068. $(gbs.cell_labels[i + 1]).before(divLabel)
  8069. divLabel[0].items = $()
  8070. gbs.cell_labels.push(divLabel[0])
  8071. }
  8072. }
  8073. }
  8074. function reloadLabel(_label) {
  8075. var labelID = getLabelID(_label).join("_")
  8076. var labels = buscaLabels()
  8077. $.each(labels, function () {
  8078. var $LB = $(this)
  8079. var LB = this
  8080. if ($LB.hasClass(labelID)) {
  8081. removeClassRegex(/counter_\d+/, LB)
  8082. $(LB.items).remove()
  8083. $(LB.fullItems).remove()
  8084. $(LB.hGrid).remove()
  8085. LB.items = []
  8086. $LB.addClass("load_items counter_0")
  8087. $LB.css({ display: "none" })
  8088. setTimeout(function () {
  8089. $LB.css({ display: "block" })
  8090. }, 300)
  8091. }
  8092. })
  8093. }
  8094. this.reloadLabel = function (_label) {
  8095. reloadLabel(_label)
  8096. }
  8097. //Marca un elemento como favorito
  8098. this.doFavorite = function (tipoLibro, idLibro, idTrad, bannerFavorite) {
  8099. if (!lectorLogueado) {
  8100. return panelSocial.showAlertMiBiblioteca(44)
  8101. }
  8102. if (!idTrad) {
  8103. idTrad = -1
  8104. }
  8105. var isFavoriteBook = $(bannerFavorite).hasClass("favorite") ? true : false
  8106. var estado = isFavoriteBook ? 0 : 1
  8107. var saveFavorito = that.saveFavorito(tipoLibro, idLibro, idTrad, estado)
  8108. saveFavorito.done(function (d) {
  8109. d = $.trim(d)
  8110. if (d.indexOf("OK") > -1) {
  8111. isFavoriteBook = estado == 0 ? false : true
  8112. if (isFavoriteBook) {
  8113. bannerFavorite.addClass("favorite")
  8114. } else {
  8115. bannerFavorite.removeClass("favorite")
  8116. }
  8117. }
  8118. })
  8119. }
  8120. //Guarda un item como favorito
  8121. this.saveFavorito = function (tipoItem, idItem, idTrad, estado) {
  8122. var url = "/ltotal/lector/favoritos.jsp"
  8123. var queryURL = ltotalOS.getPostURL(url)
  8124. var params = {
  8125. tipoItem: tipoItem,
  8126. idItem: idItem,
  8127. idTrad: idTrad,
  8128. estado: estado,
  8129. ltotalurl: url,
  8130. }
  8131. jQuery.extend(params, that.SycCredentials)
  8132. params = $.trim(decodeURIComponent($.param(params)))
  8133. return $.post(queryURL, params).done(function () {
  8134. tipoItem == 16 ? (tipoItem = 45) : tipoItem
  8135. var idItemBitac =
  8136. tipoItem == 1 ? "4_" + idItem + "," + idTrad : tipoItem + "_" + idItem
  8137. var createItem = estado == 1
  8138. resetLabel(44, tipoItem, {
  8139. createItem: createItem,
  8140. idItemBitac: idItemBitac,
  8141. })
  8142. })
  8143. }
  8144. //Elimina el item de mis favoritos
  8145. function deleteFavorite(_ev) {
  8146. _ev.stopPropagation()
  8147. var item = $(this).parent()
  8148. var celldata = getCellID(item)
  8149. var tipoItem = celldata[0]
  8150. var id = celldata[1].split(",")
  8151. var idItem = id[0]
  8152. var idTrad = id[1]
  8153. tipoItem == 4 ? (tipoItem = 1) : tipoItem
  8154. tipoItem == 45 ? (tipoItem = 16) : tipoItem
  8155. !idTrad ? (idTrad = -1) : idTrad
  8156. var url = "/ltotal/lector/favoritos.jsp"
  8157. var queryURL = ltotalOS.getPostURL(url)
  8158. var params = {
  8159. tipoItem: tipoItem,
  8160. idItem: idItem,
  8161. idTrad: idTrad,
  8162. estado: 0,
  8163. ltotalurl: url,
  8164. }
  8165. jQuery.extend(params, that.SycCredentials)
  8166. params = $.trim(decodeURIComponent($.param(params)))
  8167. $.post(queryURL, params).done(function (d) {
  8168. d = $.trim(d)
  8169. if (d.indexOf("OK") > -1) {
  8170. refreshLabelCounters(item)
  8171. if (tipoItem == 16) {
  8172. $(
  8173. ".tag_favorite.id_favorite_" + idItem,
  8174. $("#dicc_total"),
  8175. ).removeClass("favorite")
  8176. }
  8177. }
  8178. })
  8179. }
  8180. //Guarda markador de una pagina
  8181. this.saveBookMark = function (
  8182. tipoLibro,
  8183. idLibro,
  8184. idTrad,
  8185. paginas,
  8186. porcentajes,
  8187. estado,
  8188. ) {
  8189. var url = "/ltotal/lector/marcadores.jsp"
  8190. var queryURL = ltotalOS.getPostURL(url)
  8191. var params = {
  8192. tipoLibro: tipoLibro,
  8193. idLibro: idLibro,
  8194. idTrad: idTrad,
  8195. paginas: paginas,
  8196. porcentajes: porcentajes,
  8197. estado: estado,
  8198. ltotalurl: url,
  8199. }
  8200. jQuery.extend(params, that.SycCredentials)
  8201. params = $.trim(decodeURIComponent($.param(params)))
  8202. return $.post(queryURL, params)
  8203. }
  8204. function deleteFotoPromoLibro(_ev) {
  8205. _ev.stopPropagation()
  8206. var item = $(this).parent()
  8207. var id = item[0].className
  8208. .match(/foto_promo_libro_\d+/)[0]
  8209. .match(/\d+/)[0]
  8210. var url = "/ltotal/inicio/edicion.jsp"
  8211. var queryURL = ltotalOS.getPostURL(url)
  8212. var params = { caso: 8, id_foto_promo: id, ltotalurl: url }
  8213. jQuery.extend(params, that.SycCredentials)
  8214. params = $.trim(decodeURIComponent($.param(params)))
  8215. $.post(queryURL, params).done(function (d) {
  8216. refreshLabelCounters(item)
  8217. })
  8218. }
  8219. function deleteRegaloLibro(_ev) {
  8220. _ev.stopPropagation()
  8221. var item = $(this).parent()
  8222. var id = item[0].className.match(/regalo_libro_\d+/)[0].match(/\d+/)[0]
  8223. var url = "/ltotal/nuevaEntrada/regalar_libro.jsp"
  8224. var queryURL = ltotalOS.getPostURL(url)
  8225. var params = { caso: 2, id_compartido: id, ltotalurl: url }
  8226. jQuery.extend(params, that.SycCredentials)
  8227. params = $.trim(decodeURIComponent($.param(params)))
  8228. $.post(queryURL, params).done(function (d) {
  8229. refreshLabelCounters(item)
  8230. })
  8231. }
  8232. function buscaLabels() {
  8233. var labels = []
  8234. labels.push.apply(labels, gridBoxSmall.cell_labels)
  8235. for (var idCach in mosaicCache) {
  8236. if (mosaicCache.hasOwnProperty(idCach)) {
  8237. labels.push.apply(labels, mosaicCache[idCach][0][0].cell_labels)
  8238. }
  8239. }
  8240. return labels
  8241. }
  8242. function refreshLabelCounters(item) {
  8243. item.fadeOut(function () {
  8244. var label = item[0].lbl
  8245. var labelID = getLabelID(label).join("_")
  8246. var itemID = getCellID(item[0]).join("_")
  8247. postRefreshLabelCounters(labelID, itemID)
  8248. })
  8249. }
  8250. function postRefreshLabelCounters(labelID, itemID) {
  8251. //Resetea los labels
  8252. var labels = buscaLabels()
  8253. $.each(labels, function () {
  8254. var LB = this
  8255. var $LB = $(LB)
  8256. if ($LB.hasClass(labelID)) {
  8257. var willDeleteItem = false
  8258. var items = LB.fullItems ? LB.fullItems : LB.items
  8259. items.each(function (i) {
  8260. if ($(this).hasClass("cell")) {
  8261. if (getCellID(this).join("_") == itemID) {
  8262. items.splice(i, 1)
  8263. willDeleteItem = true
  8264. $(this).remove()
  8265. }
  8266. }
  8267. })
  8268. //Ajusta contadores del label
  8269. var cntl = LB.className.match(/counter_\d+/)[0]
  8270. var cnt = parseInt(cntl.match(/\d+/)[0]) - (willDeleteItem ? 1 : 0)
  8271. $LB.removeClass(cntl).addClass("counter_" + cnt)
  8272. //Fin. Ajusta contadores del label
  8273. //Recarga el label cuando queda vacio
  8274. if (cnt == 0) {
  8275. $LB.addClass("load_items")
  8276. if (LB.hGrid) {
  8277. LB.hGrid.remove()
  8278. }
  8279. $LB.css({ display: "none" })
  8280. setTimeout(function () {
  8281. $LB.css({ display: "block" })
  8282. }, 300)
  8283. } else {
  8284. LB.items = items
  8285. if (items.length > 30) {
  8286. LB.fullItems = items
  8287. LB.items = items.slice(0, 30)
  8288. }
  8289. if ($LB.next().hasClass("horiGridBox")) {
  8290. configHoriGridBox($LB.next())
  8291. } else {
  8292. $LB.after(LB.items)
  8293. diagramCellLabels()
  8294. }
  8295. }
  8296. }
  8297. })
  8298. }
  8299. this.refreshLabelCounters = function (papa) {
  8300. refreshLabelCounters(papa)
  8301. }
  8302. //Descuenta el notificador numerico de un item
  8303. this.discountNovedad = function (_tipoLibro, _idLibro, _extraClass) {
  8304. var discount_rec = function (_cont) {
  8305. var rec_novedad = $(".rec_novedad", _cont)
  8306. if (rec_novedad[0]) {
  8307. var valor = parseInt(rec_novedad.text()) - 1
  8308. if (valor > 0) {
  8309. rec_novedad.text(valor)
  8310. } else {
  8311. rec_novedad.remove()
  8312. }
  8313. }
  8314. }
  8315. var extraClass = ""
  8316. if (_extraClass) {
  8317. extraClass = _extraClass
  8318. }
  8319. for (var idCache in mosaicCache) {
  8320. if (mosaicCache.hasOwnProperty(idCache)) {
  8321. var gridCache = mosaicCache[idCache][0]
  8322. $.each(gridCache[0].cell_labels, function (i, label) {
  8323. var cl = ".cell." + _tipoLibro + "_" + _idLibro + extraClass
  8324. var cell = $(cl, label.items)
  8325. if (!cell[0]) {
  8326. cell = label.items.filter(cl)
  8327. }
  8328. if (cell[0]) {
  8329. discount_rec(cell)
  8330. if (cell[0].parentNode) {
  8331. discount_rec(cell[0].parentNode.lbl)
  8332. if (cell[0].parentNode.lbl) {
  8333. //NOTA!
  8334. //NO es recursivo, convertir a recursivo cuando se necesite
  8335. discount_rec(cell[0].parentNode.lbl.itemParent)
  8336. }
  8337. }
  8338. }
  8339. })
  8340. }
  8341. }
  8342. }
  8343. function procBooksDownloaded(cellRawStr) {
  8344. var items = []
  8345. if (cellRawStr.length > 0) {
  8346. var cellsRaw = cellRawStr.split("#")
  8347. $.each(cellsRaw, function () {
  8348. if (this.length > 0) {
  8349. var cellData = this.split("|")
  8350. var idLtotal =
  8351. cellData.length > 3 ? cellData[3].replace("IDLTOTAL_", "") : ""
  8352. var cellDiv = document.createElement("div")
  8353. cellDiv.className =
  8354. "cell " +
  8355. cellData[0].replace("ID", "mydownld") +
  8356. " " +
  8357. cellData[1].toLowerCase() +
  8358. " mydownld " +
  8359. cellData[2].toLowerCase() +
  8360. " erase_bitac" +
  8361. " " +
  8362. idLtotal
  8363. items.push(cellDiv)
  8364. }
  8365. })
  8366. }
  8367. return items
  8368. }
  8369. function postProcBooksDownloaded(items, label) {
  8370. items = $(items)
  8371. LPWrapItems(items)
  8372. $.each(items, function () {
  8373. this.lbl = label
  8374. })
  8375. if (items.length > 30) {
  8376. label.fullItems = items
  8377. items = items.slice(0, 30)
  8378. }
  8379. label.items = items
  8380. $(label).after(items)
  8381. configureLabel(label)
  8382. diagramCellLabels()
  8383. preloadItems(items[0])
  8384. }
  8385. this.recentBooksDownloadedCallback = function (_msg) {
  8386. var msgObj = JSON.parse(_msg)
  8387. var cellRawStr = msgObj.bookCells
  8388. var labelRecs = $(".cell_label.18_1")[0]
  8389. if (labelRecs) {
  8390. var itemsMix = procBooksDownloaded(cellRawStr)
  8391. if (labelRecs.itemsMixDownloads) {
  8392. var seen = {}
  8393. $.each(labelRecs.itemsMixDownloads, function () {
  8394. if (this.className.indexOf("minibookhelp") == -1) {
  8395. var idLtotal = this.className.match(/4_\d+,\d+/)
  8396. if (idLtotal) {
  8397. seen[idLtotal[0]] = true
  8398. }
  8399. }
  8400. })
  8401. var itemsFiltered = []
  8402. $.each(itemsMix, function () {
  8403. var idLtotal = this.className.match(/4_\d+,\d+/)
  8404. if (idLtotal) {
  8405. if (!seen[idLtotal[0]]) {
  8406. itemsFiltered.push(this)
  8407. }
  8408. } else {
  8409. itemsFiltered.push(this)
  8410. }
  8411. })
  8412. $.each(labelRecs.itemsMixDownloads, function () {
  8413. if (this.className.indexOf("minibookhelp") > -1) {
  8414. $(this).addClass("date_9999999999999")
  8415. if (itemsMix.length == 0) {
  8416. itemsFiltered.push(this)
  8417. }
  8418. } else {
  8419. itemsFiltered.push(this)
  8420. }
  8421. })
  8422. itemsFiltered.sort(function (a, b) {
  8423. var d1 = parseInt(a.className.match(/date_\d+/)[0].match(/\d+/)[0])
  8424. var d2 = parseInt(b.className.match(/date_\d+/)[0].match(/\d+/)[0])
  8425. return d2 - d1
  8426. })
  8427. }
  8428. postProcBooksDownloaded(itemsFiltered, labelRecs)
  8429. }
  8430. }
  8431. this.recentBooksDownloadedCallback2 = function (_msg) {
  8432. var msgObj = JSON.parse(_msg)
  8433. var cellRawStr = msgObj.bookCells
  8434. if (cellRawStr.length > 0) {
  8435. createLabelRecientes("18_1", "Continuar leyendo", gridBoxSmall)
  8436. }
  8437. }
  8438. this.coverBookCallback = function (_msg) {
  8439. var msgObj = JSON.parse(_msg)
  8440. var bookID = msgObj.bookID
  8441. var title = msgObj.title
  8442. var author = msgObj.author.split(",")[0]
  8443. var tag = msgObj.tag
  8444. var year = msgObj.year
  8445. var imgB64 = msgObj.imageBase64
  8446. var wc = parseInt(msgObj.w)
  8447. var hc = parseInt(msgObj.h)
  8448. var celldld = $(".cell.mydownld_" + bookID)
  8449. nativeCovers[bookID] = _msg
  8450. if (celldld[0]) {
  8451. celldld.css({ width: "" })
  8452. var wcell = parseInt(celldld[0].offsetWidth)
  8453. var hcell = parseInt(celldld[0].offsetHeight)
  8454. var cRatio = wc / hc
  8455. var nwc = cRatio * hcell
  8456. var maxWidth = $(panelSocial.bodyDiv).hasClass("aumented")
  8457. ? isSmartPhone
  8458. ? 150
  8459. : 180
  8460. : isSmartPhone
  8461. ? 116
  8462. : 135
  8463. if (nwc > maxWidth) {
  8464. nwc = maxWidth
  8465. }
  8466. var mrc = parseInt(wcell - nwc)
  8467. celldld.addClass("cvLD")
  8468. celldld.css({
  8469. width: nwc + "px",
  8470. "margin-right": mrc + "px",
  8471. "background-image": "url('data:image/png;base64," + imgB64 + "')",
  8472. })
  8473. celldld.append(
  8474. '<input type="hidden" class="label" labelname="label_cell_info" value="true"/><input type="hidden" class="label" labelname="label_titulo" value="' +
  8475. title +
  8476. '" /><input type="hidden" class="label" labelname="label_autor_raw" value="' +
  8477. author +
  8478. '"/><input type="hidden" class="label" labelname="label_genero" value="' +
  8479. tag +
  8480. '"/><input type="hidden" class="label" labelname="label_year" value="' +
  8481. year +
  8482. '"/>',
  8483. )
  8484. postProcPortadas([celldld[0]])
  8485. }
  8486. }
  8487. this.resetLabelCallback = function (_msg) {
  8488. var msgObj = JSON.parse(_msg)
  8489. var bookID = msgObj.bookID
  8490. var tipoLabel = msgObj.type
  8491. var formato = msgObj.formato ? msgObj.formato : "format_epub"
  8492. if (tipoLabel == "recientes_ltotal") {
  8493. var bookID2 = msgObj.bookID2
  8494. if (lectorLogueado) {
  8495. that.saveBitacora(1, bookID, bookID2, 1, -1, "", 0, {
  8496. ignorePos: true,
  8497. })
  8498. }
  8499. }
  8500. if (tipoLabel == "recientes") {
  8501. if (lectorLogueado) {
  8502. resetLabel(18, 1, {
  8503. createLabel: true,
  8504. createItem: true,
  8505. idItemBitac: "mydownld_" + bookID,
  8506. extraClass: "mydownld " + formato,
  8507. })
  8508. }
  8509. }
  8510. if (tipoLabel == "descargas") {
  8511. if (lectorLogueado) {
  8512. var labeldld = $(".cell_label.mydownld_1")[0]
  8513. if (labeldld) {
  8514. $(labeldld.items).remove()
  8515. $(labeldld).addClass("load_items")
  8516. loadDataCellLabel(labeldld)
  8517. }
  8518. } else {
  8519. resetLabel("mydownld", 1, {
  8520. createLabel: true,
  8521. createItem: true,
  8522. idItemBitac: "mydownld_" + bookID,
  8523. extraClass: "mydownld " + formato,
  8524. })
  8525. }
  8526. }
  8527. }
  8528. this.refreshLabelCountersCallback = function (_msg) {
  8529. var msgObj = JSON.parse(_msg)
  8530. var bookID = msgObj.bookID
  8531. var tipoLabel = msgObj.type
  8532. if (tipoLabel == "recientes") {
  8533. postRefreshLabelCounters("18_1", "mydownld_" + bookID)
  8534. }
  8535. }
  8536. this.downloadsMosaicCallback = function (_msg) {
  8537. var msgObj = JSON.parse(_msg)
  8538. var cellRawStr = msgObj.bookCells
  8539. var labelMydownld = $(".cell_label.mydownld_1")[0]
  8540. var items = procBooksDownloaded(cellRawStr)
  8541. if (items.length > 0) {
  8542. postProcBooksDownloaded(items, labelMydownld)
  8543. } else {
  8544. var miniBookDiv = $(
  8545. '<div class="cell minibookhelp_mydownld_1"><img class="caraSlider" src="/testLtotal/recursos/mi_biblioteca/emtpy_row.png" /></div>',
  8546. )
  8547. postProcBooksDownloaded([miniBookDiv[0]], labelMydownld)
  8548. var cmdObj = {
  8549. Module: "OfflineApp",
  8550. Action: "DownloadsCount",
  8551. Callback: "panelSocial.mosaico.downloadsCountCallback",
  8552. }
  8553. panelSocial.executeNative(cmdObj)
  8554. }
  8555. }
  8556. this.downloadsMosaicCallback2 = function (_msg) {
  8557. var msgObj = JSON.parse(_msg)
  8558. var cellRawStr = msgObj.bookCells
  8559. var msgObj = JSON.parse(_msg)
  8560. var cellRawStr = msgObj.bookCells
  8561. if (cellRawStr.length > 0) {
  8562. createLabelRecientes("mydownld_1", "Mis descargas", gridBoxSmall)
  8563. }
  8564. }
  8565. this.downloadsCountCallback = function (_msg) {
  8566. var msgObj = JSON.parse(_msg)
  8567. var count = parseInt(msgObj.downloadsCount)
  8568. if (count == 0) {
  8569. ltotalUtils.loadScript(
  8570. panelSocial.getContextoEstaticos() + "/css/ltotal/helper.css",
  8571. )
  8572. var html0 =
  8573. '<div id="ltotal_helper" class="ltotal_helper">\
  8574. <div class="body_helper">\
  8575. <div class="title_helper">MIS DESCARGAS</div>\
  8576. <div class="img_helper" style="background-image: url(/estaticosED/files/css/ltotal/helper_images/step_11.png);"></div>\
  8577. <div class="txt_helper">Aún no tienes descargas para lectura offline. Puedes cargar tus propios libros en formato EPUB o descargar los libros de la biblioteca El Libro Total. Recuerda que este contenido estará disponible sólo en este dispositivo y no en la versión de escritorio.</div>\
  8578. <div class="close_helper"></div>\
  8579. </div>\
  8580. </div>'
  8581. var cont0 = $(html0)
  8582. $(".close_helper", cont0)[0].onclick = function () {
  8583. cont0.remove()
  8584. }
  8585. $(panelSocial.bodyDiv).append(cont0)
  8586. }
  8587. }
  8588. this.downloadsMosaic = function () {
  8589. if ($(".downloads_mosaic")[0]) {
  8590. return null
  8591. }
  8592. var htmllbl =
  8593. '<div class="cell_label mydownld_1 counter_0 load_items start_visible downloads_mosaic"><div class="tag_label">Mis descargas</div></div>'
  8594. var proc = $("#proceso").html(htmllbl)
  8595. LPWrapItems(proc[0].children)
  8596. mosaico.createMosaic2(
  8597. proc[0].children,
  8598. "libros",
  8599. $('<div class="cell mydownld_mydownld"></div>')[0],
  8600. 0,
  8601. { backNav: true },
  8602. )
  8603. }
  8604. this.searchBooksCallback = function (_msg) {
  8605. var msgObj = JSON.parse(_msg)
  8606. var autoComp = that.autoComplete
  8607. if (msgObj.suggestions.length > 0) {
  8608. $.each(msgObj.suggestions, function () {
  8609. autoComp.result.suggestions.push(this)
  8610. })
  8611. }
  8612. that.autoComplete.processResponse(
  8613. autoComp.result,
  8614. autoComp.q,
  8615. autoComp.cacheKey,
  8616. )
  8617. }
  8618. //TABS
  8619. function getTabManager() {
  8620. if (!tabManager) {
  8621. var setts = {
  8622. boxTabs: boxTabs,
  8623. fnAfterActiveTab: function () {
  8624. closeSearch()
  8625. that.setMosaicCache({ backNav: false })
  8626. },
  8627. fnClose: function () {
  8628. restoreLastMosaic()
  8629. $(boxMosaicFull).css({ display: "none" })
  8630. },
  8631. }
  8632. tabManager = new TabsManager(setts)
  8633. }
  8634. tabManager.boxBooks = isTouch ? boxMosaicFull : boxMosaic
  8635. return tabManager
  8636. }
  8637. this.openObjectInTab = function (_objectViewer, _label) {
  8638. getTabManager().setBookContent(_objectViewer, _label)
  8639. }
  8640. this.updateTab = function (_tabID, _nombTab) {
  8641. getTabManager().updateBookTab(_tabID, _nombTab)
  8642. }
  8643. this.destroyTab = function (_tabID) {
  8644. getTabManager().destroyBookTab(_tabID)
  8645. }
  8646. this.zoomTextObjectsTabs = function () {
  8647. getTabManager().zoomTextObjects()
  8648. }
  8649. //FIN. TABS
  8650. function configHTML() {
  8651. var ih = executeNative
  8652. ? $(window).height() + "px"
  8653. : window.innerHeight + "px"
  8654. $("html").css({ height: ih })
  8655. if (isSmartPhone) {
  8656. $(".contentViewer").css({ height: ih })
  8657. } else {
  8658. $(".contentViewer").css({ height: "100%" })
  8659. }
  8660. }
  8661. function repaintFluid() {
  8662. that.configHMarginItems()
  8663. diagramCellLabels()
  8664. configHorizGridBoxes()
  8665. that.rePaintBanner()
  8666. }
  8667. this.repaintFluid = function () {
  8668. repaintFluid()
  8669. }
  8670. this.rePaintBanner = function () {
  8671. createCaratulaBanner($(".banner_ficha_item", gridBoxSmall)[0], {})
  8672. }
  8673. this.rePaint = function () {
  8674. detectDeviceResolution()
  8675. configHTML()
  8676. var tm = getTabManager()
  8677. if (tm.getActiveTab()) {
  8678. tm.rePaint()
  8679. } else {
  8680. repaintFluid()
  8681. }
  8682. panelSocial.rePaintShareModal()
  8683. panelSocial.rePaintModalViewer()
  8684. llector.rePaint()
  8685. generateMenus()
  8686. placeMainBtns()
  8687. that.configBtnLogin()
  8688. that.activateCategsMenuBtns()
  8689. hideCategsMenu({ no_animate: true })
  8690. if (typeof panelVideo !== "undefined") {
  8691. panelVideo.rePaint()
  8692. }
  8693. }
  8694. this.show = function () {
  8695. $(that.mainFrame).fadeTo(200, 1)
  8696. }
  8697. this.hide = function () {
  8698. $(that.mainFrame).fadeTo(200, 0)
  8699. }
  8700. this.getContain = function () {
  8701. return this.mainFrame
  8702. }
  8703. this.getDivContent = function () {
  8704. return contentTxt
  8705. }
  8706. this.activateBtnCerrar = function () {
  8707. $(closeMosaic).css({ display: "block" })
  8708. $(pilarSearch).css({ width: "230px", right: "86px" })
  8709. $(".squared", pilarSearch).css({ width: "192px" })
  8710. }
  8711. this.cerrar = function () {
  8712. //NOTA
  8713. //Esta funcion solo se usa cuando el libro total se abre en una pestana aparte desde otra aplicacion
  8714. window.history.go(-1)
  8715. }
  8716. detectDeviceResolution()
  8717. generateMenus()
  8718. if (settings.modePilars) {
  8719. $(window).resize(that.rePaint)
  8720. window.addEventListener("popstate", that.getBackNavigation, false)
  8721. window.onunload = function () {
  8722. //Elimina registro de bloqueo de edicion del libro
  8723. if (navigator.sendBeacon) {
  8724. if (typeof edicion != "undefined" && edicion.libros.editorVisible) {
  8725. var id_libro = edicion.libros.cont[0].id_libro
  8726. var id_trad = edicion.libros.cont[0].id_trad
  8727. var dblob = new Blob(["test"], { type: "text/plain" })
  8728. navigator.sendBeacon(
  8729. "/ltotal/inicio/edicion_libros.jsp?caso=8&subcaso=2&id_libro=" +
  8730. id_libro +
  8731. "&id_traduccion=" +
  8732. id_trad,
  8733. dblob,
  8734. )
  8735. }
  8736. }
  8737. }
  8738. configHTML()
  8739. }
  8740. }
  8741. //Señal de cargando
  8742. function PanelSOCIALLoaderItem() {
  8743. this.boxLoader = document.createElement("div")
  8744. this.boxLoader.setAttribute("class", "boxLoader")
  8745. var circleA = document.createElement("div")
  8746. circleA.setAttribute("class", "circleLoad circleA")
  8747. $(this.boxLoader).append(circleA)
  8748. this.getContain = function () {
  8749. return this.boxLoader
  8750. }
  8751. this.destroy = function () {
  8752. $(this.boxLoader).remove()
  8753. }
  8754. }
  8755. //Administrador por pestanas de libros y diccionarios abiertos (componentes)
  8756. function TabsManager(opts) {
  8757. var that = this
  8758. var settings = $.extend({}, opts)
  8759. var tabsList = {},
  8760. tabIdx = 0
  8761. //Area de pestanas y herramientas
  8762. var boxTools = settings.boxTabs
  8763. $(boxTools).addClass("TabsManager")
  8764. //Area de visores de los contenidos
  8765. that.boxBooks = null
  8766. var isTouch = ltotalOS.isSmartPhone || ltotalOS.isTablet
  8767. var executeNative = panelSocial.executeNative("TEST")
  8768. this.setBookContent = function (_viewerText, _label) {
  8769. $(that.boxBooks).css({ display: "" })
  8770. reAttachChildren(_viewerText.getContain())
  8771. tabsList["tab_" + tabIdx] = _viewerText
  8772. _viewerText.idTab = tabIdx
  8773. createBookTab(tabIdx, _label)
  8774. tabIdx++
  8775. }
  8776. function createBookTab(_tabID, _nombTab) {
  8777. $(boxTools).css({ display: "block" })
  8778. var tab = document.createElement("div")
  8779. tab.className = "bookTab tab_" + _tabID
  8780. $(tab).html(
  8781. '<div class="tab_label">' +
  8782. _nombTab +
  8783. '</div><div class="buttonClosePesta"></div>',
  8784. )
  8785. $(boxTools).append(tab)
  8786. var tabLabel = $(".tab_label", tab)[0]
  8787. tabLabel.title = _nombTab
  8788. //Boton de cerrar una pestana
  8789. var btnClosePesta = $(".buttonClosePesta", tab)[0]
  8790. btnClosePesta.title = "Cerrar " + _nombTab
  8791. btnClosePesta.onclick = cerrarPestana
  8792. var activeTab = function (_tab) {
  8793. $(".bookTab.active", boxTools).removeClass("active")
  8794. $(_tab).addClass("active")
  8795. if (typeof settings.fnAfterActiveTab == "function") {
  8796. settings.fnAfterActiveTab()
  8797. }
  8798. }
  8799. tab.onclick = function () {
  8800. var idx = this.className.match(/tab_\d+/)[0].match(/\d+/)[0]
  8801. var vT = tabsList["tab_" + idx]
  8802. var reattached = reAttachChildren(vT.getContain())
  8803. if (reattached) {
  8804. activeTab(this)
  8805. that.rePaint()
  8806. }
  8807. }
  8808. activeTab(tab)
  8809. $(tab).animate({ width: "180px" }, 300)
  8810. }
  8811. this.destroyBookTab = function (_tabID) {
  8812. //Elimina el libro del vector
  8813. delete tabsList["tab_" + _tabID]
  8814. var tab = $(".tab_" + _tabID, boxTools)
  8815. var nextTab = tab.next(".bookTab")[0]
  8816. if (!nextTab) {
  8817. nextTab = tab.prev(".bookTab")[0]
  8818. }
  8819. $(tab).animate({ width: "0" }, 200, function () {
  8820. tab.remove()
  8821. })
  8822. if (nextTab) {
  8823. $(nextTab).trigger("click")
  8824. } else {
  8825. cerrar()
  8826. }
  8827. }
  8828. this.updateBookTab = function (_tabID, _nombTab) {
  8829. var tab = $(".tab_" + _tabID, boxTools)
  8830. var tabLabel = $(".tab_label", tab)
  8831. tabLabel.text(_nombTab)
  8832. tabLabel[0].title = _nombTab
  8833. //Boton de cerrar una pestana
  8834. var btnClosePesta = $(".buttonClosePesta", tab)[0]
  8835. btnClosePesta.title = "Cerrar " + _nombTab
  8836. }
  8837. function reAttachChildren(_newChild) {
  8838. var r = false
  8839. var oldChild = $(that.boxBooks).children()
  8840. if ($(_newChild)[0] != oldChild[0]) {
  8841. panelSocial.clearAudioData(oldChild)
  8842. oldChild.detach()
  8843. $(that.boxBooks).append(_newChild)
  8844. r = true
  8845. }
  8846. return r
  8847. }
  8848. function cerrar() {
  8849. resetear()
  8850. $(boxTools).css({ display: "none" })
  8851. if (typeof settings.fnClose == "function") {
  8852. settings.fnClose()
  8853. }
  8854. }
  8855. function resetear() {
  8856. tabsList = {}
  8857. tabIdx = 0
  8858. $(".bookTab", boxTools).remove()
  8859. $(that.boxBooks).children().remove()
  8860. }
  8861. function cerrarPestana(_ev) {
  8862. _ev.stopPropagation()
  8863. var tab = $(this).parents(".bookTab")[0]
  8864. var idx = tab.className.match(/tab_\d+/)[0].match(/\d+/)[0]
  8865. var vT = tabsList["tab_" + idx]
  8866. vT.cerrar()
  8867. }
  8868. this.getActiveTab = function () {
  8869. return $(".bookTab.active", boxTools)[0]
  8870. }
  8871. this.rePaint = function () {
  8872. var tab = that.getActiveTab()
  8873. if (tab) {
  8874. var idTab = tab.className.match(/tab_\d+/)[0].match(/\d+/)[0]
  8875. var vT = tabsList["tab_" + idTab]
  8876. var display = $(vT.getContain()).css("display")
  8877. if (display == "none") {
  8878. $(vT.getContain()).css({ display: "" })
  8879. }
  8880. var extra = isTouch && executeNative ? { forcedRepaint: true } : {}
  8881. vT.rePaint(extra)
  8882. }
  8883. }
  8884. this.zoomTextObjects = function () {
  8885. for (var key in tabsList) {
  8886. if (tabsList.hasOwnProperty(key)) {
  8887. $(tabsList[key].boxViewerTXT)[0].zoomedText = true
  8888. }
  8889. }
  8890. }
  8891. }
  8892. //////// Html内置js,全部重新做一次 Initialization
  8893. var contentVIEWER = null
  8894. var alertLM = null
  8895. var audiosEwall = null
  8896. var dataMusicEwall = null
  8897. var executeNative = false
  8898. var executeNativePlatform = false
  8899. var hayDeepLink = false
  8900. var deepLinkUrl = null
  8901. var initScriptsLoaded = false
  8902. var idSesion = "0DF421047363AE1F370C563BAE934432"
  8903. window.onload = function () {
  8904. try {
  8905. executeNative = ltotalUtils.executeNative("TEST")
  8906. if (executeNative) {
  8907. executeNativePlatform = ltotalUtils.executeNative("PLATFORM")
  8908. }
  8909. } catch (e) {}
  8910. // initPanelSocial();
  8911. initLtotal()
  8912. setTimeout(function () {
  8913. goForScripts(1)
  8914. goForCSSs()
  8915. }, 1200)
  8916. }
  8917. function goForScripts(_c) {
  8918. var scripts = [
  8919. "/js/jquery-ui-1.13.3.min.js",
  8920. "/js/jquery.jSuggest.js",
  8921. "/js/dragger-1.0.0.js",
  8922. "/js/filtrohtml-1.0.0.js",
  8923. "/js/multicolumn-1.0.0.js",
  8924. "/js/imgViewer-1.0.2.js",
  8925. "/js/panelPTI-1.0.0.js",
  8926. "/js/dicc_total-1.0.0.js",
  8927. "/js/AlertLM-1.0.0.js",
  8928. "/js/dialogueLM-1.0.1.js",
  8929. "/js/ltotal/modalViewerLT.js",
  8930. "/js/ltotal/jquery.autocomplete.js",
  8931. "/js/viewerTxt-1.0.4.js",
  8932. "/js/ltotal/viewerTxtServices-1.0.0.js",
  8933. "/js/ltotal/globo-audiolectura-1.0.0.js",
  8934. "/js/ltotal/llector-1.0.0.js",
  8935. "/js/ltotal/corpus.js",
  8936. "/js/rangy-core.js",
  8937. "/js/diff_match_patch.js",
  8938. "/js/ltotal/edicion.js",
  8939. "/js/ltotal/editToolbar-1.0.0.js",
  8940. "/js/ltotal/fisher-1.0.0.js",
  8941. "/js/ltotal/share-1.0.0.js",
  8942. "/js/ltotal/clipboard.min.js",
  8943. "/js/ltotal/panelMusic-1.0.0.js",
  8944. "/js/rangy-cssclassapplier.js",
  8945. ]
  8946. var xhrs = []
  8947. for (var i = 0; i < scripts.length; i++) {
  8948. var addr = "/estaticosED/files" + scripts[i]
  8949. xhrs.push(ltotalUtils.loadScripts(addr, _c))
  8950. }
  8951. $.when.apply($, xhrs).then(
  8952. function () {
  8953. initScriptsLoaded = true
  8954. rangy.init()
  8955. alertLM = new AlertLM()
  8956. edicion.iniciar()
  8957. },
  8958. function (_e) {
  8959. if (_c < 10) {
  8960. goForScripts(_c + 1)
  8961. }
  8962. },
  8963. )
  8964. }
  8965. function goForCSSs() {
  8966. var csss = [
  8967. "/css/jquery-ui.custom.min.css",
  8968. "/css/dicc_total-1.0.0.css",
  8969. "/css/imgViewer-1.0.0.css",
  8970. "/css/scrollSyc-1.0.0.css",
  8971. "/css/PanelAlert-1.0.0.css",
  8972. "/css/dialogueLM-1.0.1.css",
  8973. "/css/jSuggest.css",
  8974. "/css/ltotal/modalViewerLT.css",
  8975. "/css/viewerTxt-1.0.4.css",
  8976. "/css/ltotal/corpus.css",
  8977. "/css/ltotal/viewerTxtComparado-1.0.0.css",
  8978. "/css/ltotal/llector-1.0.0.css",
  8979. "/css/ltotal/fisher-1.0.0.css",
  8980. "/css/ltotal/edicion-1.0.0.css",
  8981. "/css/ltotal/multipage-1.0.0.css",
  8982. "/css/ltotal/editToolbar-1.0.0.css",
  8983. "/css/ltotal/share-1.0.0.css",
  8984. "/css/ltotal/panelMusic-1.0.0.css",
  8985. ]
  8986. for (var i = 0; i < csss.length; i++) {
  8987. ltotalUtils.loadScript("/estaticosED/files" + csss[i])
  8988. }
  8989. }
  8990. function initPanelSocial() {
  8991. var ltotalOSConfig = {
  8992. bridged: false,
  8993. //repoDir: "https://www.syc.com.co/estaticos/repo_ltotal",
  8994. //queryURLPrefix: "EscritorioUniversal/LtotalBridge.aspx"
  8995. //queryURLPrefix: "http://www.ellibrototal.com"
  8996. //queryURLPrefix: "http://test.ellibrototal.com.co"
  8997. queryURLPrefix: "",
  8998. }
  8999. ltotalOS.init(ltotalOSConfig)
  9000. var btnCerrar = $.trim(gup("btnCerrar"))
  9001. var settings = {
  9002. withLogin: true,
  9003. contMusicHostDiv: ".boxBread",
  9004. btnCerrar: btnCerrar,
  9005. }
  9006. panelSocial = new PanelSOCIAL(settings)
  9007. }
  9008. function initLtotal() {
  9009. var isSmartPhone = ltotalOS.isSmartPhone
  9010. var isTablet = ltotalOS.isTablet
  9011. var isTouch = isSmartPhone || isTablet
  9012. if (!contentVIEWER) {
  9013. if (isSmartPhone) {
  9014. contentVIEWER = new ContentViewer_mobile({
  9015. name: "contentVIEWER",
  9016. content: "",
  9017. height: $(window).height(),
  9018. background: "transparent",
  9019. closeButton: false,
  9020. title: "",
  9021. })
  9022. contentVIEWER.removeBtnTop("backLevel")
  9023. contentVIEWER.removeBtnTop("backLevel_SocialApps")
  9024. contentVIEWER.setTitle("")
  9025. contentVIEWER.addClassContainViewer("ltotalClass")
  9026. } else {
  9027. contentVIEWER = new ContentViewer({
  9028. name: "contentVIEWER",
  9029. buttonsBar: false,
  9030. titleBar: false,
  9031. fixed: true,
  9032. background: "transparent",
  9033. closeButton: false,
  9034. })
  9035. }
  9036. $(".mainContent", contentVIEWER.mainFrame).css({
  9037. "background-color": "transparent",
  9038. })
  9039. $(".topBar, .bottomBar", contentVIEWER.mainFrame).remove()
  9040. $(contentVIEWER.mainFrame).css({
  9041. display: "block",
  9042. width: "100%",
  9043. height: "100%",
  9044. "background-color": "transparent",
  9045. })
  9046. }
  9047. LTotalWebAppReady()
  9048. setTimeout(function () {
  9049. document.body.appendChild(contentVIEWER.mainFrame)
  9050. var extra = {}
  9051. extra.idCliente = 1
  9052. panelSocial.setNativeMainViewBGColor(11, 28, 43)
  9053. $(".mainContent").css({ width: "100%", height: "100%", top: "0" })
  9054. panelSocial.initLibroTotal(contentVIEWER, postloadCallback, extra)
  9055. }, 150)
  9056. }
  9057. function postloadCallback() {
  9058. if (initScriptsLoaded) {
  9059. var isSmartPhone = ltotalOS.isSmartPhone
  9060. var isTablet = ltotalOS.isTablet
  9061. var isTouch = isSmartPhone || isTablet
  9062. //Estadistica de visitas a la interfaz eDesk
  9063. ltotalOS.statistics(81, navigator.userAgent.toLowerCase())
  9064. var extraNav = { isTouch: isTouch }
  9065. //Llama funciones despues del cargue del sistema
  9066. var huboURL = processURL(extraNav)
  9067. if (!huboURL) {
  9068. huboURL = processLastNavigation(extraNav)
  9069. }
  9070. promoNativeApp({ isTouch: isTouch, huboURL: huboURL })
  9071. panelSocial.getLaunchCounter()
  9072. processDeepLink()
  9073. } else {
  9074. setTimeout(function () {
  9075. postloadCallback()
  9076. }, 800)
  9077. }
  9078. }
  9079. function LTotalWebAppReady() {
  9080. var cmdObj = { Module: "App", Action: "LTotalWebAppReady" }
  9081. var cmdNat = panelSocial.executeNative(cmdObj)
  9082. }
  9083. function processDeepLink() {
  9084. var cmdObj = {
  9085. Module: "App",
  9086. Action: "ProcessDeepLink",
  9087. Callback: "processDeepLinkCallback",
  9088. }
  9089. var cmdNat = panelSocial.executeNative(cmdObj)
  9090. }
  9091. function processDeepLinkCallback(_msg) {
  9092. var cb = JSON.parse(_msg)
  9093. deepLinkUrl = cb.deepLinkUrl
  9094. if ($.trim(deepLinkUrl).length > 0) {
  9095. if (deepLinkUrl.indexOf("/ltotal/passwd.jsp") != -1) {
  9096. return restorePassword()
  9097. }
  9098. hayDeepLink = true
  9099. deepLinkUrl = deepLinkUrl
  9100. .replace(/t_item/gi, "t")
  9101. .replace(/id_item/gi, "d")
  9102. .replace(/\&id_filter\=/gi, "_")
  9103. .replace(/idLibro/gi, "t=1&d")
  9104. processURL(null)
  9105. }
  9106. }
  9107. function getIdDedicatoria() {
  9108. var idDed = ""
  9109. var g = gup("g")
  9110. if ($.trim(g).length > 0) {
  9111. idDed = g
  9112. } else {
  9113. var gi = gup("gi")
  9114. if ($.trim(gi).length > 0) {
  9115. idDed = gi
  9116. }
  9117. }
  9118. return idDed
  9119. }
  9120. //Obtiene el valor de un parametro en la url
  9121. function gup(name) {
  9122. name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]")
  9123. var regexS = "[\\?#&]" + name + "=([^&#]*)"
  9124. var regex = new RegExp(regexS)
  9125. var results =
  9126. executeNative && hayDeepLink
  9127. ? regex.exec(deepLinkUrl)
  9128. : regex.exec(window.location.href)
  9129. if (results == null) return ""
  9130. else return results[1]
  9131. }
  9132. function processURL(_extra) {
  9133. //Oculta el buscador de moviles
  9134. $(".searchLT").blur()
  9135. $(".boxSearchMos").hide()
  9136. $(".autocomplete-suggestions").hide()
  9137. var data = $.trim(gup("d")).split(/,|_/)
  9138. var tipo = $.trim(gup("t"))
  9139. if (tipo.length == 0) {
  9140. tipo = $.trim(gup("c"))
  9141. }
  9142. if (tipo.length == 0) {
  9143. tipo = 1
  9144. }
  9145. return openNavigation(tipo, data, _extra)
  9146. }
  9147. function processLastNavigation(_extra) {
  9148. var r = false
  9149. var navData = ltotalUtils.fromLocalStorage("lastNavData")
  9150. if (navData) {
  9151. navData = navData.split("_")
  9152. r = openNavigation(navData.shift(), navData)
  9153. localStorage.removeItem("lastNavData")
  9154. }
  9155. return r
  9156. }
  9157. function openNavigation(tipo, data, _extra) {
  9158. var hayData = data.length > 0
  9159. var idLibro = -1
  9160. var idTrad = -1
  9161. var numePagina = 1
  9162. var huboURL = false
  9163. if (tipo == 1 && hayData) {
  9164. //Revisa si el libro es publico
  9165. idLibro = data[0]
  9166. idTrad = data[1]
  9167. if (!idLibro) {
  9168. return null
  9169. }
  9170. var getBookExtraData = function () {
  9171. if (data.length > 2) {
  9172. numePagina = data[2]
  9173. }
  9174. var extra = {
  9175. numePagina: numePagina,
  9176. }
  9177. if (data[3]) {
  9178. extra.numePaginaPercent = data[3]
  9179. }
  9180. var dedicatoria = getIdDedicatoria()
  9181. if (dedicatoria.length > 0) {
  9182. extra.idRegalo = dedicatoria
  9183. }
  9184. //Abre el libro subrayado con nota de personaje (15) relacionada
  9185. var rel = $.trim(gup("rel"))
  9186. if (rel.length > 0) {
  9187. rel = rel.split("_")
  9188. extra.idRecRela = rel[1]
  9189. extra.npagRecRela = numePagina
  9190. extra.idNotaRecRela = -1
  9191. }
  9192. var coord = $.trim(gup("txt_coord"))
  9193. if (coord.length > 0) {
  9194. extra.txtCoord = coord
  9195. }
  9196. return extra
  9197. }
  9198. var willOpenBook = true
  9199. var nbk = gup("nbk")
  9200. if (nbk.length > 0 && nbk == "1") {
  9201. willOpenBook = false
  9202. }
  9203. if (willOpenBook) {
  9204. var sb = panelSocial.selectedBook
  9205. if (sb) {
  9206. sb.cerrar()
  9207. }
  9208. }
  9209. $.post(
  9210. "/ltotal/inicio/utils/ut_10.jsp",
  9211. "tipo_item=1&id_libro=" + idLibro,
  9212. function (d) {
  9213. var libroOK = d.indexOf("libro_ok") > -1
  9214. if (!libroOK) {
  9215. return null
  9216. }
  9217. var item = document.createElement("div")
  9218. item.className = "cell 1_" + idLibro + " cvLD"
  9219. item.style.display = "inline-block"
  9220. var doOpenTries = 1
  9221. var postProcBook = function () {
  9222. var doOpenBook = function () {
  9223. doOpenTries++
  9224. var banner = $(".caratula_banner")[0]
  9225. if (banner && banner.childElementCount > 0) {
  9226. if (idTrad) {
  9227. panelSocial.openBook(1, idLibro, idTrad, getBookExtraData())
  9228. }
  9229. } else {
  9230. if (doOpenTries <= 5) {
  9231. setTimeout(doOpenBook, 1000)
  9232. }
  9233. }
  9234. }
  9235. if (willOpenBook) {
  9236. doOpenBook()
  9237. }
  9238. }
  9239. var xhr1 = panelSocial.clickSobreItem(
  9240. item,
  9241. "libros",
  9242. panelSocial.mosaico,
  9243. getBookExtraData(),
  9244. )
  9245. if (xhr1) {
  9246. xhr1.done(postProcBook)
  9247. } else {
  9248. postProcBook()
  9249. }
  9250. },
  9251. )
  9252. huboURL = true
  9253. }
  9254. if (tipo == 3 && hayData) {
  9255. //Autor
  9256. if (!data[1]) {
  9257. data[1] = 1
  9258. }
  9259. var idAutor = parseInt(data[0])
  9260. var tipoAutor = parseInt(data[1])
  9261. idLibro = parseInt(data[2])
  9262. var idIlust = parseInt(data[3])
  9263. if (tipoAutor == 1) {
  9264. //autor de libros
  9265. }
  9266. if (tipoAutor == 6) {
  9267. //Autor de imagenes
  9268. //Cerrar visor de imagenes
  9269. var bvi = $(".boxViewerImg")
  9270. if (bvi[0]) {
  9271. $(".closeViewer").trigger("click")
  9272. }
  9273. $.post(
  9274. "/ltotal/inicio/utils/ut_2.jsp",
  9275. "id_autor=" + idAutor + "&id_libro=" + idLibro,
  9276. function (_d) {
  9277. var imagsIds = _d
  9278. .replace(/\n|\r/g, "")
  9279. .replace(/(,$|:fin)/, "")
  9280. .split(",")
  9281. panelSocial.processIdsImages(imagsIds, idIlust)
  9282. },
  9283. )
  9284. }
  9285. var item = document.createElement("div")
  9286. item.className = "cell 3_" + idAutor + " cvLD"
  9287. item.style.display = "inline-block"
  9288. panelSocial.clickSobreItem(item, "libros", panelSocial.mosaico)
  9289. huboURL = true
  9290. }
  9291. if (tipo == 4 && hayData) {
  9292. idTrad = data[0]
  9293. var sb = panelSocial.selectedBook
  9294. if (sb) {
  9295. sb.cerrar()
  9296. }
  9297. var url = "/ltotal/inicio/utils/ut_48.jsp"
  9298. var params = { caso: "1", id_trad: idTrad }
  9299. panelSocial.doPost(url, params).done(function (_data) {
  9300. var p = $("#proceso").html(_data)
  9301. idLibro = parseInt($(".hdn_id_lib", p).val())
  9302. var extra = {}
  9303. if (data.length > 1) {
  9304. extra.numePagina = data[1]
  9305. }
  9306. panelSocial.openBook(1, idLibro, idTrad, extra)
  9307. })
  9308. }
  9309. if (tipo == 6 && hayData) {
  9310. var idImg = data[0]
  9311. panelSocial.processIdsImages([idImg], idImg)
  9312. }
  9313. if (tipo == 10 && hayData) {
  9314. var idMusic = data[0]
  9315. var extraMusic = {}
  9316. if (_extra && _extra.isTouch) {
  9317. extraMusic.stopMusic = true
  9318. }
  9319. panelSocial.openMusicByID(idMusic, extraMusic)
  9320. huboURL = true
  9321. }
  9322. if (tipo == 15 && hayData) {
  9323. var sb = panelSocial.selectedBook
  9324. if (sb) {
  9325. sb.cerrar()
  9326. }
  9327. if (data.length == 1) {
  9328. var idRec = data[0]
  9329. panelSocial.openBookPersoByIDRec(idRec)
  9330. } else {
  9331. var idProy = data[0]
  9332. var idNote = data[1]
  9333. panelSocial
  9334. .getSeccionLibroByIDNota(32, idProy, idNote)
  9335. .then(function (_nsec) {
  9336. var extra = {
  9337. numeSeccion: _nsec,
  9338. }
  9339. if (data[2]) {
  9340. extra.numePaginaPercent = data[2]
  9341. }
  9342. var dedicatoria = getIdDedicatoria()
  9343. if (dedicatoria.length > 0) {
  9344. extra.idRegalo = dedicatoria
  9345. }
  9346. panelSocial.openBook(32, idProy, -1, extra)
  9347. })
  9348. }
  9349. huboURL = true
  9350. }
  9351. if (tipo == 16 && hayData) {
  9352. var idWord = data[0]
  9353. panelSocial.openDiccTotal(null, null, {
  9354. idWord: idWord,
  9355. casoRela: 1,
  9356. openInTab: true,
  9357. })
  9358. huboURL = true
  9359. }
  9360. if (tipo == 17 && hayData) {
  9361. var idArticle = data[0]
  9362. if (!idArticle) {
  9363. return null
  9364. }
  9365. var item = document.createElement("div")
  9366. item.className = "cell 17_" + idArticle + " cvLD"
  9367. item.style.display = "inline-block"
  9368. panelSocial.clickSobreItem(item, "libros", panelSocial.mosaico)
  9369. huboURL = true
  9370. //NOTA!!
  9371. //En futuro expandir para que se pueda abrir el articulo y ubicarse en la pagina y porcentaje
  9372. }
  9373. if (tipo == 27 && hayData) {
  9374. var idProy = data[0]
  9375. var idNote = "0"
  9376. if (data[1]) {
  9377. idNote = data[1].split(":")[0]
  9378. }
  9379. //var idNotePage = 0;
  9380. //NOTA!!
  9381. //data[1].split(":")[1] contiene el numero de pagina de la nota
  9382. panelSocial
  9383. .getSeccionLibroByIDNota(27, idProy, idNote)
  9384. .then(function (_nsec) {
  9385. if (_nsec < 0) {
  9386. var item = document.createElement("div")
  9387. item.className = "cell 27_" + idProy + " cvLD"
  9388. item.style.display = "inline-block"
  9389. return panelSocial.clickSobreItem(
  9390. item,
  9391. "libros",
  9392. panelSocial.mosaico,
  9393. )
  9394. }
  9395. var extra = {
  9396. numeSeccion: _nsec,
  9397. }
  9398. //Abre el libro de investigacion subrayado con nota de personaje (15) relacionada
  9399. var rel = $.trim(gup("rel"))
  9400. var relaData = null
  9401. if (rel.length > 0) {
  9402. rel = rel.split("_")
  9403. extra.idRecRela = rel[1]
  9404. extra.npagRecRela = -1
  9405. extra.idNotaRecRela = idNote
  9406. }
  9407. panelSocial.openBook(27, idProy, -1, extra)
  9408. })
  9409. huboURL = true
  9410. }
  9411. if (tipo == 32 && hayData) {
  9412. idLibro = data[0]
  9413. if (!idLibro) {
  9414. return null
  9415. }
  9416. var item = document.createElement("div")
  9417. item.className = "cell 32_" + idLibro + " cvLD"
  9418. item.style.display = "inline-block"
  9419. panelSocial.clickSobreItem(item, "libros", panelSocial.mosaico)
  9420. huboURL = true
  9421. }
  9422. if (tipo == 51 && hayData) {
  9423. var idVideo = data[0]
  9424. if (!idVideo) {
  9425. return null
  9426. }
  9427. $.post(
  9428. "/ltotal/inicio/utils/ut_10.jsp",
  9429. "tipo_item=51&id_video=" + idVideo,
  9430. function (d) {
  9431. var videoOK = d.indexOf("video_ok") > -1
  9432. if (!videoOK) {
  9433. return null
  9434. }
  9435. var item = document.createElement("div")
  9436. item.className = "cell 51_" + idVideo + " cvLD"
  9437. item.style.display = "inline-block"
  9438. panelSocial.clickSobreItem(item, "videos", panelSocial.mosaico)
  9439. },
  9440. )
  9441. huboURL = true
  9442. }
  9443. if (tipo == "phev") {
  9444. //Abre el libro con fotografia del lector tomada como promocion en la feria
  9445. //phev es el parametro 'ph'oto 'ev'ent
  9446. var idFotoPromo = data[0]
  9447. if (idFotoPromo) {
  9448. $.post(
  9449. "/ltotal/inicio/utils/ut_43.jsp",
  9450. "idFotoPromo=" + idFotoPromo,
  9451. function (d) {
  9452. var idLib = d.match(/idLib_\d+/)[0].match(/\d+/)[0]
  9453. var idTrad = d.match(/idTrad_\d+/)[0].match(/\d+/)[0]
  9454. panelSocial.openBook(1, idLib, idTrad, {
  9455. idFotoPromo: idFotoPromo,
  9456. numePagina: 1,
  9457. })
  9458. },
  9459. )
  9460. }
  9461. huboURL = true
  9462. }
  9463. if (tipo == "contacto") {
  9464. //Abre contenedor de contactenos
  9465. panelSocial.mosaico.showContactenos()
  9466. huboURL = true
  9467. }
  9468. if (tipo == "mlnk") {
  9469. var sb = panelSocial.selectedBook
  9470. if (sb) {
  9471. sb.cerrar()
  9472. }
  9473. var mosaicLink = gup("d")
  9474. panelSocial.openMosaicLink(mosaicLink)
  9475. }
  9476. return huboURL
  9477. }
  9478. function getSYCCredentials() {
  9479. var ku = $.trim(gup("ku"))
  9480. var ki = $.trim(gup("ki"))
  9481. var kp = $.trim(gup("kp"))
  9482. if (ku.length > 0 && ki.length > 0 && kp.length) {
  9483. $(document.body).append(
  9484. '<input id="Valor1" type="hidden" value="' + ki + '" />',
  9485. )
  9486. $(document.body).append(
  9487. '<input id="Valor2" type="hidden" value="' + ku + '" />',
  9488. )
  9489. $(document.body).append(
  9490. '<input id="Valor3" type="hidden" value="' + kp + '" />',
  9491. )
  9492. }
  9493. }
  9494. function nativeMessage(_msg) {
  9495. panelSocial.nativeMessage(JSON.parse(_msg))
  9496. }
  9497. function promoNativeApp(_extra) {
  9498. if (_extra.isTouch && !executeNative && !_extra.huboURL) {
  9499. var yaVisto = ltotalUtils.fromLocalStorage("promoNativeApp")
  9500. if (!yaVisto) {
  9501. var boxModalAPP = document.createElement("div")
  9502. boxModalAPP.setAttribute("class", "boxModalAPP")
  9503. $(contentVIEWER.mainFrame).append(boxModalAPP)
  9504. var containApps = document.createElement("div")
  9505. containApps.setAttribute("class", "containApps")
  9506. var titleApps = document.createElement("div")
  9507. titleApps.setAttribute("class", "titleApps")
  9508. titleApps.innerHTML = "Para una mejor experiencia descarga nuestra app!"
  9509. $(containApps).append(titleApps)
  9510. var boxIOS = document.createElement("div")
  9511. boxIOS.setAttribute("class", "boxAppSO boxIOS")
  9512. $(containApps).append(boxIOS)
  9513. var htmlIOS =
  9514. "<a class='hrefIOS' href='https://itunes.apple.com/us/app/el-libro-total-biblioteca/id1298628446?mt=8'></a>"
  9515. $(boxIOS).append(htmlIOS)
  9516. var boxANDROID = document.createElement("div")
  9517. boxANDROID.setAttribute("class", "boxAppSO boxANDROID")
  9518. $(containApps).append(boxANDROID)
  9519. var htmlANDROID =
  9520. "<a class='hrefANDR' href='http://play.google.com/store/apps/details?id=com.syc.librototal.El_Libro_Total'></a>"
  9521. $(boxANDROID).append(htmlANDROID)
  9522. var modalAPP = new ModalViewerLT({
  9523. hostDiv: boxModalAPP,
  9524. widthV: "80%",
  9525. leftV: "10%",
  9526. heightV: "60%",
  9527. topV: "15%",
  9528. rightV: "0px",
  9529. addClassViewer: "modalAPP",
  9530. clickPreClose: function () {},
  9531. clickClose: function () {
  9532. $(".boxModalAPP").remove()
  9533. ltotalUtils.toLocalStorage("promoNativeApp", true)
  9534. },
  9535. })
  9536. modalAPP.addContent(containApps)
  9537. }
  9538. }
  9539. }
  9540. function restorePassword() {
  9541. if (executeNative) {
  9542. var iframeURL = deepLinkUrl + "&isIframe=1"
  9543. panelSocial.createIFRAME({
  9544. hostDiv: panelSocial.bodyDiv,
  9545. id: "iframePasswd",
  9546. url: iframeURL,
  9547. close: function () {
  9548. panelSocial.cancelFullscreen()
  9549. },
  9550. })
  9551. }
  9552. }
  9553. function getAScript(_path, _url, _c) {
  9554. var addr = _path + _url + "?v=" + _c
  9555. var xhr = new XMLHttpRequest()
  9556. xhr.open("GET", addr, false)
  9557. xhr.onload = function (_e) {
  9558. var s = _e.target.status
  9559. if (s >= 200 && s < 300) {
  9560. var se = document.createElement("SCRIPT")
  9561. se.id = _url
  9562. se.type = "text/javascript"
  9563. se.text = xhr.responseText
  9564. document.getElementsByTagName("head")[0].appendChild(se)
  9565. }
  9566. if (s >= 400 && s < 500) {
  9567. if (_c < 10) {
  9568. getAScript(_path, _url, _c + 1)
  9569. }
  9570. }
  9571. }
  9572. xhr.send(null)
  9573. }
  9574. //////////////////////////////////////////////////
  9575. // 外部js文件结束
  9576. // 重新创建 panelSocial 实例,打上补丁
  9577. delete window.panelSocial
  9578. initPanelSocial()
  9579. // 保存 选择高亮文本 至 selectedText
  9580. function handleSelection() {
  9581. const selectedText = window.getSelection().toString().trim()
  9582. if (selectedText) {
  9583. GM_setValue("sharedText", selectedText) // 存储到 GM_setValue
  9584. console.log("选定的文本已存储到 GM_setValue:", selectedText)
  9585. }
  9586. }
  9587. // 监听 selectionchange 事件
  9588. document.addEventListener("selectionchange", handleSelection)
  9589. // 监听 mouseup 事件
  9590. document.addEventListener("mouseup", handleSelection)
  9591. // 创建 MutationObserver 实例 (observer2)
  9592. const observer2 = new MutationObserver((mutations) => {
  9593. mutations.forEach((mutation) => {
  9594. if (mutation.addedNodes) {
  9595. mutation.addedNodes.forEach((node) => {
  9596. if (
  9597. node.nodeType === Node.ELEMENT_NODE &&
  9598. node.classList.contains("modalViewerLT")
  9599. ) {
  9600. console.log("modalViewerLT 元素已出现!")
  9601. // 在这里执行你想要的操作
  9602. // 找到 div 元素
  9603. const closeModalViewerDiv = document.querySelector(
  9604. "div.closeModalViewer",
  9605. )
  9606. // 定义点击事件处理函数
  9607. function handleClick() {
  9608. console.log("closeModalViewer 被点击了!")
  9609. // 在这里添加你想要执行的操作
  9610. closeModalViewerDiv.click()
  9611. }
  9612. // 找到 noteSignatureDiv 元素
  9613. const noteSignatureDiv =
  9614. document.querySelector("div.note_signature")
  9615. // 找到 divNoteSignature 元素
  9616. const contentHtmlDiv = document.querySelector("div.contentHtml")
  9617. // 如果找到 noteSignatureDiv ,则 contentHtmlDiv 添加点击事件监听器
  9618. if (noteSignatureDiv) {
  9619. contentHtmlDiv.addEventListener("click", handleClick)
  9620. console.log("点击事件监听器已添加。")
  9621. } else {
  9622. console.log("未找到 contentHtml div 元素。")
  9623. }
  9624. // 如果只需要执行一次,可以取消观察
  9625. // observer2.disconnect();
  9626. }
  9627. })
  9628. }
  9629. })
  9630. })
  9631. // 配置观察选项 (config2)
  9632. const config2 = { childList: true, subtree: true }
  9633. // 开始观察目标元素
  9634. observer2.observe(document.body, config2)
  9635. // 创建 MutationObserver 实例
  9636. const observer1 = new MutationObserver((mutations) => {
  9637. mutations.forEach((mutation) => {
  9638. if (mutation.addedNodes) {
  9639. mutation.addedNodes.forEach((node) => {
  9640. if (
  9641. node.nodeType === Node.ELEMENT_NODE &&
  9642. node.id === "div_nota_visor"
  9643. ) {
  9644. console.log("div_nota_visor 元素已找到!")
  9645. // 找到 input 元素
  9646. let inputElement = document.querySelector("input.nota_title")
  9647. // 如果找到,则设置其 value 属性为 "hello"
  9648. if (inputElement) {
  9649. const notaTitle = GM_getValue("sharedText", "") // 从 GM_getValue 获取
  9650. inputElement.value = notaTitle
  9651. }
  9652. function getLocalDateTimeISO() {
  9653. const now = new Date()
  9654. const year = now.getFullYear()
  9655. const month = String(now.getMonth() + 1).padStart(2, "0")
  9656. const day = String(now.getDate()).padStart(2, "0")
  9657. const hours = String(now.getHours()).padStart(2, "0")
  9658. const minutes = String(now.getMinutes()).padStart(2, "0")
  9659. const seconds = String(now.getSeconds()).padStart(2, "0")
  9660. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
  9661. }
  9662. const targetElement = document.querySelector(
  9663. "#div_nota_visor > div.div_section_top > div.editor_area.editor_area_notas > p",
  9664. )
  9665. if (targetElement) {
  9666. // 修改内部文本
  9667. targetElement.textContent = getLocalDateTimeISO()
  9668. console.log("元素文本已修改!")
  9669. } else {
  9670. console.log("未找到目标元素!")
  9671. }
  9672. const btnSalvar = document.querySelector(".btn_salvar")
  9673. if (btnSalvar) {
  9674. console.log("找到 btn_salvar 元素:", btnSalvar) // 在这里可以对找到的元素执行操作
  9675. btnSalvar.click()
  9676. } else {
  9677. console.log("未找到 btn_salvar 元素")
  9678. } // observer1.disconnect() // 停止观察
  9679. }
  9680. })
  9681. }
  9682. })
  9683. })
  9684. // 配置观察选项
  9685. const config1 = { childList: true, subtree: true }
  9686. // 开始观察目标元素
  9687. observer1.observe(document.body, config1)
  9688. console.log("开始监测 div_nota_visor 元素...")
  9689. //////
  9690. // 创建 MutationObserver 实例
  9691. const observer = new MutationObserver((mutations) => {
  9692. mutations.forEach((mutation) => {
  9693. if (mutation.addedNodes) {
  9694. mutation.addedNodes.forEach((node) => {
  9695. if (
  9696. node.nodeType === Node.ELEMENT_NODE &&
  9697. node.classList.contains("nota_no_publica")
  9698. ) {
  9699. console.log("titulo_2 元素已找到!") // 查找并点击 closeLight 元素
  9700. const closeLightButton = document.querySelector(
  9701. ".closeLight.pg_center_left.book_icon",
  9702. )
  9703. if (closeLightButton) {
  9704. closeLightButton.click()
  9705. console.log("closeLight 元素已点击!")
  9706. } else {
  9707. console.log("closeLight 元素未找到!")
  9708. } // observer.disconnect(); // 停止观察
  9709. }
  9710. })
  9711. }
  9712. })
  9713. }) // 配置观察选项
  9714. const config = { childList: true, subtree: true } // 开始观察目标元素
  9715. observer.observe(document.body, config)
  9716. console.log("开始监测 titulo_2 元素...")
  9717. })()

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址