Skip to content

Commit fd6b49d

Browse files
committed
fix link within wiki
1 parent a2cbc46 commit fd6b49d

12 files changed

+95
-35
lines changed

AlgorithmVisualizer.wiki

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 7e8e4201daff1aef2c19778441666496ccb0466b
1+
Subproject commit 9ec90c2dff4974717446a58082d3d567b555f5a2

css/stylesheet.css

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ section {
242242
margin: 2px;
243243
}
244244

245-
#tab_desc > .wrapper a {
245+
#tab_desc > .wrapper a,
246+
#tab_doc > .wrapper a {
246247
text-decoration: underline;
247248
}
248249

@@ -494,7 +495,7 @@ input[type=number]::-webkit-outer-spin-button {
494495

495496
.applications li,
496497
.complexity {
497-
margin: 10px 0px;
498+
margin: 10px 0px;
498499
}
499500

500501
.complexity-type {
@@ -518,20 +519,20 @@ input[type=number]::-webkit-outer-spin-button {
518519
}
519520

520521
button[disabled] {
521-
cursor: not-allowed;
522-
opacity: 0.6;
522+
cursor: not-allowed;
523+
opacity: 0.6;
523524
}
524525

525526
#btn_pause {
526-
width: 86px;
527+
width: 86px;
527528
}
528529

529530
.top-menu-buttons button.active {
530-
background: rgba(0, 0, 0, .15);
531-
box-shadow: 0px 0px 10px 3px #1a1a1a inset;
531+
background: rgba(0, 0, 0, .15);
532+
box-shadow: 0px 0px 10px 3px #1a1a1a inset;
532533
}
533534

534535
.top-menu-buttons button:active {
535-
background: rgba(0, 0, 0, .15);
536-
box-shadow: 0px 0px 10px 3px #1a1a1a inset;
536+
background: rgba(0, 0, 0, .15);
537+
box-shadow: 0px 0px 10px 3px #1a1a1a inset;
537538
}

js/app/constructor.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const state = {
1616
editor: null,
1717
tracerManager: null,
1818
categories: null,
19-
loadedScratch: null
19+
loadedScratch: null,
20+
wikiList: null
2021
};
2122

2223
const initState = (tracerManager) => {
@@ -25,6 +26,7 @@ const initState = (tracerManager) => {
2526
state.tracerManager = tracerManager;
2627
state.categories = {};
2728
state.loadedScratch = null;
29+
state.wikiList = [];
2830
};
2931

3032
/**
@@ -77,6 +79,18 @@ const App = function () {
7779
state.loadedScratch = loadedScratch;
7880
};
7981

82+
this.getWikiList = () => {
83+
return state.wikiList;
84+
};
85+
86+
this.setWikiList = (wikiList) => {
87+
state.wikiList = wikiList;
88+
};
89+
90+
this.hasWiki = (wiki) => {
91+
return ~state.wikiList.indexOf(wiki);
92+
};
93+
8094
const tracerManager = TracerManager.init();
8195

8296
initState(tracerManager);

js/dom/setup/setup_document.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ const app = require('../../app');
44

55
module.exports = () => {
66
$(document).on('click', 'a', function (e) {
7-
e.preventDefault();
8-
if (!window.open($(this).attr('href'), '_blank')) {
9-
alert('Please allow popups for this site');
7+
const href = $(this).attr('href');
8+
if (/^(https?:\/\/).+/.test(href)) {
9+
e.preventDefault();
10+
if (!window.open(href, '_blank')) {
11+
alert('Please allow popups for this site');
12+
}
1013
}
1114
});
1215

js/dom/show_wiki.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
'use strict';
22

3+
const app = require('../app');
34
const Server = require('../server');
45
const converter = new showdown.Converter({tables: true});
56

67
module.exports = (wiki) => {
78
Server.loadWiki(wiki).then((data) => {
89
console.log(data);
910
$('#tab_doc > .wrapper').html(converter.makeHtml(data));
11+
$('#tab_doc > .wrapper a').click(function (e) {
12+
const href = $(this).attr('href');
13+
14+
console.log(href);
15+
if (app.hasWiki(href)) {
16+
e.preventDefault();
17+
module.exports(href);
18+
}
19+
});
1020
});
1121
};

js/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ $(() => {
6868
});
6969

7070
Server.loadWikiList().then((data) => {
71+
app.setWikiList(data.wikis);
72+
7173
DOM.showWiki('Home');
7274
})
7375
});

public/algorithm_visualizer.css

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ section {
359359
margin: 2px;
360360
}
361361

362-
#tab_desc > .wrapper a {
362+
#tab_desc > .wrapper a,
363+
#tab_doc > .wrapper a {
363364
text-decoration: underline;
364365
}
365366

@@ -623,7 +624,7 @@ input[type=number]::-webkit-outer-spin-button {
623624

624625
.applications li,
625626
.complexity {
626-
margin: 10px 0px;
627+
margin: 10px 0px;
627628
}
628629

629630
.complexity-type {
@@ -647,20 +648,20 @@ input[type=number]::-webkit-outer-spin-button {
647648
}
648649

649650
button[disabled] {
650-
cursor: not-allowed;
651-
opacity: 0.6;
651+
cursor: not-allowed;
652+
opacity: 0.6;
652653
}
653654

654655
#btn_pause {
655-
width: 86px;
656+
width: 86px;
656657
}
657658

658659
.top-menu-buttons button.active {
659-
background: rgba(0, 0, 0, .15);
660-
box-shadow: 0px 0px 10px 3px #1a1a1a inset;
660+
background: rgba(0, 0, 0, .15);
661+
box-shadow: 0px 0px 10px 3px #1a1a1a inset;
661662
}
662663

663664
.top-menu-buttons button:active {
664-
background: rgba(0, 0, 0, .15);
665-
box-shadow: 0px 0px 10px 3px #1a1a1a inset;
665+
background: rgba(0, 0, 0, .15);
666+
box-shadow: 0px 0px 10px 3px #1a1a1a inset;
666667
}

public/algorithm_visualizer.js

Lines changed: 35 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/algorithm_visualizer.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/algorithm_visualizer.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)