Skip to content

Commit

Permalink
Use a small JavaScript file to verify CDN liveness
Browse files Browse the repository at this point in the history
Move the code that hides the message about CDN blocking from Ode
itself to a small little JavaScript file. So people on slow links will
not see the warning message for the time it takes to load all of Ode,
which might be a while.

Change-Id: I9c10ab43bb7c2c69e149b25714131a35735dfcd1
  • Loading branch information
jisqyv committed Mar 14, 2024
1 parent 2e52fc4 commit fda9f51
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 2 additions & 0 deletions appinventor/appengine/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,8 @@
<arg value="${build.extra.dir}"/>
<arg line="${client.flags} ${client.module}"/>
</java>
<copy todir="${build.war.dir}/ode"
file="${appinventor.dir}/appengine/extra/cdnok.js" />
</target>

<target name="devmode"
Expand Down
5 changes: 5 additions & 0 deletions appinventor/appengine/extra/cdnok.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function cdnok() {
let odeblock = document.getElementById("odeblock");
odeblock.style.display = 'none';
}
cdnok();
10 changes: 0 additions & 10 deletions appinventor/appengine/src/com/google/appinventor/client/Ode.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@
import com.google.gwt.core.client.Callback;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.MouseWheelEvent;
import com.google.gwt.event.dom.client.MouseWheelHandler;
Expand Down Expand Up @@ -648,13 +645,6 @@ public void onUncaughtException(Throwable e) {
}
});

// First order of business. Let's hide the div with the message about
// how access to Ode is blocked. If we get here, Ode is loaded, so there
// is no block! (yeah!)

Element element = Document.get().getElementById("odeblock");
element.getStyle().setDisplay(Style.Display.NONE);

// Initialize global Ode instance
instance = this;

Expand Down
1 change: 1 addition & 0 deletions appinventor/appengine/war/WEB-INF/appengine-web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<!-- These are not cached on purpose -->
<include path="/ode/**.nocache.*" expiration="0s" />
<include path="/ode/cdnok.js" expiration="3600s" />
<include path="/index.html" expiration="0s" />

<include path="/ode/**.cache.*" expiration="365d" />
Expand Down
1 change: 1 addition & 0 deletions appinventor/appengine/war/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
</h1>
</div>
<script type="text/javascript" src="static/closure-library/closure/goog/base.js"></script>
<script type="text/javascript" src="<%= odeBase %>ode/cdnok.js"></script>
<script type="text/javascript" src="<%= odeBase %>ode/ode.nocache.js"></script>
<script src="static/leaflet/leaflet.js"></script>
<script src="static/leaflet/leaflet.toolbar.js"></script>
Expand Down

0 comments on commit fda9f51

Please sign in to comment.