Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to filter specific url #34

Closed
izzuddinraffar opened this issue Nov 30, 2016 · 4 comments
Closed

How to filter specific url #34

izzuddinraffar opened this issue Nov 30, 2016 · 4 comments

Comments

@izzuddinraffar
Copy link

izzuddinraffar commented Nov 30, 2016

Hi, I'm using local storage / external storage and want to filter specific url when create a sticky note
For example, when I create sticky note on this url " http://test.com/dashboard/index.php?file=topic_exercise ", it saved on it for revisit page later.

In addition, if I enter to other url on same domain as " http://test.com/dashboard/index.php?file=topic_assessment ", the created sticky note not show on it.

This my code I have implemented,but not working,it still show sticky note in other url.
if($.PostItAll!=undefined){
$.PostItAll.changeConfig('global', {
addNew : false,
askOnDelete : false,
showInfo : false,
htmlEditor : false,
addArrow : 'all'
});
$.PostItAll.load({
page : '/dashboard/test.php?file=topic_exercise'

      });
    }
    $('#createStickyNote').on('click', function(){
        $.PostItAll.new({
        	content : 'Sticky Note.',
        	page     : '/dashboard/test.php?file=topic_exercise',
        	style : {
		    tresd           : true,
		    fontfamily      : 'verdana',
		    fontsize        : 'small',
		    arrow           : 'none'
		 },
		    features: {
		        savable : true
		    }
		});
    });

Thanks.

@julkue
Copy link
Contributor

julkue commented Nov 30, 2016

I'm not sure if @txusko understands what you mean, but I don't, I'm afraid.

Do you mean:

  1. Check for a URL before the creation of a sticky note?
  2. Check the URL of a saved sticky note?

@izzuddinraffar
Copy link
Author

Sorry for it, I have updated my issue above.

@txusko
Copy link
Owner

txusko commented Dec 3, 2016

Hi @izzud1655 sorry for my late reply, I didn't notice about your issue.

I don't know if I understand well your question, but If you want to filter the notes relative to the page you're visiting, you should change the global var: $.fn.postitall.globals.filter.

By default, it's set to "domain" (it will load all the notes created in the current domain), but you can change it to "page" (notes in current page) or to "all" (no filter).
If you want to retrieve notes relative to the page taking into account the parameters within a URL I think you should add a new option in "filter" global param and add a new exception in the getNotes method of the plugin.

This is the part I was referring to:

if(filtered == "domain")
    finded = (o.domain === window.location.origin);
else if(filtered == "page")
    finded = (o.domain === window.location.origin && o.page === window.location.pathname);
else
    finded = true;

I hope it helps ...

@izzuddinraffar
Copy link
Author

it's working,thanks, i have added as below..
if(filtered == "domain"){
finded = (o.domain === window.location.origin);
}else if(filtered == "page"){
finded = (o.domain === window.location.origin && o.page === window.location.pathname);
}else if(filtered == "url"){
console.log(window.location.pathname+'?file='+$.urlParam('file'));
finded = (o.domain === window.location.origin && o.page === window.location.pathname+'?file='+$.urlParam('file'));
console.log(finded);
}else{
finded = true;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants