Skip to content

Commit d26e329

Browse files
committed
add replaceall for all browser
1 parent c82ed87 commit d26e329

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/StringPrototype.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
if (String.prototype.replaceAll === undefined) {
2+
String.prototype.replaceAll = function (before, after) {
3+
let res = new String(), matched = 0;
4+
for (let i = 0; i < this.length; i += 1) {
5+
if (this[i] == before[matched]) {
6+
matched += 1;
7+
if (matched == before.length) {
8+
res += after;
9+
matched = 0;
10+
}
11+
} else {
12+
matched = 0;
13+
res += this[i];
14+
}
15+
}
16+
return res;
17+
};
18+
}

src/components/problem/content.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div id="problem-view">
33
<div id="content">
4-
<div id="problem-content">
4+
<div id="problem-content" v-loading="problemLoading">
55
<div v-if="!isWider" id="full-screen-button" @click="full_screen()">
66
Expand
77
<i class="el-icon-arrow-right"></i>
@@ -85,7 +85,8 @@ export default {
8585
enable: true,
8686
hidden: false,
8787
time: '-',
88-
memery: '-'
88+
memery: '-',
89+
problemLoading: true
8990
};
9091
},
9192
methods: {
@@ -94,14 +95,14 @@ export default {
9495
.get(apiurl('/problem/' + String(this.$route.params.id)))
9596
.then(res => {
9697
let data = res.data.res;
97-
console.log(data);
9898
this.title = data.title;
9999
this.pid = data.pid;
100100
this.allowHTML = data.allow_html;
101101
this.description = data.description;
102102
this.memery = data.memory_limit / 1000;
103103
this.time = data.time_limit;
104104
this.hidden = !data.enabled;
105+
this.problemLoading = false;
105106
})
106107
.catch(err => {
107108
if(err.request.status === 404) {

src/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import './assets/css/fontstyle.css';
3535
import './assets/css/basic.css';
3636
import('./loader/load');
3737

38+
import './StringPrototype';
39+
3840
Vue.config.productionTip = false;
3941

4042
new Vue({

0 commit comments

Comments
 (0)