From ab77b23a62f7a6cbd78be5178cf197f573df180c Mon Sep 17 00:00:00 2001 From: NexisSis Date: Fri, 17 Jul 2020 14:17:58 +0300 Subject: [PATCH] Added if for iframe issue in player --- player.js | 31 ++++++++++++++++++++------ src/player.ls | 62 ++++++++++++++++++++++++++++++--------------------- 2 files changed, 61 insertions(+), 32 deletions(-) diff --git a/player.js b/player.js index 0e161338..1d1357d8 100644 --- a/player.js +++ b/player.js @@ -1,4 +1,4 @@ -// Generated by LiveScript 1.6.0 +// Generated by LiveScript 1.5.0 (function(){ this.include = function(){ return this.client({ @@ -398,7 +398,7 @@ return setTimeout(onReady, 1); }); onLoad = function(ssInstance){ - var ss, ref$, ref1$, ref2$, ref3$; + var ss, ref$, ref1$, ref2$, ref3$, isFramed; ssInstance == null && (ssInstance = SocialCalc.CurrentSpreadsheetControlObject); window.spreadsheet = ss = ssInstance || (SocialCalc._view || SocialCalc._app ? new SocialCalc.SpreadsheetViewer() @@ -466,6 +466,7 @@ } else { SocialCalc.Callbacks.broadcast('ask.log'); } + isFramed = window !== window.top || document !== top.document || self.location !== top.location; if (typeof ss.ExecuteCommand == 'function') { ss.ExecuteCommand('redisplay', ''); } @@ -499,27 +500,43 @@ if (window.parent.location.href.match(/(^.*\/=[^?/]+)/)) { return window.open(RegExp.$1 + ".xlsx"); } else { - return window.open("." + (window.parent.location.pathname.match('/.*/view$') || window.parent.location.pathname.match('/.*/edit$') ? '.' : '') + "/=" + SocialCalc._room.replace(/\.[1-9]\d*$/, '') + ".xlsx"); + if (isFramed) { + return window.open(SocialCalc._room.replace(/\.[1-9]\d*$/, '') + ".xlsx"); + } else { + return window.open("." + (window.parent.location.pathname.match('/.*/view$') || window.parent.location.pathname.match('/.*/edit$') ? '.' : '') + "/=" + SocialCalc._room.replace(/\.[1-9]\d*$/, '') + ".xlsx"); + } } } else { - return window.open("." + (window.parent.location.pathname.match('/.*/view$') || window.parent.location.pathname.match('/.*/edit$') ? '.' : '') + "/" + SocialCalc._room + ".xlsx"); + if (isFramed) { + return window.open(SocialCalc._room + ".xlsx"); + } else { + return window.open("." + (window.parent.location.pathname.match('/.*/view$') || window.parent.location.pathname.match('/.*/edit$') ? '.' : '') + "/" + SocialCalc._room + ".xlsx"); + } } } }), $.extend({}, typeof vex != 'undefined' && vex !== null ? vex.dialog.buttons.YES : void 8, { text: 'CSV', click: function(){ - return window.open("." + (window.parent.location.pathname.match('/.*/view$') || window.parent.location.pathname.match('/.*/edit$') ? '.' : '') + "/" + SocialCalc._room + ".csv"); + if (isFramed) { + return window.open(SocialCalc._room + ".csv"); + } else { + return window.open("." + (window.parent.location.pathname.match('/.*/view$') || window.parent.location.pathname.match('/.*/edit$') ? '.' : '') + "/" + SocialCalc._room + ".csv"); + } } }), $.extend({}, typeof vex != 'undefined' && vex !== null ? vex.dialog.buttons.YES : void 8, { text: 'HTML', click: function(){ - return window.open("." + (window.parent.location.pathname.match('/.*/view$') || window.parent.location.pathname.match('/.*/edit$') ? '.' : '') + "/" + SocialCalc._room + ".html"); + if (isFramed) { + return window.open(SocialCalc._room + ".html"); + } else { + return window.open("." + (window.parent.location.pathname.match('/.*/view$') || window.parent.location.pathname.match('/.*/edit$') ? '.' : '') + "/" + SocialCalc._room + ".html"); + } } }), $.extend({}, typeof vex != 'undefined' && vex !== null ? vex.dialog.buttons.YES : void 8, { text: 'ODS', click: function(){ if (isMultiple) { - if (window.parent.location.href.match(/(^.*\/=[^?/]+)/)) { + if (isFramed || window.parent.location.href.match(/(^.*\/=[^?/]+)/)) { return window.open(RegExp.$1 + ".ods"); } else { return window.open("." + (window.parent.location.pathname.match('/.*/view$') || window.parent.location.pathname.match('/.*/edit$') ? '.' : '') + "/=" + SocialCalc._room.replace(/\.[1-9]\d*$/, '') + ".ods"); diff --git a/src/player.ls b/src/player.ls index b5b4a30f..4a128bf3 100644 --- a/src/player.ls +++ b/src/player.ls @@ -7,9 +7,9 @@ SocialCalc.isConnected = true requestParams = SocialCalc.requestParams SocialCalc._auth = requestParams[\auth] if requestParams[\auth]? - SocialCalc._app = true if requestParams[\app]? + SocialCalc._app = true if requestParams[\app]? SocialCalc._view = true if requestParams[\view]? - #SocialCalc._view = SocialCalc._auth is \0 + #SocialCalc._view = SocialCalc._auth is \0 SocialCalc._room ?= window.EtherCalc?_room || window.location.hash.replace \# '' SocialCalc._room = "#{SocialCalc._room}".replace /^_+/ '' .replace /\?.*/ '' @@ -74,7 +74,7 @@ SocialCalc.Callbacks.broadcast = (type, data={}) ~> return unless SocialCalc.isConnected data.user = SocialCalc._username - data.room = SocialCalc._room if !data.room? + data.room = SocialCalc._room if !data.room? data.type = type data.auth = SocialCalc._auth if SocialCalc._auth emit data @@ -94,14 +94,14 @@ return unless ss return if @data.room and @data.room != SocialCalc._room and ss.formDataViewer?._room != @data.room and @data.type == "log" if @data.room and @data.room != SocialCalc._room and @data.type != "recalc" and @data.type != "log" - return if ss.formDataViewer?._room != @data.room + return if ss.formDataViewer?._room != @data.room ss = ss.formDataViewer # process the form data sheet event editor = ss.editor switch @data.type | \confirmemailsent => SocialCalc.EditorSheetStatusCallback(null, "confirmemailsent", @data.message, editor); | \chat => window.addmsg? @data.msg - | \ecells - break if SocialCalc._app + | \ecells + break if SocialCalc._app do => for user, ecell of @data.ecells continue if user is SocialCalc._username peerClass = " #user defaultPeer" @@ -121,12 +121,12 @@ SocialCalc.Callbacks.broadcast \ecell, to: @data.user ecell: editor.ecell.coord - break if SocialCalc._app + break if SocialCalc._app cr = SocialCalc.coordToCr @data.ecell cell = SocialCalc.GetEditorCellElement editor, cr.row, cr.col cell.element.className += peerClass if cell?element?className.search(find) == -1 | \ask.ecell - break if SocialCalc._app + break if SocialCalc._app SocialCalc.Callbacks.broadcast \ecell do to: @data.user ecell: editor.ecell.coord @@ -240,12 +240,12 @@ Check the activity stream to see the newly edited page! else new SocialCalc.SpreadsheetControl! ) - + # eddy { if !window.GraphOnClick? - SocialCalc.Callbacks.broadcast \ask.log - return - # } eddy + SocialCalc.Callbacks.broadcast \ask.log + return + # } eddy ss.ExportCallback = (s) -> alert SocialCalc.ConvertSaveToOtherFormat(SocialCalc.Clipboard.clipboard, "csv") @@ -265,7 +265,7 @@ Check the activity stream to see the newly edited page! """ view: \sheet onclick: null - onclickFocus: true + onclickFocus: true # } ss.tabnums.graph = ss.tabs.length if ss.tabs @@ -292,20 +292,20 @@ Check the activity stream to see the newly edited page! # Spinner - shows when sheet data is loading ss.sheet.cells["A1"] = new SocialCalc.Cell("A1") ss.sheet.cells["A1"].displaystring = '
' - + ss.InitializeSpreadsheetViewer? \tableeditor, 0, 0, 0 ss.InitializeSpreadsheetControl? \tableeditor, 0, 0, 0 # eddy { if !SocialCalc._view? && ss.formDataViewer? # request formData and then the spreadsheet data - ss.formDataViewer.sheet._room = ss.formDataViewer._room = SocialCalc._room + "_formdata" + ss.formDataViewer.sheet._room = ss.formDataViewer._room = SocialCalc._room + "_formdata" SocialCalc.Callbacks.broadcast \ask.log {room: ss.formDataViewer._room} - else + else # request the spreadsheet data - SocialCalc.Callbacks.broadcast \ask.log - # } eddy - + SocialCalc.Callbacks.broadcast \ask.log + # } eddy + const isFramed = window != window.top || document != top.document || self.location != top.location ss.ExecuteCommand? \redisplay, '' ss.ExecuteCommand? 'set sheet defaulttextvalueformat text-wiki' $ document .on \mouseover '.te_download tr:nth-child(2) td:first' -> @@ -323,18 +323,30 @@ Check the activity stream to see the newly edited page! $.extend {}, vex?dialog.buttons.YES, text: 'Excel', click: -> if isMultiple if window.parent.location.href.match(/(^.*\/=[^?/]+)/) - window.open "#{ RegExp.$1 }.xlsx" + window.open "#{ RegExp.$1 }.xlsx" else - window.open ".#{if window.parent.location.pathname.match('\/.*\/view$') || window.parent.location.pathname.match('\/.*\/edit$') then '.' else ''}/=#{ SocialCalc._room.replace(/\.[1-9]\d*$/, '') }.xlsx" + if isFramed + window.open "#{ SocialCalc._room.replace(/\.[1-9]\d*$/, '') }.xlsx" + else + window.open ".#{if window.parent.location.pathname.match('\/.*\/view$') || window.parent.location.pathname.match('\/.*\/edit$') then '.' else ''}/=#{ SocialCalc._room.replace(/\.[1-9]\d*$/, '') }.xlsx" else - window.open ".#{if window.parent.location.pathname.match('\/.*\/view$') || window.parent.location.pathname.match('\/.*\/edit$') then '.' else ''}/#{ SocialCalc._room }.xlsx" + if isFramed + window.open "#{ SocialCalc._room }.xlsx" + else + window.open ".#{if window.parent.location.pathname.match('\/.*\/view$') || window.parent.location.pathname.match('\/.*\/edit$') then '.' else ''}/#{ SocialCalc._room }.xlsx" $.extend {}, vex?dialog.buttons.YES, text: 'CSV', click: -> - window.open ".#{if window.parent.location.pathname.match('\/.*\/view$') || window.parent.location.pathname.match('\/.*\/edit$') then '.' else ''}/#{ SocialCalc._room }.csv" + if isFramed + window.open "#{ SocialCalc._room }.csv" + else + window.open ".#{if window.parent.location.pathname.match('\/.*\/view$') || window.parent.location.pathname.match('\/.*\/edit$') then '.' else ''}/#{ SocialCalc._room }.csv" $.extend {}, vex?dialog.buttons.YES, text: 'HTML', click: -> - window.open ".#{if window.parent.location.pathname.match('\/.*\/view$') || window.parent.location.pathname.match('\/.*\/edit$') then '.' else ''}/#{ SocialCalc._room }.html" + if isFramed + window.open "#{ SocialCalc._room }.html" + else + window.open ".#{if window.parent.location.pathname.match('\/.*\/view$') || window.parent.location.pathname.match('\/.*\/edit$') then '.' else ''}/#{ SocialCalc._room }.html" $.extend {}, vex?dialog.buttons.YES, text: 'ODS', click: -> if isMultiple - if window.parent.location.href.match(/(^.*\/=[^?/]+)/) + if isFramed || window.parent.location.href.match(/(^.*\/=[^?/]+)/) window.open "#{ RegExp.$1 }.ods" else window.open ".#{if window.parent.location.pathname.match('\/.*\/view$') || window.parent.location.pathname.match('\/.*\/edit$') then '.' else ''}/=#{ SocialCalc._room.replace(/\.[1-9]\d*$/, '') }.ods"