我正在写一个扭曲SVG图形的游戏应用程序,直到他们喊"叔叔!".当从Web服务器托管时,该程序在iPad(safari/webkit)上运行正常,此处不再需要说明.只要使用最新版本的Chrome(如v.25或更高版本),它在从Android服务器托管时也适用于Android平板电脑.
该程序根本不访问互联网,但使用其SVG图形,运行Javascript并将状态存储在HTML5 localStorage()中.
如果我在较旧的Android平板电脑的"默认浏览器"上运行该程序,则无法正确处理SVG图形,因此我需要在平板电脑上安装最新版本的Chrome.
我刚刚为我的应用创建了一个APK,并发现当我在我真正的新Android平板电脑上安装它时,它不会使用Chrome浏览器.相反,它似乎使用嵌入在APK中的浏览器,或者至少从平板电脑中存在补充库的APK中调用.
我对APK的目标是让我的代码运行最近的webkit浏览器,这似乎意味着在Chrome环境中运行.
对于我的问题,我需要改变一些事情.但是什么?
亲爱的读者能否为我提供线索?
谢谢,
杰罗姆.
我正在研究Angular2测试指南,并希望为ngOnInit()函数编写测试.编程指南的Routing部分中的那个具有以下格式:
let org: Org = null;
ngOnInit(): void {
let that = this;
this.route.data
.subscribe((data: { org: Org }) => {
that.org = data.org;
});
}
Run Code Online (Sandbox Code Playgroud)
这是通过解析器实现的,例如:
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Org> {
let id = this.authService.user.orgId;
return this.orgService
.getOrg(id)
.map(
(org: Org) : Org => {
if(org) {
return org;
} else {
// If the Org isn't available then the edit page isn't appropriate.
this.router.navigate(['/provider/home']);
return null;
}
})
.first();
}
Run Code Online (Sandbox Code Playgroud)
代码工作正常,但我不知道如何为ngOnInit编写测试.我可以使用的示例假设嵌入式OrgService可以由MockOrgService替换.但是,我所拥有的只是一个解析器.
我最终会弄清楚如何自己测试解析器.我可以使用基于旋转变压器的ngOnInit进行任何有用的测试吗?
谢谢,
杰罗姆.
我显示一个带有嵌入式SVG的HTML.我想要它来检测鼠标事件,但它不适用于移动设备(Android Jellybean).它适用于桌面浏览器.
这是一个演示页面:http: //artsyenta.org/misc/ss/j.touchtry1.html.
如果将鼠标拖到圆圈上,则会在名为"j_xxx"的元素中看到鼠标条目的日志.这适用于Firefox和Chrome.
打开你的Android平板电脑(我也在某人的iPhone上试过这个,结果相同).将手指拖过圆圈即可立即获得一个touchenter事件.没有其他表现.
您可以通过查看页面源来查看整个页面和代码.它不长,最长的部分是SVG定义.重要的部分是:
$(document).ready(function() {
makeSomethingHappen("hello");
});
function makeSomethingHappen(svg) {
placeATop(true);
$('[class^=j_]')
.on("mouseover", function(event) { logAction(event, this); })
.on("mouseout", function(event) { logAction(event, this); })
.on("touchstart", function(event) { logAction(event, this); })
.on("touchend", function(event) { logAction(event, this); })
.on("touchenter", function(event) { logAction(event, this); })
.on("touchleave", function(event) { logAction(event, this); })
.on("touchEnter", function(event) { logAction(event, this); })
.on("touchLeave", function(event) { logAction(event, this); });
}
var cntAct = 0;
function logAction(ev, ele) {
cntAct++;
var logSpan = …Run Code Online (Sandbox Code Playgroud) 我使用HTML5,Javascript和许多SVG图形创建了一个网页.它在我的Android平板电脑上的原生Android浏览器和最新的Chrome浏览器上运行良好.
我已将我的应用程序包装在PhoneGap中并将其部署在模拟器中.一切都好.然后我将它部署在平板电脑上.我没有得到相同的结果.
当我的META标签包含"target-densitydpi ="device-dpi"时,我的SVG图形会像在浏览器中一样大,但文本大小只有一半.
我被告知target-densitydpi已被弃用,所以我想弄清楚如何做到这一点.
我有这个activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
而这个META:
<meta name="viewport" content="width=device-width, height=device-height, user-scalable=no, initial-scale=1, minimum-scale=1, maximum-scale=1" />
Run Code Online (Sandbox Code Playgroud)
在我的window.onload()中,我执行计算来调整SVG图形的大小:
var minWindowDim = Math.min(window.screen.availWidth, window.screen.availHeight)
var maxWindowDim = Math.max(window.screen.availWidth, window.screen.availHeight)
var minEffectiveDim = Math.min(minWindowDim, (maxWindowDim / 1.5));
var minDim = minEffectiveDim * AVID.avidSizeFactor;
var avidWrapper = document.getElementById("avidWrapper");
avidWrapper.setAttribute("height", minDim);
avidWrapper.setAttribute("width", minDim);
Run Code Online (Sandbox Code Playgroud)
avidWrapper是一个名义上为318像素的SVG.这就是为什么高度和宽度设置相同.
我发出一些警告告诉我发生了什么事.
在桌面Chrome浏览器中:
window.screen.availWidth: 1600
window.screen.availHeight: 860
minWindowDim: 860
maxWindowDim: 1600
minEffectiveDim: 860
minDim: 817 // This is 95% of …Run Code Online (Sandbox Code Playgroud) 请注意,我已经更改了表格和字段的名称,以使其简短易懂.
我有一个问题,归结为,来到这个:
update destTable
set destField = ( select top 1 isnull(s.sourceField, '') from sourceTable s
where <various matches between the destTable table and the s table>
);
Run Code Online (Sandbox Code Playgroud)
(我知道语法'更新destTable设置destField ...来自destTable d,sourceTable s ......'但是我不知道如何将"top 1"放入其中.)
从这里我得到SQLServer 2012 Express结果:
Msg 515, Level 16, State 2, Line 1
Cannot insert the value NULL into column 'destField', table 'destTable'; column does not allow nulls. UPDATE fails.
The statement has been terminated.
Run Code Online (Sandbox Code Playgroud)
对于这两个表,所有字段都定义为非null和default('').
"前1"很重要,因为sourceTable可能有多个匹配"where"子句.
我查询了sourceTable的所有行,发现它的所有sourceField值都是非null.然而,我得到了结果.
查询的本质是,在1000个destTable记录中,与sourceTable的匹配将仅产生300行的匹配.其他700个destTable记录将没有匹配项.
我不明白SQLServer对我做了什么.当我上次使用MySQL运行它时,此查询工作正常.
谢谢你,杰罗姆.
我有一个Angular 2应用程序,到目前为止工作正常.My GlobalsService.getGlobals()通过我的OptionService.getOptions()获取"USA States".我的代码落在哪里是在Karma/Jasmine测试中.
当我在当前的测试设置中调用getGlobals()时,我得到"this._subscribe不是函数"错误.我发现很难调试这个,因为Google Chrome不合作.
添加了调试的getGlobals()代码.我在getOptions()和.subscribe()之间拆分代码以查看发生了什么.
public getGlobals(): void {
let asdf = this.optionService.getOptions();
console.log("asdf is " + (typeof asdf) + ", asdf.subscribe is: " + asdf.subscribe);
try {
asdf.subscribe(
(options: Option[]) => this.fillOptions(options),
(error: string) => this.error = error
);
} catch(error) {
console.log("caught error involving asdf, it is: " + error);
throw error;
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,我得到:
LOG: 'asdf is object, asdf.subscribe is: function (observerOrNext, error, complete) {
[1] var operator = this.operator;
[1] var sink = toSubscriber_1.toSubscriber(observerOrNext, …Run Code Online (Sandbox Code Playgroud) android ×2
angular ×2
cordova ×2
javascript ×2
svg ×2
html5 ×1
isnull ×1
jasmine ×1
karma-runner ×1
mobile ×1
observable ×1
resolver ×1
sql ×1
sql-server ×1