+237
| /** | ||
| @author:focusbe | ||
| @email:1134420693@qq.com | ||
| @blog:http://blog.focusbe.com | ||
| @github:https://github.com/focusbe | ||
| **/ | ||
| define(['jquery','./prefix'],function($,PREFIX){ | ||
| alert(1); | ||
| // var $ = require('./jquery.js'); | ||
| // console.log($); | ||
| //var PREFIX = require('./prefix.js'); | ||
| console.log(PREFIX); | ||
| var BgSound = function(option){ | ||
| var audioElement = null; | ||
| var volumeclock = null; | ||
| var volume = 1; | ||
| var self = this; | ||
| var cursrc = ''; | ||
| var curstate; | ||
| var shouldplay = false; | ||
| var defaultOption = { | ||
| file:'', | ||
| loop:true, | ||
| volume:1, | ||
| autoplay:true, | ||
| onplay:function(){ | ||
| }, | ||
| onpause:function(){ | ||
| } | ||
| } | ||
| option = $.extend(defaultOption,option); | ||
| self.init = function(){ | ||
| if($("#SOUND_AUDIO").length==0) | ||
| { | ||
| var soundaudio_outer = $('<div id="SOUND_AUDIO_outer"></div>'); | ||
| soundaudio_outer.css({position:'absolute',width:100,height:100,top:'-100%'}); | ||
| $('body').append(soundaudio_outer); | ||
| soundaudio_outer.append('<audio id="SOUND_AUDIO"></audio>'); | ||
| self.audioElement = document.getElementById('SOUND_AUDIO'); | ||
| } | ||
| self.setAudio(); | ||
| if(option.autoplay) | ||
| { | ||
| self.play(); | ||
| $('body').bind('touchstart',touchPlayZhibo); | ||
| function touchPlayZhibo() | ||
| { | ||
| self.play(); | ||
| $('body').unbind('touchstart',touchPlayZhibo); | ||
| } | ||
| } | ||
| self.bind(); | ||
| }; | ||
| self.bind = function(){ | ||
| self.audioElement.addEventListener("playing", function(){ | ||
| if(typeof(option.onplay)=='function') | ||
| { | ||
| option.onplay(); | ||
| } | ||
| },false); | ||
| self.audioElement.addEventListener("pause", function(){ | ||
| if(typeof(option.onpause)=='function') | ||
| { | ||
| option.onpause(); | ||
| } | ||
| },false); | ||
| self.audioElement.addEventListener("ended", function(){ | ||
| if(typeof(option.onpause)=='function') | ||
| { | ||
| option.onpause(); | ||
| } | ||
| },false); | ||
| self.bindBackRun(); | ||
| }; | ||
| self.setAudio = function(thisoption){ | ||
| if(typeof(thisoption)=='object') | ||
| { | ||
| option = $.extend(option,thisoption); | ||
| } | ||
| if(cursrc!=option.file) | ||
| { | ||
| SOUND_AUDIO.src = option.file; | ||
| cursrc = option.file; | ||
| } | ||
| if(!option.loop) | ||
| { | ||
| SOUND_AUDIO.removeAttribute('loop'); | ||
| } | ||
| else | ||
| { | ||
| SOUND_AUDIO.loop = 'loop'; | ||
| } | ||
| SOUND_AUDIO.volume = option.volume; | ||
| volume = option.volume; | ||
| }; | ||
| self.play = function(thisoption){ | ||
| if(typeof(thisoption)=='object') | ||
| { | ||
| option = $.extend(option,thisoption); | ||
| self.setAudio(); | ||
| } | ||
| else if(typeof(thisoption)=='string') | ||
| { | ||
| option.file = thisoption; | ||
| self.setAudio(); | ||
| } | ||
| self.resume(); | ||
| curstate = 'play'; | ||
| }; | ||
| self.pause = function(huanchun){ | ||
| if(!self.audioElement) | ||
| return; | ||
| if(typeof(huanchun)=='undefined') | ||
| { | ||
| huanchun = true; | ||
| } | ||
| if(self.volumeclock) | ||
| { | ||
| clearInterval(self.volumeclock); | ||
| self.volumeclock = null; | ||
| } | ||
| //self.audioElement.pause(); | ||
| if(huanchun) | ||
| { | ||
| volume = self.audioElement.volume; | ||
| self.volumeclock = setInterval(function(){ | ||
| volume-=0.2; | ||
| if(volume<=0) | ||
| { | ||
| volume = 0; | ||
| self.audioElement.volume = 0; | ||
| clearInterval(self.volumeclock); | ||
| self.volumeclock = null; | ||
| self.audioElement.pause(); | ||
| return; | ||
| } | ||
| else{ | ||
| self.audioElement.volume=volume; | ||
| } | ||
| },100); | ||
| } | ||
| else{ | ||
| self.audioElement.volume = 0; | ||
| self.audioElement.pause(); | ||
| } | ||
| curstate = 'pause'; | ||
| }; | ||
| self.stop = function(huanchun){ | ||
| self.pause(huanchun); | ||
| self.audioElement.load(); | ||
| }; | ||
| self.resume = function(){ | ||
| if(!self.audioElement) | ||
| return; | ||
| if(self.volumeclock) | ||
| { | ||
| clearInterval(self.volumeclock); | ||
| self.volumeclock = null; | ||
| } | ||
| volume = self.audioElement.volume; | ||
| self.audioElement.play(); | ||
| self.volumeclock = setInterval(function(){ | ||
| volume+=0.2; | ||
| if(volume>=option.volume) | ||
| { | ||
| self.audioElement.volume = option.volume; | ||
| clearInterval(self.volumeclock); | ||
| self.volumeclock = null; | ||
| return; | ||
| } | ||
| else{ | ||
| self.audioElement.volume=volume; | ||
| } | ||
| },100); | ||
| curstate = 'play'; | ||
| }; | ||
| self.bindBackRun = function(){ | ||
| // Get Browser Specific Hidden Property | ||
| function hiddenProperty(prefix) { | ||
| if (prefix) { | ||
| return prefix + 'Hidden'; | ||
| } else { | ||
| return 'hidden'; | ||
| } | ||
| } | ||
| // Get Browser Specific Visibility State | ||
| function visibilityState(prefix) { | ||
| if (prefix) { | ||
| return prefix + 'VisibilityState'; | ||
| } else { | ||
| return 'visibilityState'; | ||
| } | ||
| } | ||
| // Get Browser Specific Event | ||
| function visibilityEvent(prefix) { | ||
| if (prefix) { | ||
| return prefix + 'visibilitychange'; | ||
| } else { | ||
| return 'visibilitychange'; | ||
| } | ||
| } | ||
| var prefix = PREFIX.js; | ||
| var hidden = hiddenProperty(prefix); | ||
| var visibilityState = visibilityState(prefix); | ||
| var visibilityEvent = visibilityEvent(prefix); | ||
| document.addEventListener(visibilityEvent, function(event) { | ||
| if (!document[hidden]) { | ||
| // The page is visible. | ||
| if(shouldplay) | ||
| { | ||
| self.resume(); | ||
| } | ||
| } else { | ||
| // The page is hidden. | ||
| if(curstate=='play') | ||
| { | ||
| shouldplay = true; | ||
| self.pause(false); | ||
| } | ||
| else{ | ||
| shouldplay = false; | ||
| } | ||
| } | ||
| }); | ||
| } | ||
| self.init(); | ||
| } | ||
| return BgSound; | ||
| }); |
+27
| //获取js,css3浏览器前缀 | ||
| define(function(){ | ||
| var prefix = function() { | ||
| if (typeof(window.getComputedStyle) == 'undefined') { | ||
| return { | ||
| dom: '', | ||
| lowercase: '', | ||
| css: '', | ||
| js: '' | ||
| }; | ||
| } | ||
| var styles = window.getComputedStyle(document.documentElement, ''), | ||
| pre = (Array.prototype.slice | ||
| .call(styles) | ||
| .join('') | ||
| .match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o']) | ||
| )[1], | ||
| dom = ('WebKit|Moz|MS|O').match(new RegExp('(' + pre + ')', 'i'))[1]; | ||
| return { | ||
| dom: dom, | ||
| lowercase: pre, | ||
| css: '-' + pre + '-', | ||
| js: pre[0].toUpperCase() + pre.substr(1) | ||
| }; | ||
| }; | ||
| return prefix; | ||
| }); |
+2
-6
@@ -1,6 +0,2 @@ | ||
| var bgdound = require('./bgsound/v1.js'); | ||
| define(function(){ | ||
| return { | ||
| bgsound: bgsound | ||
| }; | ||
| }); | ||
| var bgsound = require('./bgsound.js'); | ||
| exports.bgsound =bgsound; |
+17
-3
| { | ||
| "name": "focusbejs", | ||
| "version": "1.0.3", | ||
| "description": "focusbejs", | ||
| "version": "1.0.4", | ||
| "description": "focusbejs ui", | ||
| "main": "index.js", | ||
@@ -9,4 +9,18 @@ "scripts": { | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/focusbe/focusbejs.git" | ||
| }, | ||
| "keywords": [ | ||
| "focusbejs" | ||
| ], | ||
| "author": "focusbe", | ||
| "license": "ISC" | ||
| "license": "ISC", | ||
| "bugs": { | ||
| "url": "https://github.com/focusbe/focusbejs/issues" | ||
| }, | ||
| "homepage": "https://github.com/focusbe/focusbejs#readme", | ||
| "devDependencies": { | ||
| "jquery": "^1.9.1" | ||
| } | ||
| } |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
6
20%509
0.2%2
-33.33%0
-100%16699
-83.46%1
Infinity%