-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor opening nomad links using iFrame
(reference #53)
- Loading branch information
1 parent
89799d8
commit 8d6fd2c
Showing
4 changed files
with
49 additions
and
61 deletions.
There are no files selected for viewing
32 changes: 5 additions & 27 deletions
32
...Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/controller/CommandLaunchNomadLink.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,20 @@ | ||
package controller | ||
{ | ||
import model.proxy.login.ProxyLogin; | ||
import mediator.MediatorMainContentView; | ||
|
||
import org.apache.royale.html.elements.Iframe; | ||
import org.puremvc.as3.multicore.interfaces.INotification; | ||
import org.puremvc.as3.multicore.patterns.command.SimpleCommand; | ||
import org.apache.royale.utils.js.loadJavascript; | ||
import org.apache.royale.net.HTTPService; | ||
import org.apache.royale.net.beads.CORSCredentialsBead; | ||
import org.apache.royale.net.events.FaultEvent; | ||
import org.apache.royale.net.HTTPHeader; | ||
import mediator.MediatorMainContentView; | ||
import org.apache.royale.jewel.Group; | ||
import org.apache.royale.core.IChild; | ||
|
||
public class CommandLaunchNomadLink extends SimpleCommand | ||
{ | ||
override public function execute(note:INotification):void | ||
{ | ||
var mainMediator:MediatorMainContentView = facade.retrieveMediator(MediatorMainContentView.NAME) as MediatorMainContentView; | ||
|
||
var nomadHelper:Group = mainMediator.view.viewNomadHelper as Group; | ||
|
||
if (nomadHelper.numElements > 0) | ||
{ | ||
for (var i:int = nomadHelper.numElements - 1; i >= 0; i--) | ||
{ | ||
var element:IChild = nomadHelper.getElementAt(i); | ||
nomadHelper.removeElement(element); | ||
} | ||
} | ||
|
||
var nomadHelperContent:Group = new Group(); | ||
nomadHelper.addElement(nomadHelperContent); | ||
|
||
var nomadHelper:Iframe = mainMediator.view.viewNomadHelper as Iframe; | ||
var link:String = String(note.getBody()); | ||
window["$"](nomadHelperContent.element).load("https://nomadweb.venus.startcloud.com/nomad/nomadhelper.html?link='"+link+"'", function(responseText:String, textStatus:String, jqXHR:Object):void { | ||
var status:String = textStatus; | ||
}); | ||
var encodedLink:String = encodeURIComponent(link); | ||
nomadHelper.src = "https://nomadweb.venus.startcloud.com/nomad/nomadhelper.html?link=" + encodedLink; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,52 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Test Links Scoped to Nomad</title> | ||
<script type="text/javascript"> | ||
const HASH_PREFIX = '#/'; | ||
<!-- <meta http-equiv="Content-Security-Policy" content="frame-ancestors 'self' domino.venus.startcloud.com;">--> | ||
</head> | ||
<body> | ||
<script type="text/javascript"> | ||
window.onload = () => { | ||
var link = GetURLParameter("link"); | ||
if (link) | ||
{ | ||
const hrefUrl = new URL(link); | ||
if (navigator?.serviceWorker?.controller) { | ||
navigator.serviceWorker.controller.postMessage({ | ||
type: 'openNotesUri', | ||
payload: { | ||
notesUri: decodeURIComponent( | ||
hrefUrl.hash.substring( | ||
hrefUrl.hash.indexOf(HASH_PREFIX) + HASH_PREFIX.length | ||
), | ||
), | ||
}, | ||
}); | ||
} else { | ||
console.error('no service worker registered'); | ||
} | ||
} | ||
var link = GetURLParameter("link"); | ||
|
||
link = decodeURIComponent(link); | ||
openLink(link); | ||
}; | ||
|
||
function openLink(link) | ||
{ | ||
const HASH_PREFIX = '#/'; | ||
const hrefUrl = new URL(link); | ||
if (navigator?.serviceWorker?.controller) { | ||
navigator.serviceWorker.controller.postMessage({ | ||
type: 'openNotesUri', | ||
payload: { | ||
notesUri: decodeURIComponent( | ||
hrefUrl.hash.substring( | ||
hrefUrl.hash.indexOf(HASH_PREFIX) + HASH_PREFIX.length | ||
), | ||
), | ||
}, | ||
}); | ||
} else { | ||
console.error('no service worker registered'); | ||
} | ||
} | ||
|
||
function GetURLParameter(sParam) | ||
{ | ||
var sPageURL = window.location.search.substring(1); | ||
var sURLVariables = sPageURL.split('&'); | ||
for (var i = 0; i < sURLVariables.length; i++) | ||
var sPageURL = window.location.search.substring(1); | ||
var sURLVariables = sPageURL.split('&'); | ||
for (var i = 0; i < sURLVariables.length; i++) | ||
{ | ||
var urlParam = sURLVariables[i]; | ||
|
||
var sParameterName = sURLVariables[i].split('='); | ||
if (sParameterName[0] == sParam) | ||
{ | ||
var sParameterName = sURLVariables[i].split('='); | ||
if (sParameterName[0] == sParam) | ||
{ | ||
return sParameterName[1]; | ||
} | ||
return sParameterName[1]; | ||
} | ||
} | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
</script> | ||
</body> | ||
</html> |