This repository has been archived by the owner on Dec 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
node_modules | ||
dist | ||
bower_components | ||
**/.DS_Store | ||
.idea/* | ||
.DS_Store | ||
*.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"node": true, | ||
"browser": true, | ||
"esnext": true, | ||
"bitwise": true, | ||
"camelcase": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"immed": true, | ||
"indent": 2, | ||
"latedef": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"quotmark": "single", | ||
"undef": true, | ||
"unused": true, | ||
"strict": true, | ||
"trailing": true, | ||
"smarttabs": true, | ||
"globals": { | ||
"angular": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
module.exports = function (grunt) { | ||
'use strict'; | ||
require('load-grunt-tasks')(grunt); | ||
grunt.initConfig({ | ||
csslint: { | ||
src: ['css/**/*.css'] | ||
}, | ||
jshint: { | ||
all: ['Gruntfile.js', 'app/**/*.js'] | ||
}, | ||
imagemin: { | ||
dist: { | ||
options: { | ||
optimizationLevel: 3 | ||
}, | ||
files: [ | ||
{ | ||
expand: true, | ||
cwd: 'app/images', | ||
src: ['**/*.{png,jpg,jpeg}'], | ||
dest: 'dist/images/' | ||
} | ||
] | ||
} | ||
}, | ||
concat: { | ||
css : { | ||
src : ['app/styles/*.css', '!app/styles/all.css'], | ||
dest : 'app/styles/all.css' | ||
}, | ||
module: { | ||
src: ['app/js/**/*.js'], | ||
dest: 'dist/js/module.js' | ||
}, | ||
init : { | ||
src: ['app/init.js'], | ||
dest : 'dist/js/init.js' | ||
}, | ||
lib : { | ||
src: ['bower_components/angular.js'], | ||
dest : 'dist/js/lib.js' | ||
}, | ||
core : { | ||
src : ['app/core.js'], | ||
dest : 'dist/js/core.js' | ||
} | ||
}, | ||
cssmin: { | ||
options: { | ||
keepSpecialComments: 0 | ||
}, | ||
compress: { | ||
files: { | ||
'dist/styles/all.min.css': ['app/styles/all.css'] | ||
} | ||
} | ||
}, | ||
uglify: { | ||
minjs: { | ||
files: [{ | ||
expand: true, | ||
cwd: 'app/', | ||
src: ['**/*.js', '!**/*.min.js'], | ||
dest: 'dist/', | ||
ext: '.min.js' | ||
}] | ||
} | ||
}, | ||
watch: { | ||
js : { | ||
files : ['app/**/*.js', 'Gruntfile.js'], | ||
tasks : ['jshint','concat:module','concat:init','concat:core'] | ||
}, | ||
css : { | ||
files : ['app/styles/*.css'], | ||
tasks : ['csslint','concat:css'] | ||
} | ||
}, | ||
wiredep : { | ||
src : ['app/index.html'] | ||
} | ||
}); | ||
grunt.registerTask('default', ['csslint', 'jshint', 'imagemin', 'cssmin', 'concat', 'uglify']); | ||
grunt.registerTask('css', ['concat:css', 'cssmin']); | ||
grunt.registerTask('dev', ['watch']); | ||
grunt.registerTask('test','test', function(){ | ||
require('wiredep')({ src: 'app/index.html' }); | ||
}); | ||
grunt.registerTask('build',['concat', 'cssmin', 'uglify','imagemin']); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
@author yanSun | ||
插件核心模块,负责app加载前阶段,并加载app | ||
*/ | ||
(function(window){ | ||
"use strict"; | ||
var APP_URL = ""; | ||
window.dobotStatus = 0; //0代表未加载,1代表正在加载,2代表加载, -1代表加载出错 | ||
function injectAppPoint(){ | ||
var douyuHeaderElement = document.getElementById('header').getElementsByClassName('header_nav')[0], | ||
pointElement = document.createElement('li'); | ||
pointElement.id = 'dobot_point'; | ||
pointElement.innerHTML = "<a href='javascript:;'>Dobot</a><img id='dobot_loading' style='display:none;width: 20px;height: 20px;position: absolute;top: -10px;right: 3px;' src='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48c3ZnIHdpZHRoPScxMjBweCcgaGVpZ2h0PScxMjBweCcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQiIGNsYXNzPSJ1aWwtcmlwcGxlIj48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgZmlsbD0ibm9uZSIgY2xhc3M9ImJrIj48L3JlY3Q+PGc+IDxhbmltYXRlIGF0dHJpYnV0ZU5hbWU9Im9wYWNpdHkiIGR1cj0iMnMiIHJlcGVhdENvdW50PSJpbmRlZmluaXRlIiBiZWdpbj0iMHMiIGtleVRpbWVzPSIwOzAuMzM7MSIgdmFsdWVzPSIxOzE7MCI+PC9hbmltYXRlPjxjaXJjbGUgY3g9IjUwIiBjeT0iNTAiIHI9IjQwIiBzdHJva2U9IiNlZjY2MDEiIGZpbGw9Im5vbmUiIHN0cm9rZS13aWR0aD0iNyIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIj48YW5pbWF0ZSBhdHRyaWJ1dGVOYW1lPSJyIiBkdXI9IjJzIiByZXBlYXRDb3VudD0iaW5kZWZpbml0ZSIgYmVnaW49IjBzIiBrZXlUaW1lcz0iMDswLjMzOzEiIHZhbHVlcz0iMDsyMjs0NCI+PC9hbmltYXRlPjwvY2lyY2xlPjwvZz48Zz48YW5pbWF0ZSBhdHRyaWJ1dGVOYW1lPSJvcGFjaXR5IiBkdXI9IjJzIiByZXBlYXRDb3VudD0iaW5kZWZpbml0ZSIgYmVnaW49IjFzIiBrZXlUaW1lcz0iMDswLjMzOzEiIHZhbHVlcz0iMTsxOzAiPjwvYW5pbWF0ZT48Y2lyY2xlIGN4PSI1MCIgY3k9IjUwIiByPSI0MCIgc3Ryb2tlPSIjZWY2NjAxIiBmaWxsPSJub25lIiBzdHJva2Utd2lkdGg9IjciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCI+PGFuaW1hdGUgYXR0cmlidXRlTmFtZT0iciIgZHVyPSIycyIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiIGJlZ2luPSIxcyIga2V5VGltZXM9IjA7MC4zMzsxIiB2YWx1ZXM9IjA7MjI7NDQiPjwvYW5pbWF0ZT48L2NpcmNsZT48L2c+PC9zdmc+'><span id='dobot_error_status' style='position: absolute;font-size: 4px;top: -6px;right: -9px;width: auto;height: auto;background-color: #ef6601;color: #fff;display: block;line-height: initial;'>error</span>"; | ||
douyuHeaderElement.appendChild(pointElement); | ||
pointElement.onclick = function(){ | ||
switch(window.dobotStatus){ | ||
case -1: | ||
case 0 : | ||
loadApp(); | ||
break; | ||
case 1 : | ||
showLoadingStatus(); | ||
break; | ||
case 2 : | ||
showApp(); | ||
break; | ||
} | ||
}; | ||
loadApp(); | ||
} | ||
/* | ||
加载app | ||
*/ | ||
function loadApp(){ | ||
var appWraper = document.createElement('div'), | ||
xhr = new XMLHttpRequest(); | ||
window.dobotStatus = 1; | ||
xhr.onreadystatechange = function(){ | ||
if(xhr.readyState == 4){ | ||
if(xhr.status == 200){ | ||
appWraper.innerHTML = xhr.responseText; | ||
} | ||
} | ||
}; | ||
xhr.open('GET', APP_URL); | ||
xhr.send(null); | ||
} | ||
function showLoadingStatus(){ | ||
document.getElementById('dobot_loading').style.display = 'block'; | ||
hideErrorStatus(); | ||
} | ||
function hideLoadingStatus(){ | ||
document.getElementById('dobot_loading').style.display = 'none'; | ||
} | ||
function showErrorStatus(){ | ||
document.getElementById('dobot_error_status').style.display = 'block'; | ||
hideLoadingStatus(); | ||
} | ||
function hideErrorStatus(){ | ||
document.getElementById('dobot_error_status').style.display = 'none'; | ||
|
||
} | ||
function showApp(){ | ||
var appPanelElement = document.getElementById('dobot'); | ||
hideLoadingStatus(); | ||
appPanelElement.style.display = 'block'; | ||
} | ||
injectAppPoint(); | ||
})(window); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div id="dobot"> | ||
<!-- bower:js --> | ||
<script src="../bower_components/angular/angular.js"></script> | ||
<script src="../bower_components/angular-cookies/angular-cookies.js"></script> | ||
<script src="../bower_components/ngDialog/js/ngDialog.js"></script> | ||
<!-- endbower --> | ||
</div> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "dobot", | ||
"version": "0.0.0", | ||
"dependencies": { | ||
"angular": "~1.3.15", | ||
"angular-cookies": "^1.3.0", | ||
"ngDialog": "^0.3.12" | ||
}, | ||
"appPath": "app", | ||
"moduleName": "appApp" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name" : "dobot", | ||
"version": "0.0.1", | ||
"dependencies": { | ||
"grunt": "latest", | ||
"grunt-contrib-watch": "latest", | ||
"grunt-contrib-concat": "latest", | ||
"grunt-contrib-copy": "latest", | ||
"grunt-contrib-uglify": "latest", | ||
"grunt-contrib-jshint": "latest", | ||
"grunt-contrib-csslint": "latest", | ||
"grunt-contrib-cssmin": "latest", | ||
"grunt-contrib-imagemin": "latest", | ||
"load-grunt-tasks" : "latest", | ||
"wiredep" : "latest", | ||
"jshint-stylish": "latest" | ||
}, | ||
"repository": {} | ||
} |