Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@babel/preset-typescript": "^7.28.5",
"@babel/runtime": "^7.28.4",
"@babel/runtime-corejs3": "^7.28.4",
"@biomejs/biome": "2.1.4",
"@biomejs/biome": "^2.1.4",
"@rspack/cli": "^1.7.0",
"@rspack/core": "^1.7.0",
"@types/ace": "^0.0.52",
Expand Down
3 changes: 2 additions & 1 deletion src/components/settingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import select from "dialogs/select";
import Ref from "html-tag-js/ref";
import actionStack from "lib/actionStack";
import appSettings from "lib/settings";
import { hideAd } from "lib/startAd";
import FileBrowser from "pages/fileBrowser";
import { isValidColor } from "utils/color/regex";
import helpers from "utils/helpers";
Expand Down Expand Up @@ -99,7 +100,7 @@ export default function settingsPage(
/** DISCLAIMER: do not assign hideSearchBar directly because it can change */
$page.ondisconnect = () => hideSearchBar();
$page.onhide = () => {
helpers.hideAd();
hideAd();
actionStack.remove(title);
};

Expand Down
3 changes: 2 additions & 1 deletion src/lib/removeAds.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import purchaseListener from "handlers/purchase";
import helpers from "utils/helpers";
import { hideAd } from "./startAd.js";

/**
* Remove ads after purchase
Expand All @@ -25,7 +26,7 @@ export default function removeAds() {

function onpurchase() {
resolve(null);
helpers.hideAd(true);
hideAd(true);
localStorage.setItem("acode_pro", "true");
window.IS_FREE_VERSION = false;
toast(strings["thank you :)"]);
Expand Down
17 changes: 17 additions & 0 deletions src/lib/startAd.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,20 @@ export default async function startAd() {
window.iad = interstitial;
window.adRewardedUnitId = adUnitIdRewarded;
}

/**
* Hides the ad
* @param {Boolean} [force=false]
*/
export function hideAd(force = false) {
const { ad } = window;
if (ad?.active) {
const $pages = tag.getAll(".page-replacement");
const hide = $pages.length === 1;

if (force || hide) {
ad.active = false;
ad.hide();
}
}
}
3 changes: 2 additions & 1 deletion src/pages/about/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Reactive from "html-tag-js/reactive";
import actionStack from "lib/actionStack";
import constants from "lib/constants";
import helpers from "utils/helpers";
import { hideAd } from "./startAd.js";

export default function AboutInclude() {
const $page = Page(strings.about.capitalize());
Expand Down Expand Up @@ -115,7 +116,7 @@ export default function AboutInclude() {

$page.onhide = function () {
actionStack.remove("about");
helpers.hideAd();
hideAd();
};

app.append($page);
Expand Down
3 changes: 2 additions & 1 deletion src/pages/adRewards/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import actionStack from "lib/actionStack";
import adRewards from "lib/adRewards";
import removeAds from "lib/removeAds";
import helpers from "utils/helpers";
import { hideAd } from "./startAd.js";

let $rewardPage = null;

Expand Down Expand Up @@ -179,7 +180,7 @@ export default function openAdRewardsPage() {
action: $page.hide,
});

helpers.hideAd(true);
hideAd(true);
render();
app.append($page);
$rewardPage = $page;
Expand Down
3 changes: 2 additions & 1 deletion src/pages/changelog/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import markdownIt from "markdown-it";
import markdownItFootnote from "markdown-it-footnote";
import markdownItTaskLists from "markdown-it-task-lists";
import helpers from "utils/helpers";
import { hideAd } from "./startAd.js";

export default async function Changelog() {
const GITHUB_API_URL =
Expand Down Expand Up @@ -73,7 +74,7 @@ export default async function Changelog() {

$page.onhide = function () {
actionStack.remove("changelog");
helpers.hideAd();
hideAd();
};

actionStack.push({
Expand Down
3 changes: 2 additions & 1 deletion src/pages/customTheme/customTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ThemeBuilder from "theme/builder";
import themes from "theme/list";
import { isValidColor } from "utils/color/regex";
import helpers from "utils/helpers";
import { hideAd } from "./startAd.js";

export default function CustomThemeInclude() {
const theme = themes.get("custom");
Expand All @@ -34,7 +35,7 @@ export default function CustomThemeInclude() {

$page.onhide = () => {
actionStack.remove("custom-theme");
helpers.hideAd();
hideAd();
};

$page.addEventListener("click", handleClick);
Expand Down
3 changes: 2 additions & 1 deletion src/pages/fileBrowser/fileBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import _addMenu from "./add-menu.hbs";
import _addMenuHome from "./add-menu-home.hbs";
import _template from "./fileBrowser.hbs";
import _list from "./list.hbs";
import { hideAd } from "./startAd.js";
import util from "./util";

/**
Expand Down Expand Up @@ -511,7 +512,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {

$page.onhide = function () {
hideSearchBar();
helpers.hideAd();
hideAd();
actionStack.clearFromMark();
actionStack.remove("filebrowser");
$content.removeEventListener("click", handleClick);
Expand Down
3 changes: 2 additions & 1 deletion src/pages/fontManager/fontManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import appSettings from "lib/settings";
import FileBrowser from "pages/fileBrowser";
import helpers from "utils/helpers";
import Url from "utils/Url";
import { hideAd } from "./startAd.js";

export default function fontManager() {
const defaultFont = "Roboto Mono";
Expand All @@ -32,7 +33,7 @@ export default function fontManager() {
});

$page.onhide = () => {
helpers.hideAd();
hideAd();
actionStack.remove("fontManager");
};

Expand Down
3 changes: 2 additions & 1 deletion src/pages/plugin/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { highlightCodeBlock, initHighlighting } from "utils/codeHighlight";
import helpers from "utils/helpers";
import Url from "utils/Url";
import view from "./plugin.view.js";
import { hideAd } from "./startAd.js";

let $lastPluginPage;

Expand Down Expand Up @@ -61,7 +62,7 @@ export default async function PluginInclude(
});

$page.onhide = function () {
helpers.hideAd();
hideAd();
actionStack.remove("plugin");
loader.removeTitleLoader();
cancelled = true;
Expand Down
3 changes: 2 additions & 1 deletion src/pages/plugins/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import actionStack from "lib/actionStack";
import Contextmenu from "components/contextmenu";
import settings from "lib/settings";
import loadPlugin from "lib/loadPlugin";
import { hideAd } from "./startAd.js";

/**
*
Expand Down Expand Up @@ -206,7 +207,7 @@ export default function PluginsInclude(updates) {
});

$page.onhide = function () {
helpers.hideAd();
hideAd();
actionStack.remove("plugins");
};

Expand Down
3 changes: 2 additions & 1 deletion src/pages/problems/problems.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Page from "components/page";
import actionStack from "lib/actionStack";
import EditorFile from "lib/editorFile";
import helpers from "utils/helpers";
import { hideAd } from "./startAd.js";

export default function Problems() {
const $page = Page(strings["problems"]);
Expand Down Expand Up @@ -53,7 +54,7 @@ export default function Problems() {
helpers.showAd();

$page.onhide = function () {
helpers.hideAd();
hideAd();
actionStack.remove("problems");
};

Expand Down
3 changes: 2 additions & 1 deletion src/pages/quickTools/quickTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import items, { description } from "components/quickTools/items";
import actionStack from "lib/actionStack";
import settings from "lib/settings";
import helpers from "utils/helpers";
import { hideAd } from "./startAd.js";

export default function QuickTools() {
const $page = Page(strings["shortcut buttons"]);
Expand All @@ -30,7 +31,7 @@ export default function QuickTools() {

$page.onhide = () => {
actionStack.remove("quicktools-settings");
helpers.hideAd();
hideAd();
// Cleanup manager
manager.destroy();
};
Expand Down
3 changes: 2 additions & 1 deletion src/pages/themeSetting/themeSetting.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import CustomTheme from "pages/customTheme";
import ThemeBuilder from "theme/builder";
import themes from "theme/list";
import helpers from "utils/helpers";
import { hideAd } from "./startAd.js";

export default function () {
const $page = Page(strings.theme.capitalize());
Expand Down Expand Up @@ -67,7 +68,7 @@ export default function () {
});

$page.onhide = () => {
helpers.hideAd();
hideAd();
actionStack.remove("appTheme");
};

Expand Down
16 changes: 0 additions & 16 deletions src/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,22 +312,6 @@ export default {
}
}
},
/**
* Hides the ad
* @param {Boolean} [force=false]
*/
hideAd(force = false) {
const { ad } = window;
if (ad?.active) {
const $pages = tag.getAll(".page-replacement");
const hide = $pages.length === 1;

if (force || hide) {
ad.active = false;
ad.hide();
}
}
},
async toInternalUri(uri) {
return new Promise((resolve, reject) => {
window.resolveLocalFileSystemURL(
Expand Down