-
Notifications
You must be signed in to change notification settings - Fork 73
Port Ajaxifier to modern JavaScript #1337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
84 changes: 0 additions & 84 deletions
84
repository/JQuery-Core.package/JQAjaxifierLibrary.class/instance/ajaxifierJs.st
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"separateMethodMetaAndSource" : false, | ||
"noMethodMetaData" : true, | ||
"useCypressPropertiesFile" : true | ||
} |
1 change: 1 addition & 0 deletions
1
repository/Seaside-Ajaxifier-Core.package/WAAjaxifierLibrary.class/README.md
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
I ajaxify a web application by turning full page requests into background AJAX requests. |
80 changes: 80 additions & 0 deletions
80
repository/Seaside-Ajaxifier-Core.package/WAAjaxifierLibrary.class/instance/ajaxifierJs.st
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
uploads | ||
ajaxifierJs | ||
^ '/* JavaScript based Ajaxifier | ||
* Copyright (c) 2008 Lukas Renggli, [email protected] | ||
* Copyright (c) 2022 Philippe Marschall, [email protected] | ||
*/ | ||
"use strict"; | ||
window.addEventListener("DOMContentLoaded", (loadEvent) => { | ||
|
||
// variables | ||
let activeHash = ""; | ||
|
||
// ajax action | ||
function load(type, url, data, modifyHistory) { | ||
const xhr = new XMLHttpRequest(); | ||
|
||
xhr.responseType = "document" | ||
xhr.addEventListener("load", (event) => { | ||
if (xhr.status === 200) { | ||
Array.from(xhr.response.head.children).forEach((child) => { | ||
if (child.nodeType === Node.ELEMENT_NODE && child.nodeName === "SCRIPT") { | ||
child.remove(); | ||
} | ||
}); | ||
document.head.innerHTML = xhr.response.head.innerHTML; | ||
document.body = xhr.response.body; | ||
|
||
if (modifyHistory) { | ||
const path = xhr.responseURL; | ||
window.history.pushState(path, null, path); | ||
} | ||
} | ||
}); | ||
|
||
xhr.open(type, url); | ||
|
||
// WAActionCallback per default are disabled for AJAX requests | ||
// Detection happens with X-Requested-With so we override it | ||
xhr.setRequestHeader("X-Requested-With", "Ajaxifier"); | ||
xhr.send(data); | ||
} | ||
|
||
// click handler | ||
document.addEventListener("click", (event) => { | ||
|
||
// links | ||
const anchor = event.target.closest("a"); | ||
if (anchor !== null) { | ||
load("GET", anchor.getAttribute("href"), null, true); | ||
event.preventDefault(); | ||
return; | ||
} | ||
|
||
// submit | ||
const submit = event.target.closest("input[type=submit], button[type=submit]"); | ||
if (submit !== null) { | ||
const form = submit.closest("form"); | ||
if (form !== null) { | ||
const formData = new FormData(form); | ||
formData.append(submit.getAttribute("name"), ""); | ||
load("POST", form.getAttribute("action"), formData, true); | ||
event.preventDefault(); | ||
} | ||
} | ||
|
||
}); | ||
|
||
// check for changes in the hash | ||
setInterval(() => { | ||
const currentHash = window.location.hash.substr(1); | ||
if (currentHash !== activeHash) | ||
load("GET", "?" + (activeHash = currentHash), null, true); | ||
}, 250); | ||
|
||
// We assume nobody else will override onpopstate... since we are LIKELY the only ones to use pushstate etc. | ||
window.onpopstate = (event) => { | ||
load("GET", event.state, null, false); | ||
} | ||
|
||
});' |
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
.../JQAjaxifierLibrary.class/properties.json → .../WAAjaxifierLibrary.class/properties.json
This file contains hidden or 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,11 +1,11 @@ | ||
{ | ||
"commentStamp" : "", | ||
"commentStamp" : "pmm 8/25/2022 15:03", | ||
"super" : "WAFileLibrary", | ||
"category" : "JQuery-Core-Libraries", | ||
"category" : "Seaside-Ajaxifier-Core", | ||
"classinstvars" : [ ], | ||
"pools" : [ ], | ||
"classvars" : [ ], | ||
"instvars" : [ ], | ||
"name" : "JQAjaxifierLibrary", | ||
"name" : "WAAjaxifierLibrary", | ||
"type" : "normal" | ||
} |
1 change: 1 addition & 0 deletions
1
repository/Seaside-Ajaxifier-Core.package/monticello.meta/categories.st
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
SystemOrganization addCategory: #'Seaside-Ajaxifier-Core'! |
File renamed without changes.
1 change: 1 addition & 0 deletions
1
repository/Seaside-Ajaxifier-Core.package/monticello.meta/package
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
(name 'Seaside-Ajaxifier-Core') |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{ } |
7 changes: 0 additions & 7 deletions
7
...ide-RenderLoop.package/WARenderPhaseContinuation.class/instance/addRedirectedToHeader..st
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...ry/Seaside-RenderLoop.package/WARenderPhaseContinuation.class/instance/handleFiltered..st
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.