瀏覽代碼

add alert

schtonn 2 年之前
父節點
當前提交
a9d1c99b04
共有 3 個文件被更改,包括 37 次插入35 次删除
  1. 34 32
      js/paint.js
  2. 1 1
      js/score.js
  3. 2 2
      paint/index.html

+ 34 - 32
js/paint.js

@@ -15,13 +15,13 @@ $(window).on({
     },
 })
 
-var tryTime=0
+var tryTime = 0
 
-function tryClear(){
-    if(tryTime==0)alert('你干嘛')
-    else if(tryTime==1)alert('哎呦')
-    else if(tryTime==2)alert('不会让你清空的')
-    else if(tryTime==3){
+function tryClear() {
+    if (tryTime == 0) alert('你干嘛')
+    else if (tryTime == 1) alert('哎呦')
+    else if (tryTime == 2) alert('不会让你清空的')
+    else if (tryTime == 3) {
         alert('按钮都给你禁用咯')
         document.getElementById('clear').classList.add('disabled');
     }
@@ -123,7 +123,7 @@ $(document).ready(function () {
         isdown = 0;
     }
 
-    let showLine = true
+    let showGrid = false
 
     draw.draggable = false
     for (let i = 0; i < 64; i++) {      //创建像素点16*16
@@ -156,12 +156,12 @@ $(document).ready(function () {
     reset();
 
     lineButton.onclick = function () {
-        if (showLine) {
+        if (showGrid) {
             changeClass(box, 'pixel')
-            showLine = false
+            showGrid = false
         } else {
             changeClass(box, 'pixel-line')
-            showLine = true
+            showGrid = true
         }
     }
     resetButton.onclick = function () {
@@ -194,27 +194,29 @@ $(document).ready(function () {
     }
 
     upload.onclick = function () {
-        const query = new AV.Query('paint');
-
-        console.log(id)
-        query.equalTo('id', id)
-        query.find().then((result) => {
-            var map = []
-            for (let i = 0; i < box.length; i++) {
-                map[i] = box[i].style.backgroundColor
-            }
-            if (result.length) {
-                result[0].set('data', map)
-                result[0].save()
-                console.log('Updated')
-            }
-            else {
-                const up = new AV.Object('paint');
-                up.set('data', map)
-                up.set('id', id)
-                up.save()
-                console.log('Created new instance')
-            }
-        })
+        if (confirm('请确认,上传后对所有人可见。')) {
+            const query = new AV.Query('paint');
+
+            console.log(id)
+            query.equalTo('id', id)
+            query.find().then((result) => {
+                var map = []
+                for (let i = 0; i < box.length; i++) {
+                    map[i] = box[i].style.backgroundColor
+                }
+                if (result.length) {
+                    result[0].set('data', map)
+                    result[0].save()
+                    console.log('Updated')
+                }
+                else {
+                    const up = new AV.Object('paint');
+                    up.set('data', map)
+                    up.set('id', id)
+                    up.save()
+                    console.log('Created new instance')
+                }
+            })
+        }
     }
 })

+ 1 - 1
js/score.js

@@ -8,7 +8,7 @@ AV.init({
     serverURL: "https://bmologyy.lc-cn-n1-shared.com/",
 });
 
-console.log("温馨提示:*成绩*一定不会上传到网络,但为了保证使用范围,避免过度使用,可能会对其他信息进行记录。")
+console.log("温馨提示:*成绩*一定不会上传到网络,但为了保证使用范围,可能会对其他信息进行记录。")
 
 function decimal(x, n) {
     x = Math.round(x * 10 ** n) / 10 ** n;

+ 2 - 2
paint/index.html

@@ -124,7 +124,7 @@
 
 <body>
     <a class="btn btn-info" href="/" style="text-shadow: rgb(85, 85, 85) 3px 2px 4px;"><span
-        class="glyphicon glyphicon-home" aria-hidden="true"></span>&nbsp;返回</a>
+            class="glyphicon glyphicon-home" aria-hidden="true"></span>&nbsp;返回</a>
     <div id="main">
         <div id="draw"></div>
         <div id="tools">
@@ -149,7 +149,7 @@
     </div>
     <div style="text-align: center;margin-top:10px">
         <button class="btn btn-warning" id="show-hide-line">
-            <span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>&nbsp;展示/隐藏网格</button>
+            <span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>&nbsp;网格</button>
         <button class="btn btn-info" id="upload"><span class="glyphicon glyphicon-cloud-upload"
                 aria-hidden="true"></span>&nbsp;上传</button>
         <button class="btn btn-danger" id="reset"><span class="glyphicon glyphicon-cloud-download"