Skip to content

Instantly share code, notes, and snippets.

@tekwiz
Last active December 10, 2015 21:18
Show Gist options
  • Save tekwiz/4494402 to your computer and use it in GitHub Desktop.
Save tekwiz/4494402 to your computer and use it in GitHub Desktop.
Fixer for iWeb problems

IWFixer

The iwfixer.js file contents should be appended at the very bottom of the iWebSite.js script in the iWeb application. This will then become minified with the iWebSite.js file when any iWeb site is published.

Compatibility

This is only known to work with iWeb 3.0; however, only the instructions should need to be modified for it to work with earlier versions. Note: iWeb has been discontinued by Apple, so there should not be any forward compatibility issues to consider.

iWebSite.js

The iWebSite.js file is found in the iWeb application package under

Contents/Resources/Scripts/Site/iWebSite.js

Objective: Fix iFrames

The IWFixer.fixIframes method loops over all the iframes with src targets starting with .//, and removes this.

Extension

Copyright

Copyright 2013 Travis Warlick, LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
###!
* IWFixer for iWeb 3.0 - https://gist.github.com/4494402
* Version: 1.0.0
* Copyright 2013 Travis Warlick, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
###
IWFixer =
load: ($) ->
$("body").append IWFixer.jqScriptWrap("IWFixer.run(jQuery);")
scriptLoad: (uri) ->
document.writeln "<script type=\"text/javascript\" src=\"#{encodeURI(uri)}\"></script>"
scriptRun: (js) ->
document.writeln IWFixer.scriptWrap(js)
scriptWrap: (js) ->
"<script type=\"text/javascript\">#{js}</script>"
jqScriptWrap: (js) ->
jQuery IWFixer.scriptWrap(js)
run: ($) ->
IWFixer.fixIframes $
fixIframes: ($) ->
$('iframe[src^=".//"]').each ->
$(this).attr "src", $(this).attr("src").replace(".//", "")
IWFixer.scriptLoad("http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js")
IWFixer.scriptRun("jQuery.noConflict();jQuery(document).ready(IWFixer.load);")
/*!
* IWFixer for iWeb 3.0 - https://gist.github.com/4494402
* Version: 1.0.0
* Copyright 2013 Travis Warlick, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var IWFixer = {
load: function($) {
$("body").append(IWFixer.jqScriptWrap("IWFixer.run(jQuery);"));
},
scriptLoad: function(uri) {
document.writeln("<script type=\"text/javascript\" src=\"" + (encodeURI(uri)) + "\"></script>");
},
scriptRun: function(js) {
document.writeln(IWFixer.scriptWrap(js));
},
scriptWrap: function(js) {
return "<script type=\"text/javascript\">" + js + "</script>";
},
jqScriptWrap: function(js) {
return jQuery(IWFixer.scriptWrap(js));
},
run: function($) {
IWFixer.fixIframes($);
},
fixIframes: function($) {
$('iframe[src^=".//"]').each(function() {
$(this).attr("src", $(this).attr("src").replace(".//", ""));
});
}
};
IWFixer.scriptLoad("http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js");
IWFixer.scriptRun("jQuery.noConflict();jQuery(document).ready(IWFixer.load);");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment