Stupid simple indication of text copied to the clipboard
This commit is contained in:
		
							
								
								
									
										17
									
								
								js/app.js
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								js/app.js
									
									
									
									
									
								
							@@ -12,7 +12,8 @@ let app = new Vue({
 | 
			
		||||
    ],
 | 
			
		||||
    inputBox: "ccc\n#4f46e5\n#db2777aa\n",
 | 
			
		||||
 | 
			
		||||
    copyInput: "",
 | 
			
		||||
    showStatusMessage: false,
 | 
			
		||||
    showErrorMessage: false,
 | 
			
		||||
 | 
			
		||||
    hexRegex: /^\#?[a-f0-9]{3,9}/i,
 | 
			
		||||
    rgbRegex: /^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)/i,
 | 
			
		||||
@@ -375,8 +376,20 @@ console.error('hexa to HSLa not implemented yet');
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    updateClipboard: function (text) {
 | 
			
		||||
      let _this = this;
 | 
			
		||||
      clipboard.writeText(text).then(() => {
 | 
			
		||||
        console.log('text copied!');
 | 
			
		||||
        _this.showErrorMessage = false;
 | 
			
		||||
        _this.showStatusMessage = true;
 | 
			
		||||
        setTimeout(() => {
 | 
			
		||||
          _this.showStatusMessage = false;
 | 
			
		||||
        }, 1000);
 | 
			
		||||
      })
 | 
			
		||||
      .catch(() => {
 | 
			
		||||
        _this.showStatusMessage = false;
 | 
			
		||||
        _this.showErrorMessage = true;
 | 
			
		||||
        setTimeout(() => {
 | 
			
		||||
          _this.showErrorMessage = false;
 | 
			
		||||
        }, 1000);
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user