Trying to delete ":view: in Telescope. Is something wrong with my code? - meteor

I want to get rid of the "view:" text from the template in Telescope.
This is my client/lib/config.js file:
module.exports = {
banner: '/**\n' +
' * core-js ' + require('../package').version + '\n' +
' * https://github.com/zloirock/core-js\n' +
' * License: http://rock.mit-license.org\n' +
' * © ' + new Date().getFullYear() + ' Denis Pushkarev\n' +
' */'
Telescope.modules.remove("top","posts_views_nav");
};
I've added Telescope.modules.remove("top","posts_views_nav");. However this does not seem to be working.
Could someone help?
Thanks.

I am not sure where you added that line.
I usually use my-custom-package to edit Telescope. Telescope overwrites original files with custom_ prefix files.
Create custom_modules.js
Make the changes you need.
Add custom_modules.js to package.js in your custom package folder.
Let me know it that helped.

Related

Code snippet not working after recent update to wordpress

Hi all I am a bit stumped it seems after the latest update to wordpress this function has stopped working. Any ideas would be gratefully received . . .
First snippet gets the parameter "we" and should then auto fill the form field id #input_2_4 after making some calculations.
`<script>
$.urlParam = function (name) {
var results = new RegExp('[\?&]' + name + '=([^&#]*)')
.exec(window.location.href);
return results[1] || 0;
}
var we = parseInt( $.urlParam('we') );
$('#input_2_4').val( '£' + (we * 0.1450).toFixed(2));
</script>`
Everything seems present in the url string including &we=1685 value but field #input_3_4 is now blank.
Link
I'd try it like below to remove any $ issues. Console.log should let you know if the issue is in getting the URL parameters. You may need to look at enqueueing the script as well to make sure it's getting loaded in the proper order.
jQuery.urlParam = function (name) {
var results = new RegExp('[\?&]' + name + '=([^&#]*)')
.exec(window.location.href);
console.log(window.location.href)
console.log(results[1] || 0);
return results[1] || 0;
}
var we = parseInt( jQuery.urlParam('we') );
jQuery('#input_2_4').val( '£' + (we * 0.1450).toFixed(2));

Google Appmaker createItem failing with could not select element

I have a temporary table where I let the user copy the record that needs to be edited. Once the edit is complete, I copy it back.
I am getting an error when I am trying to copy the original record to temporary table for editing. Here's the code I am using
console.log('copyOriginalToTemp ' + tempRecord.ID + ' options ' + JSON.stringify(options));
var myCreateDatasource = app.datasources.RadiosTemp.modes.create;
console.log('# of items in myCreateDatasource ' + myCreateDatasource.items.length);
var draft = myCreateDatasource.item;
draft.BatchId = options.BatchId ;
draft.County = tempRecord.County ;
... // lot of assignments
console.log('About to create item ');
myCreateDatasource.createItem(function(createdRecord) {
console.log('Creating the Item ' + createdRecord._key);
app.datasources.RadiosTemp.query.filters.BatchId._equals = options.BatchId;
.....
});
Error message tells me that newly created item cannot be selected but I have no idea why?. If I change the datasource to Manual Save, I get the same error with no key since it is in Manual save mode.

Convert underscores to hyphens in angular variable

I have data icons whose classes are formatted by vehicle type and then sub-type, like so:
.di-icon-type-car-full-size-car
.di-icon-type-car-mid-size-car
.di-icon-type-van-large-van
.di-icon-type-van-minivan
In my view I am trying to dynamically set the class based on the current vehicle's information:
span(ng-class="'di-icon-type-' + vehicle.type + '-' + vehicle.sub_type")
The problem is, my vehicle.sub_type variable is formatted with underscores, not dashes. So the class appears as di-icon-type-car-full_size_car instead of di-icon-type-car-full-size-car, for example. Is there a way I can convert all underscores in my vehicle.sub_type variable to hyphens before using it?
I would suggest to move a string concatenation and dash normalization into a function in a controller like this:
$scope.getIconClass = function(vehicle) {
var className = 'di-icon-type-' + vehicle.type + '-' + vehicle.sub_type;
return className.replace(/_/g, '-');
};
Then use it like this in the template:
<span ng-class="getIconClass(vehicle)"></span>
Alternatively, you could write a custom filter to do the job:
.filter('kebabcase', function() {
return function (value) {
return value && value.replace(/_/g, '-');
};
});
Then use it like this:
<span ng-class="'di-icon-type-' + vehicle.type + '-' + vehicle.sub_type | kebabcase"></span>
Example Plunker: http://plnkr.co/edit/dRj6Sf3NeUq8IxnBshyE?p=preview
span(ng-class="'di-icon-type-' + vehicle.type.replace(/_/g, "-") + '-' + vehicle.sub_type")
should work for you

Grunt task for making sure you have copyrights on each file

I need to make sure there's copyrights notice at the beginning of each file.
How can I use grunt to fail my build in case the copyrights statement is missing?
First of all, I'm assuming you are referring to *.js or *.html or other similar work files, and not to graphic or binary files.
This can be done, with a grunt.registerTask which will:
1. loop through all relevant files
2. Read and compare first line to copyright line
3. If different - re-write file but a new first line which will be the copyright info
Pretty simple. Again - this will not work on binary files. I wrote this for you but it seems very useful, I might consider adding it as a plugin. Field tested:
run it by grunt verifyCopyright and also make sure that if your files are in a different directory your change it, and also if you want to process other files add them to the list as well. good luck...
grunt.registerTask('verifyCopyright', function () {
var fileRead, firstLine, counter = 0, fileExtension, commentWrapper;
copyrightInfo = 'Copyright by Gilad Peleg #2013';
//get file extension regex
var re = /(?:\.([^.]+))?$/;
grunt.log.writeln();
// read all subdirectories from your modules folder
grunt.file.expand(
{filter: 'isFile', cwd: 'public/'},
["**/*.js", ['**/*.html']])
.forEach(function (dir) {
fileRead = grunt.file.read('public/' + dir).split('\n');
firstLine = fileRead[0];
if (firstLine.indexOf(copyrightInfo > -1)) {
counter++;
grunt.log.write(dir);
grunt.log.writeln(" -->doesn't have copyright. Writing it.");
//need to be careful about:
//what kind of comment we can add to each type of file. i.e /* <text> */ to js
fileExtension = re.exec(dir)[1];
switch (fileExtension) {
case 'js':
commentWrapper = '/* ' + copyrightInfo + ' */';
break;
case 'html':
commentWrapper = '<!-- ' + copyrightInfo + ' //-->';
break;
default:
commentWrapper = null;
grunt.log.writeln('file extension not recognized');
break;
}
if (commentWrapper) {
fileRead.unshift(commentWrapper);
fileRead = fileRead.join('\n');
grunt.file.write( 'public/' + dir, fileRead);
}
}
});
grunt.log.ok('Found', counter, 'files without copyright');
})
Instead of checking to see if it's there and failing, why not just have a task that automatically injects it? See grunt-banner.
https://github.com/thekua/grunt-regex-check could be what you want. You define the regex to check for and if it finds it then the task fails.

How correctly assign value to field

I am trying to assign value for one edit field(not asp.net control) in asp.net application using JavaScript code. It seems that < character in value string gives problems for ASP.NET. If I remove < and > characters from value everything works fine.
Where is the problem? How to pass <> characters to the field? I don't want to use ServerSide code I want to do it on ClientSide using JS and HTML Edit box.
function loadShareBox(pageTitle) {
document.getElementById("shareHTML").value = '<a href="' + document.location.href + '" target=_blank>' + pageTitle + '</a>';
}
regards,
Tomas
try using these
< corresponds <
> corresponds >
the code would look like this
function loadShareBox(pageTitle) {
document.getElementById("shareHTML").value = '<a href="' + document.location.href + '" target=_blank>' + pageTitle + '</a>';
}
edit: ah, I think there is another problem. You are trying to insert a new element within another element. So you should create a new element and append in shareHTML.
var myLink = document.createElement("a");
myLink.setAttribute("href", "mylink");
var text = document.createTextNode("Link name");
myLink.appendChild(text);
var myElement = document.getElementById("shareHTML")
myElement.appendChild(myLink);
this should do the work

Resources