灯角

文章 0 评论 0 浏览 23

灯角 2024-10-25 01:10:09

尝试使用 jsonStr[k].title = 'new title';

Try using jsonStr[k].title = 'new title';

如何更改 JSON 字符串内的值

灯角 2024-10-24 23:13:46
<script>
    function goTo() {
        var input = get("box").value,
            frame = get("frame");

        if(input.match(/\bhttp(.)*/)) {
            frame.src = input;
        } else {
            input = "http://" + input;
            frame.src = input;
        }      
    }

    function get(id) {
        return document.getElementById(id);    
    }  
</script>

<input type="text" id="box" value="http://www.example.com" />
<button onClick="goTo();">go</button>

<iframe src="http://www.example.com" frameborder="0" id="frame" width="100%" height="90%"></iframe>

--> 示例 <--

<script>
    function goTo() {
        var input = get("box").value,
            frame = get("frame");

        if(input.match(/\bhttp(.)*/)) {
            frame.src = input;
        } else {
            input = "http://" + input;
            frame.src = input;
        }      
    }

    function get(id) {
        return document.getElementById(id);    
    }  
</script>

<input type="text" id="box" value="http://www.example.com" />
<button onClick="goTo();">go</button>

<iframe src="http://www.example.com" frameborder="0" id="frame" width="100%" height="90%"></iframe>

--> example <--

使用文本框更改 Iframe 中的 URL

灯角 2024-10-24 22:10:16

像这样的事情应该可以解决问题。

<input type="checkbox" class="divisions" value="division1" />
<input type="checkbox" class="division1_departments" value="division1_departmen1" />
<input type="checkbox" class="division1_departments" value="division1_departmen2" />
<input type="checkbox" class="divisions" value="division2" />
<input type="checkbox" class="division2_departments" value="division2_departmen1" />
<input type="checkbox" class="division2_departments" value="division2_departmen2" />
<script type="text/javascript">
    $(document).ready(function () {
        $("input.divisions:checkbox").click(function () {
            $("input." + $(this).val() + "_departments:checkbox").attr("checked", $(this).is(':checked'));
        });
    });
</script>

Something like this should do the trick.

<input type="checkbox" class="divisions" value="division1" />
<input type="checkbox" class="division1_departments" value="division1_departmen1" />
<input type="checkbox" class="division1_departments" value="division1_departmen2" />
<input type="checkbox" class="divisions" value="division2" />
<input type="checkbox" class="division2_departments" value="division2_departmen1" />
<input type="checkbox" class="division2_departments" value="division2_departmen2" />
<script type="text/javascript">
    $(document).ready(function () {
        $("input.divisions:checkbox").click(function () {
            $("input." + $(this).val() + "_departments:checkbox").attr("checked", $(this).is(':checked'));
        });
    });
</script>

在 jQuery 中,如何根据另一个复选框打开和关闭复选框的子集

灯角 2024-10-24 20:53:09

JAVA_OPTS 实际上在输出中运行吗?您可能需要实际将它们放在正在运行的命令行上,或者在其中包含 $JAVA_OPTS 。

Are JAVA_OPTS actually being run in the output? You may need to actually put them on the command line you're running, or include $JAVA_OPTS on it.

java.lang.outofmemory 异常 jvm 堆大小不足

灯角 2024-10-24 19:10:17

好吧,我会看看我能做些什么来提供帮助:/

我已经查看了进度标签的默认样式(它的 css 样式)(使用 Google Chrome 的 Inspect 元素选项),我发现以下内容(希望这有帮助) ):

1.  -webkit-appearance: progress-bar;
2.  background-attachment: scroll;
3.  background-clip: border-box;
4.  background-color: gray;
5.  background-image: none;
6.  background-origin: padding-box;
7.  border-bottom-color: black;
8.  border-bottom-style: none;
9.  border-bottom-width: 0px;
10. border-left-width: 0px;
11. border-right-width: 0px;
12. border-top-color: black;
13. border-top-style: none;
14. border-top-width: 0px;
15. display: inline-block;
16. font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif;
17. font-size: 16px;
18. height: 16px;
19. line-height: 16px;
20. margin-bottom: 0px;
21. margin-left: 0px;
22. margin-right: 0px;
23. margin-top: 0px;
24. outline-color: black;
25. outline-style: none;
26. outline-width: 0px;
27. padding-bottom: 0px;
28. padding-left: 0px;
29. padding-right: 0px;
30. padding-top: 0px;
31. position: static;
32. text-align: center;
33. vertical-align: -3px;
34. width: 160px;
Styles
________________________________________

element.style {}
Matched CSS Rules
user agent stylesheet

progress {
1.  -webkit-appearance: progress-bar;
2.  display: inline-block;
3.  height: 1em;
4.  width: 10em;
5.  vertical-align: -0.2em;
6.  background-color: gray;
}

Pseudo element
user agent stylesheet

progress::-webkit-progress-bar-value {
1.  -webkit-appearance: progress-bar;
2.  background-color: green;
}

Well I'll see what I can do to help :/

I have looked at the default style (the css style of it) of the progress tag (using Google Chrome's Inspect element option) and what I found is the following (hope this helps):

1.  -webkit-appearance: progress-bar;
2.  background-attachment: scroll;
3.  background-clip: border-box;
4.  background-color: gray;
5.  background-image: none;
6.  background-origin: padding-box;
7.  border-bottom-color: black;
8.  border-bottom-style: none;
9.  border-bottom-width: 0px;
10. border-left-width: 0px;
11. border-right-width: 0px;
12. border-top-color: black;
13. border-top-style: none;
14. border-top-width: 0px;
15. display: inline-block;
16. font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif;
17. font-size: 16px;
18. height: 16px;
19. line-height: 16px;
20. margin-bottom: 0px;
21. margin-left: 0px;
22. margin-right: 0px;
23. margin-top: 0px;
24. outline-color: black;
25. outline-style: none;
26. outline-width: 0px;
27. padding-bottom: 0px;
28. padding-left: 0px;
29. padding-right: 0px;
30. padding-top: 0px;
31. position: static;
32. text-align: center;
33. vertical-align: -3px;
34. width: 160px;
Styles
________________________________________

element.style {}
Matched CSS Rules
user agent stylesheet

progress {
1.  -webkit-appearance: progress-bar;
2.  display: inline-block;
3.  height: 1em;
4.  width: 10em;
5.  vertical-align: -0.2em;
6.  background-color: gray;
}

Pseudo element
user agent stylesheet

progress::-webkit-progress-bar-value {
1.  -webkit-appearance: progress-bar;
2.  background-color: green;
}

是否有可能为 html5 进度标签着色?

灯角 2024-10-24 18:48:49

基于颜色直方图的人脸检测方法与人脸方向无关。

Methods for face detection based on color histogram are independent of face orientation.

旋转人脸检测

灯角 2024-10-24 13:11:41

图片传输协议 http://en.wikipedia.org/wiki/Picture_Transfer_Protocol 是一个令人讨厌的小东西事物。到目前为止,我手中所有声称拥有适当 PTP 支持的相机都在某个地方失败了。但理论上可以使用PTP来远程控制相机,即触发快门、检索图片等。

与重新实现整个事情相比,我建议您获得一些易于使用的 PTP 库。 http://ptp.sourceforge.net 上列出了一些开源项目

There's the Picture Transfer Protocol http://en.wikipedia.org/wiki/Picture_Transfer_Protocol a nastly little thing. All the cameras I held in my hands so far, claiming they had proper PTP support failed it somewhere. But in theory one can use PTP to remote control a camera, i.e. trigger the shutter, retrieve the picture and so on.

Rater than reimplementing the whole thing I recommend you get some readily usable PTP library. There are some open source ones listed on http://ptp.sourceforge.net

如何以编程方式触发连接到 USB 的相机?

灯角 2024-10-24 07:08:27

对你有帮助吗?请注意紧随其后的帖子进行更正。

Does this help you at all? Pay attention to the post right after it for a correction.

MacVim 中的 command-t 插件 - 使 MacVim 无法工作

灯角 2024-10-24 03:44:32

如果您使用 Angular2/4,那么这里有一个很棒的指令

请参阅将数据动态加载到文本区域时的问题列表以获取解决方法。除此之外,它可以与 ReactiveForms 和模板表单配合使用。

作为参考,这是指令代码:

import { Input, AfterViewInit, ElementRef, HostListener, Directive} from '@angular/core';

@Directive({
    selector: 'textarea[autosize]'
})

export class Autosize implements AfterViewInit {

    private el: HTMLElement;
    private _minHeight: string;
    private _maxHeight: string;
    private _lastHeight: number;
    private _clientWidth: number;

    @Input('minHeight')
    get minHeight() { 
      return this._minHeight;
    }
    set minHeight(val: string) {
      this._minHeight = val;
      this.updateMinHeight();
    }

    @Input('maxHeight')
    get maxHeight() {
      return this._maxHeight; 
    }
    set maxHeight(val: string) {
      this._maxHeight = val;
      this.updateMaxHeight();
    }

 @HostListener('window:resize', ['$event.target'])
    onResize(textArea: HTMLTextAreaElement) {
      //Only apply adjustment if element width had changed.
      if (this.el.clientWidth === this._clientWidth) return;
      this._clientWidth = this.element.nativeElement.clientWidth;
      this.adjust();
    }

 @HostListener('input',['$event.target'])
  onInput(textArea: HTMLTextAreaElement): void {
    this.adjust();  
  }

  constructor(public element: ElementRef){
    this.el = element.nativeElement;
    this._clientWidth = this.el.clientWidth;
  }

  ngAfterViewInit(): void{
    // set element resize allowed manually by user
    const style = window.getComputedStyle(this.el, null);
    if (style.resize === 'both') {
            this.el.style.resize = 'horizontal';
        }
    else if (style.resize === 'vertical') {
            this.el.style.resize = 'none';
    }
    // run first adjust
    this.adjust();
  }

  adjust(): void{
    // perform height adjustments after input changes, if height is different
    if (this.el.style.height == this.element.nativeElement.scrollHeight + "px") return;
    this.el.style.overflowX = 'hidden';
    this.el.style.height = 'auto';
    this.el.style.height = this.el.scrollHeight + "px";
  }

  updateMinHeight(): void{
    // Set textarea min height if input defined
    this.el.style.minHeight = this._minHeight + 'px';
  }

  updateMaxHeight(): void{
    // Set textarea max height if input defined
    this.el.style.maxHeight = this._maxHeight + 'px';
  }

}

If you are using Angular2/4 there is a great directive here that works.

See the issues list for when you are loading data dynamically into the textarea for a workaround. Other than that issue it works fine with ReactiveForms and Template forms.

For reference, this is the directive code:

import { Input, AfterViewInit, ElementRef, HostListener, Directive} from '@angular/core';

@Directive({
    selector: 'textarea[autosize]'
})

export class Autosize implements AfterViewInit {

    private el: HTMLElement;
    private _minHeight: string;
    private _maxHeight: string;
    private _lastHeight: number;
    private _clientWidth: number;

    @Input('minHeight')
    get minHeight() { 
      return this._minHeight;
    }
    set minHeight(val: string) {
      this._minHeight = val;
      this.updateMinHeight();
    }

    @Input('maxHeight')
    get maxHeight() {
      return this._maxHeight; 
    }
    set maxHeight(val: string) {
      this._maxHeight = val;
      this.updateMaxHeight();
    }

 @HostListener('window:resize', ['$event.target'])
    onResize(textArea: HTMLTextAreaElement) {
      //Only apply adjustment if element width had changed.
      if (this.el.clientWidth === this._clientWidth) return;
      this._clientWidth = this.element.nativeElement.clientWidth;
      this.adjust();
    }

 @HostListener('input',['$event.target'])
  onInput(textArea: HTMLTextAreaElement): void {
    this.adjust();  
  }

  constructor(public element: ElementRef){
    this.el = element.nativeElement;
    this._clientWidth = this.el.clientWidth;
  }

  ngAfterViewInit(): void{
    // set element resize allowed manually by user
    const style = window.getComputedStyle(this.el, null);
    if (style.resize === 'both') {
            this.el.style.resize = 'horizontal';
        }
    else if (style.resize === 'vertical') {
            this.el.style.resize = 'none';
    }
    // run first adjust
    this.adjust();
  }

  adjust(): void{
    // perform height adjustments after input changes, if height is different
    if (this.el.style.height == this.element.nativeElement.scrollHeight + "px") return;
    this.el.style.overflowX = 'hidden';
    this.el.style.height = 'auto';
    this.el.style.height = this.el.scrollHeight + "px";
  }

  updateMinHeight(): void{
    // Set textarea min height if input defined
    this.el.style.minHeight = this._minHeight + 'px';
  }

  updateMaxHeight(): void{
    // Set textarea max height if input defined
    this.el.style.maxHeight = this._maxHeight + 'px';
  }

}

当您键入文本时会扩展的 CSS 文本区域

灯角 2024-10-24 02:40:54

这很难。我制作了很多自定义视图,我首先想到的是,用上图制作一个 Button,并自己处理 onTouch,以便您可以区分用户点击的区域。在那里您还可以更改按钮的状态,例如将图像更改为斜角图像,例如当按下左侧按钮时。

你能想象这个 ansatz 吗?

That's a hard one. I made a lot of custom views, and the first thing I would thinking of is, made one Button with that above image, and handle onTouch by yourself so you can distinguish which area the user hit. There you can also change the state of the button, like changing the image to a bevel one e.g. when the left button is hit.

Can you imagine this ansatz?

安卓自定义按钮

灯角 2024-10-24 02:29:51

虽然我意识到这个问题是针对 winforms 的,但请允许我为 wpf 寻求者提供一个答案(实际上,正如我到达这里的那样)。

只需将类似的内容放入组合框中即可。

<Grid>
    <ComboBox Width="1" Height="1" IsDropDownOpen="{Binding ElementName=TButton,Path=IsChecked,Mode=TwoWay}">
        <Grid Width="200" Height="400" Background="BlanchedAlmond" Margin="-5" IsHitTestVisible="True">
            <Button Background="Transparent"></Button> <--------- This is the equivalent of a e.handled
            <StackPanel>
                <Button Content="Button 1"/>
                <Button Content="Button 1"/>
                <Button Content="Button 1"/>
                <Button Content="Button 1"/>
            </StackPanel>
        </Grid>
    </ComboBox>
   <ToggleButton x:Name="TButton" Content="Drop" MaxHeight="40" MaxWidth="40"/>
</Grid>

快速而肮脏的修复,以获得体面、无麻烦的下拉控制。

当您单击组合框项目时,您实际上单击了不可见的按钮,并且组合保持打开状态。

我尝试过使用最热门的可见矩形,但没有骰子。这可以解决问题。

注意


应将不可见背景替换为完全剥离按钮的样式(当鼠标悬停或执行单击时)。

另外,使用下拉字体图标/路径而不是drop会很好。 :)

我再次为在这里发帖道歉。我一直在到处寻找一个具有 0 个外部依赖项的快速下拉控件(弹出窗口不会这样做),而我偶然发现的都是可笑的(不必要的)复杂的实现。我希望这能引导某人走向正确的方向!

祝你好运!

编辑
简单的不透明度 0 就可以了。嚯……

While I realize the question was intended for winforms, please allow me to contribute an answer for wpf seekers(as I got here, actually).

simply put something like this in the combo box.

<Grid>
    <ComboBox Width="1" Height="1" IsDropDownOpen="{Binding ElementName=TButton,Path=IsChecked,Mode=TwoWay}">
        <Grid Width="200" Height="400" Background="BlanchedAlmond" Margin="-5" IsHitTestVisible="True">
            <Button Background="Transparent"></Button> <--------- This is the equivalent of a e.handled
            <StackPanel>
                <Button Content="Button 1"/>
                <Button Content="Button 1"/>
                <Button Content="Button 1"/>
                <Button Content="Button 1"/>
            </StackPanel>
        </Grid>
    </ComboBox>
   <ToggleButton x:Name="TButton" Content="Drop" MaxHeight="40" MaxWidth="40"/>
</Grid>

Quick and dirty fix for a decent, hassle free drop down control.

When you click the combobox item, you actually click the invisible button and the combo stays open.

I've tried with a hittest visible rect, but no dice. This does the trick.

Note


One should replace the invisible background with a style that completely strips the button (when mouse is over or a click is performed).

Also, a drop font icon / path instead of drop would be nice. :)

I apologize again for posting here. I've been looking all over the place for a quick drop down control with 0 outside dependencies(popup won't do) and all I've stumbled across are ridiculously (needlessly) complicated implementations. I hope this will steer somebody in the right direction!

Best of luck to you!

Edit
A simple opacity 0 will do. Doh...

选择项目后如何使组合框保持打开状态?

灯角 2024-10-23 19:06:51

您应该模拟一个接口(它具有您需要的方法),而不是模拟具体的类。

例如:

public class SimpleJdbcDaoSupportExtension extends SimpleJdbcDaoSupport implements MyDomainDao{  
     public SimpleJdbcDaoSupportExtension (JdbcTemplate jdbcTemplate){  
             super.setJdbcTemplate(jdbcTemplate);  
     }

     public MyDomainObj getResult(){
         SimpleJdbcTemplate sjdbc = getSimpleJdbcTemplate();  
         MyDomainObj result = sjdbc.query(*whatever necessary args*.);
         return result;
     }
}

public class Test {  
    @Mock private MyDomainDao myDomainDao ;
    private YourController yourController;  

    @Before
    public void doBeforeEachTestCase() {
        MockitoAnnotations.initMocks(this);
        yourController = new YourController(myDomainDao);
    }  
    @Test
    public final void testSomething(){           
        when(myDomainDao.getResult().thenReturn(new MyDomainObj());
        //on to testing the usages of myDomainDao
        yourController.doSomething();
        //verify
        verify(myDomainDao, times(2)).getResult();
    }
}

Instead of mocking the concrete class, you ought to be mocking an interface (which has the methods you need).

e.g.:

public class SimpleJdbcDaoSupportExtension extends SimpleJdbcDaoSupport implements MyDomainDao{  
     public SimpleJdbcDaoSupportExtension (JdbcTemplate jdbcTemplate){  
             super.setJdbcTemplate(jdbcTemplate);  
     }

     public MyDomainObj getResult(){
         SimpleJdbcTemplate sjdbc = getSimpleJdbcTemplate();  
         MyDomainObj result = sjdbc.query(*whatever necessary args*.);
         return result;
     }
}

public class Test {  
    @Mock private MyDomainDao myDomainDao ;
    private YourController yourController;  

    @Before
    public void doBeforeEachTestCase() {
        MockitoAnnotations.initMocks(this);
        yourController = new YourController(myDomainDao);
    }  
    @Test
    public final void testSomething(){           
        when(myDomainDao.getResult().thenReturn(new MyDomainObj());
        //on to testing the usages of myDomainDao
        yourController.doSomething();
        //verify
        verify(myDomainDao, times(2)).getResult();
    }
}

Spring JUnit 和 Mockito - SimpleJdbcTemplate

灯角 2024-10-23 15:26:23

您无法直接在 Silverlight 应用程序中访问本地文件系统,因为该应用程序可能会危害系统;它被抽象掉了。

OOB Silverlight 应用程序增加了信任,但仍然无法像 WinForms 或 WPF 应用程序那样提供对文件系统的完整访问。

You don't have access to the local file system directly within a Silverlight application since the application could compromise the system; it is abstracted away.

An OOB Silverlight application has increased trust but still does not provide complete access to the file system as would a WinForms or WPF application.

了解 Silverlight

灯角 2024-10-23 14:58:03

strip_tags 应该适用于大多数情况。我个人倾向于使用更全面的库来处理用户提交的文本。 htmLawed 非常适合此目的。

http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/index.php

strip_tags should work for most cases. I personally favor using a more comprehensive library to handle user-submitted text. htmLawed is excellent for this purpose.

http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/index.php

如何不允许用户提交链接? (html 表单/PHP/javascript)

灯角 2024-10-23 13:54:42

对于仅包含文件的文件夹,您的方法是不错的,但是如果您正在寻找还包含子文件夹的场景,则需要递归

此外,您还应该捕获返回的返回值,以确保允许您删除文件

并包含

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

在你的清单中

void DeleteRecursive(File dir)
{
    Log.d("DeleteRecursive", "DELETEPREVIOUS TOP" + dir.getPath());
    if (dir.isDirectory())
    {
        String[] children = dir.list();
        for (int i = 0; i < children.length; i++)
        {
            File temp = new File(dir, children[i]);
            if (temp.isDirectory())
            {
                Log.d("DeleteRecursive", "Recursive Call" + temp.getPath());
                DeleteRecursive(temp);
            }
            else
            {
                Log.d("DeleteRecursive", "Delete File" + temp.getPath());
                boolean b = temp.delete();
                if (b == false)
                {
                    Log.d("DeleteRecursive", "DELETE FAIL");
                }
            }
        }

    }
    dir.delete();
}

Your approach is decent for a folder that only contains files, but if you are looking for a scenario that also contains subfolders then recursion is needed

Also you should capture the return value of the return to make sure you are allowed to delete the file

and include

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

in your manifest

void DeleteRecursive(File dir)
{
    Log.d("DeleteRecursive", "DELETEPREVIOUS TOP" + dir.getPath());
    if (dir.isDirectory())
    {
        String[] children = dir.list();
        for (int i = 0; i < children.length; i++)
        {
            File temp = new File(dir, children[i]);
            if (temp.isDirectory())
            {
                Log.d("DeleteRecursive", "Recursive Call" + temp.getPath());
                DeleteRecursive(temp);
            }
            else
            {
                Log.d("DeleteRecursive", "Delete File" + temp.getPath());
                boolean b = temp.delete();
                if (b == false)
                {
                    Log.d("DeleteRecursive", "DELETE FAIL");
                }
            }
        }

    }
    dir.delete();
}

如何删除整个文件夹和内容?

更多

推荐作者

lixs

文章 0 评论 0

敷衍 

文章 0 评论 0

盗梦空间

文章 0 评论 0

tian

文章 0 评论 0

13375331123

文章 0 评论 0

你对谁都笑

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文