App-Android(使用App+htnl5框架,解决消息推送兼容SignalR问题)
loulijun2021
2022-09-20 eb23a7c7faefe86330a88f9118b8211f6b86e75b
js/common.js
@@ -6,7 +6,9 @@
document.addEventListener('touchstart', shield, false);//取消浏览器的所有事件,使得active的样式在手机上正常生效
document.oncontextmenu=shield;//屏蔽选择函数
// H5 plus事件处理
var ws=null,as='pop-in';
   var ws = null,
      as = 'pop-in';
function plusReady(){
   ws=plus.webview.currentWebview();
   plus.key.addEventListener('backbutton', function(){
@@ -51,10 +53,17 @@
      ws.scrollIndicator||(ws.scrollIndicator='none');
      ws.scalable||(ws.scalable=false);
      ws.backButtonAutoControl||(ws.backButtonAutoControl='close');
      ws.titleNView=ws.titleNView||{autoBackButton:true};
         ws.titleNView = ws.titleNView || {
            autoBackButton: true
         };
      ws.titleNView.backgroundColor = '#D74B28';
      ws.titleNView.titleColor = '#CCCCCC';
      ws.doc&&(ws.titleNView.buttons=ws.titleNView.buttons||[],ws.titleNView.buttons.push({fontSrc:'_www/helloh5.ttf',text:'\ue301',fontSize:'20px',onclick:'javascript:openDoc()'}));
         ws.doc && (ws.titleNView.buttons = ws.titleNView.buttons || [], ws.titleNView.buttons.push({
            fontSrc: '_www/helloh5.ttf',
            text: '\ue301',
            fontSize: '20px',
            onclick: 'javascript:openDoc()'
         }));
      t&&(ws.titleNView.titleText=t);
      openw = plus.webview.create(id, id, ws);
      openw.addEventListener('loaded', function(){
@@ -152,7 +161,8 @@
};
// 格式化日期时间字符串,格式为"YYYY-MM-DD HH:MM:SS"
w.dateToStr=function(d){
   return (d.getFullYear()+"-"+ultZeroize(d.getMonth()+1)+"-"+ultZeroize(d.getDate())+" "+ultZeroize(d.getHours())+":"+ultZeroize(d.getMinutes())+":"+ultZeroize(d.getSeconds()));
      return (d.getFullYear() + "-" + ultZeroize(d.getMonth() + 1) + "-" + ultZeroize(d.getDate()) + " " +
         ultZeroize(d.getHours()) + ":" + ultZeroize(d.getMinutes()) + ":" + ultZeroize(d.getSeconds()));
};
/**
 * zeroize value with length(default is 2).
@@ -172,7 +182,8 @@
})(window);
// fast click 
;(function () {
;
(function() {
   'use strict';
   /**
@@ -282,7 +293,9 @@
      // Some old versions of Android don't have Function.prototype.bind
      function bind(method, context) {
         return function() { return method.apply(context, arguments); };
         return function() {
            return method.apply(context, arguments);
         };
      }
@@ -477,7 +490,8 @@
      // Synthesise a click event, with an extra attribute so it can be tracked
      clickEvent = document.createEvent('MouseEvents');
      clickEvent.initMouseEvent(this.determineEventType(targetElement), true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);
      clickEvent.initMouseEvent(this.determineEventType(targetElement), true, true, window, 1, touch.screenX,
         touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);
      clickEvent.forwardedTouchEvent = true;
      targetElement.dispatchEvent(clickEvent);
   };
@@ -500,7 +514,8 @@
      var length;
      // Issue #160: on iOS 7, some input elements (e.g. date datetime month) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
      if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month') {
      if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 &&
         targetElement.type !== 'time' && targetElement.type !== 'month') {
         length = targetElement.value.length;
         targetElement.setSelectionRange(length, length);
      } else {
@@ -631,9 +646,11 @@
    * @returns {boolean}
    */
   FastClick.prototype.touchHasMoved = function(event) {
      var touch = event.changedTouches[0], boundary = this.touchBoundary;
      var touch = event.changedTouches[0],
         boundary = this.touchBoundary;
      if (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) > boundary) {
      if (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) >
         boundary) {
         return true;
      }
@@ -653,7 +670,8 @@
      }
      // If the touch has moved, cancel the click tracking
      if (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(event)) {
      if (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(
            event)) {
         this.trackingClick = false;
         this.targetElement = null;
      }
@@ -682,7 +700,8 @@
      // If no for attribute exists, attempt to retrieve the first labellable descendant element
      // the list of which is defined here: http://www.w3.org/TR/html5/forms.html#category-label
      return labelElement.querySelector('button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea');
      return labelElement.querySelector(
         'button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea');
   };
@@ -693,7 +712,8 @@
    * @returns {boolean}
    */
   FastClick.prototype.onTouchEnd = function(event) {
      var forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this.targetElement;
      var forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this
         .targetElement;
      if (!this.trackingClick) {
         return true;
@@ -726,7 +746,8 @@
         touch = event.changedTouches[0];
         // In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null
         targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) || targetElement;
         targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window
            .pageYOffset) || targetElement;
         targetElement.fastClickScrollParent = this.targetElement.fastClickScrollParent;
      }
@@ -745,7 +766,8 @@
         // Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through.
         // Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37).
         if ((event.timeStamp - trackingClickStart) > 100 || (deviceIsIOS && window.top !== window && targetTagName === 'input')) {
         if ((event.timeStamp - trackingClickStart) > 100 || (deviceIsIOS && window.top !== window &&
               targetTagName === 'input')) {
            this.targetElement = null;
            return false;
         }
@@ -974,7 +996,8 @@
         // Firefox 27+ does not have tap delay if the content is not zoomable - https://bugzilla.mozilla.org/show_bug.cgi?id=922896
         metaViewport = document.querySelector('meta[name=viewport]');
         if (metaViewport && (metaViewport.content.indexOf('user-scalable=no') !== -1 || document.documentElement.scrollWidth <= window.outerWidth)) {
         if (metaViewport && (metaViewport.content.indexOf('user-scalable=no') !== -1 || document
               .documentElement.scrollWidth <= window.outerWidth)) {
            return true;
         }
      }